{ 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
Windows,
SysUtils,
Classes,
Forms,
Child in 'Child.pas' {Form1};
var
DllApp : THandle;
{$R *.RES}
procedure MyDLLProc(Reason: Integer);
begin
// DLL is unloading. Restore the Application pointer.
if Reason = DLL_PROCESS_DETACH then
begin
if DllApp<>0 then
Application.Handle := DllApp;
end;
end;
procedure CreateChildForm(MainApp:THandle);stdcall;export;
var
Child : TForm1;
begin
if not DllApp<>0 then
begin
DllApp := Application.Handle;
Application.Handle := MainApp;
end;
procedure TMainForm.CreateMDIChild(const Name: string);
var
H: HWnd;
iMy: procedure(MainApp:THandle);stdcall;
begin
{ create a new MDI child window }
CreateChildForm(Application.Handle);
end;
procedure TMainForm.FileNew1Execute(Sender: TObject);
begin
CreateMDIChild('NONAME' + IntToStr(MDIChildCount + 1));
end;
procedure TMainForm.FileOpen1Execute(Sender: TObject);
begin
if OpenDialog.Execute then
CreateMDIChild(OpenDialog.FileName);
end;
procedure TMainForm.HelpAbout1Execute(Sender: TObject);
begin
AboutBox.ShowModal;
end;
procedure TMainForm.FileExit1Execute(Sender: TObject);
begin
Close;
end;