0 users online | 0 Guests and 0 Registered

»

ID #1008

Ein Formular (TForm) aus einer DLL aufrufen/anzeigen

Der Sourcecode der DLL muss so aussehen :

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.

Der Import der Procedure im Hauptprogramm erfolgt dann folgendermaßen :

procedure UserForm(appHandle:THandle); stdcall; external '<dll-name>';

Der eigentliche Aufruf des Fensters (Formulars) erfolgt so :

procedure TForm1.Buuton1Click(Sender:TObject);
begin
  UserForm(Application.Handle);
end;

 

Tags: -

Related entries:

Last update: 2009-10-27 23:07
Author: Rolf Warnecke
Revision: 1.0

{writePrintMsgTag} {writeSend2FriendMsgTag} {writePDFTag}
Please rate this FAQ:

Average rating: 5 (2 Votes)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ

Most popular FAQs RSS

  1. Display Resolution change
    (30 views)
  2. Scanned a Picture
    (13 views)

Latest FAQs RSS

  1. Scanned a Picture
    (2010-11-19 06:01)
  2. Display Resolution change
    (2010-02-09 18:01)