Entwickler-Ecke

Visual Component Library (VCL) - ...ein Formular aus DLL anzeigen/aufrufen?


bis11 - Mo 03.03.03 22:36
Titel: ...ein Formular aus DLL anzeigen/aufrufen?
ein Formular aus DLL anzeigen/aufrufen?

Da dieses Thema hier schon öfters besprochen wurde, habe ich nochmal zusätzlich ein bisschen im WWW rumgesucht und dieses hier gefunden :

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
library FormDialog;

uses
  SysUtils,
  Classes,
  Windows,
  Forms,
  FormUnit in 'FormUnit.pas' {UserForm};

{$R *.res}

procedure UserForm(appHandle: THandle); stdcall;
begin
  if appHandle = 0 then apphandle := GetActiveWindow;
  Application.Handle := appHandle;
  try
    with TUserLoginMain.Create(Application) Do // hier muss natürlich der Klassen-Bezeichner der Form stehen
                                               // TUserLoginMain ist nur ein Beispiel
      try
        ShowModal
      finally
        Free;
      end
  except
    On E: Exception Do Application.HandleException(E);
  end;
  Application.Handle := 0;
end;

exports
  UserForm;
  
begin

end.

Die Einbindung der DLL in das Projekt :

Delphi-Quelltext
1:
procedure UserForm(appHandle:THandle); stdcall;                    

Aufrufen kann ich das ganze dann zum Beispiel so :

Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Buuton1Click(Sender:TObject);
begin
  UserForm(Application.Handle);
end;

Moderiert von user profile iconjasocul: Beitrag geprüft am 22.05.2006