Benim projem öncelikle bir kullanıcı giriş ekranı (.exe) sonrasında Anamenu.dll yükleniyor. Anamenüdende formların bulunduğu dll ler yükleniyor. mesela Ticaret.dll, Finans.dll, Uretim.dll vb.gibi... mesela Ticaret.dll i LoadLibrary(Ticaret.dll) şeklinde yükledikten sonra içindeki datamodulu create ediyorum ve sql bağlantısını hazır hale getiriyorum.
şimdi bu şekilde çalışmada hiçbir problem yok fakat 5-6 form açıldığında windows görev çubuğunda hiçte hoş olmayan görüntü oluşuyor. Formlar haliyle görev çubuğunda yer işgal ediyor.
ben bu şekilde değilde mdi-child form sistemine geçmek istiyordum. uğraşlarım sonucu önce exe sonra yüklenen dll ve yüklenen dll içine yüklenen child dll yapmayı başardım. Fakat sorunlar da beraberinde başladı. birincisi yüklenen child formun içinde cxVerticalGrid component var ise "Cannot assing TFont to a Tfont" hata mesajı alıyorum.
Kullandığım dll çağırma sistemindemi hata var başka bir yerdemi anlayamadım. örnek kodlar aşağıda yardımlarınızı bekliyorum.
Teşekkürler.
bu örneği kodbank' tan bulmuştum.
exe kodları...
Kod: Tümünü seç
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, dxBar, dxBarExtItems, Menus;
type
TShowFrm = procedure(App: TApplication; Scr:TScreen); stdcall;
TForm1 = class(TForm)
btnYukle: TButton;
procedure FormCreate(Sender: TObject);
procedure btnYukleClick(Sender: TObject);
private
{ Private declarations }
hInstance: THandle;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
try
hInstance := SafeLoadLibrary('Project1.dll', SEM_NOOPENFILEERRORBOX);
{load the library on form create as will need to know what
forms are available, so they can be listed for creation.}
except
on e: exception do ShowMessage(e.Message);
end;
end;
procedure TForm1.btnYukleClick(Sender: TObject);
var
AFunc: Pointer;
begin
if Form1.MDIChildCount = 0 then
try
begin
Pointer(AFunc) := GetProcAddress(hInstance, PChar ('ShowFrm'));
TShowFrm(AFunc)(Application, Screen); {Open the child form}
end;
except
on e: exception do ShowMessage(e.Message);
end;
end;
end.
Kod: Tümünü seç
library Project1;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Forms,
Windows,
Dialogs,
Unit1 in 'Unit1.pas' {F_form1},
datamodul in 'datamodul.pas' {DataModule3: TDataModule};
{$R *.res}
var
AppDLL: TApplication;
ScrDLL: TScreen;
procedure MyDLLProc(Reason: Integer);
begin
try
if Reason = DLL_PROCESS_DETACH then
begin
Application := AppDLL;
Screen := ScrDLL;
end;
except
on e: exception do ShowMessage(e.Message);
end;
end;
procedure ShowFrm(App:TApplication; Scr: TScreen); stdcall;
begin
Application := App;
Screen := Scr;
App.ShowHint:= False;
App.CreateForm(TDataModule3, DataModule3);
App.CreateForm(TF_form1, F_form1);
F_form1.ShowHint := False;
F_form1.Show;
end;
exports
ShowFrm;
begin
try
AppDLL := Application;
ScrDLL := Screen;
DLLProc := @MyDLLProc;
except
on e: exception do ShowMessage(e.Message);
end;
end.
Not : dll projesinde Datamodule ve F_Form1 açmak yeterlidir. proje bu şekilde çalışıyor. fakat F_Form1 formunun içine cxVerticalGrid koyduğmda Font Hatası alıyorum.