This works for me:
The
DLL (.dpr):
Delphi-Quellcode:
library MyDLL;
uses
SysUtils,
Classes,
Windows,
Forms,
uMDIChild
in '
uMDIChild.pas'
{MDIChild};
// This is the unit that contains the mdi child form
var PrevApplication: TApplication;
PrevScreen: TScreen;
procedure DLLEntryProc(EntryCode: integer);
begin
case EntryCode
of
DLL_PROCESS_ATTACH:
begin
// Do Initialization stuff here. Called when a process loads the DLL
PrevApplication := Application;
PrevScreen := Screen;
end;
DLL_PROCESS_DETACH:
begin
// Do Finalization stuff here. Called when a process unloads the DLL
Application := PrevApplication;
Screen := PrevScreen;
end;
end;
end;
procedure CreateForm(A: TApplication; S: TScreen);
export;
begin
Application := A;
Screen := S;
TMDIChild.Create(Application);
end;
exports CreateForm;
begin
DLLProc := @DLLEntryProc;
DLLEntryProc(DLL_PROCESS_ATTACH);
end.
In your mainform declare like this:
procedure CreateForm(A: TApplication; S: TScreen); external 'MyDLL.dll';
And create an
MDI child like this:
CreateForm(Application, Screen);
The clientform has a constructor:
Delphi-Quellcode:
constructor TMDIChild.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;