Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi MDI-Form & MDI-Child & DLL's (https://www.delphipraxis.net/104912-mdi-form-mdi-child-dlls.html)

Remko 29. Dez 2007 19:22

Re: MDI-Form & MDI-Child & DLL's
 
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:
Delphi-Quellcode:
procedure CreateForm(A: TApplication; S: TScreen); external 'MyDLL.dll';
And create an MDI child like this:
Delphi-Quellcode:
CreateForm(Application, Screen);
The clientform has a constructor:
Delphi-Quellcode:
constructor TMDIChild.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:18 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz