5,392
社区成员
发帖
与我相关
我的任务
分享
library Project1;
uses
SysUtils,
Classes,
Controls,
Forms,
Windows,
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
procedure ShowForm(app:TApplication; parent:TWinControl);stdcall;
var
frm : TForm2;
begin
frm := TForm2.Create(Application);
frm.ParentWindow := parent.Handle;
frm.Show;
frm.Align := alClient;
end;
exports
ShowForm name 'ShowForm';
begin
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, ExtCtrls,ShellAPI;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
Button1: TButton;
TabSheet1: TTabSheet;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
procedure ShowForm(app:TApplication; parent:TWinControl);stdcall;external 'Project1.dll';
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowForm(Application,PageControl1.Pages[0]);
end;
end.
library Project1;
uses
SysUtils,
Classes,
Controls,
Forms,
Windows,
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
var
DllApp:TApplication;
procedure ShowForm(app:TApplication; parent:TWinControl);stdcall;
var
frm : TForm2;
begin
Application := app;
frm := TForm2.Create(Application);
frm.ParentWindow := parent.Handle;
frm.Show;
frm.Align := alClient;
end;
procedure DLLMain(Reason: Integer); register;
begin
{DLL取消调用时,发送DLL_PROCESS_DETACH消息,此时将DLL的Application返回为本身}
if Reason = DLL_PROCESS_DETACH then Application:=DLLApp;
end;
exports
ShowForm name 'ShowForm';
begin
DllApp := Application;
DLLProc := @DLLMain;
end.