dll内有一TFrame1
外部接口函数
function x(app:tapplication):Tframe;stdcall;
begin
Result:=tframe1.create(app);
end;主调程序
主窗体上有一个panel1
我这么调没报错,但也没显示任何内容的问题
var
f:tframe;
begin
f:=x(application);
f.parent:=panel1;
f.show;
end;
外部接口函数
function x(app:tapplication):Tframe;stdcall;
begin
Result:=tframe1.create(app);
end;主调程序
主窗体上有一个panel1
我这么调没报错,但也没显示任何内容的问题
var
f:tframe;
begin
f:=x(application);
f.parent:=panel1;
f.show;
end;
...
uses
SysUtils,
Forms,
Windows,
Messages,
Classes,
DLLFormUnit in 'DLLFormUnit.pas' {frmDLLForm};{$R *.res}function CreateDLLForm(App: TApplication):TForm;
begin
Application := App;
Application.CreateForm(TfrmDLLForm, frmDLLForm);
result:=frmDLLForm;
end;exports
CreateDLLForm;
begin
end.调用DLL的主窗口
...
type
LoadDLLFrm=function(App:TApplication):TForm;
...
var
DLLForm:TForm; //定义一个全局变量
implementation
procedure TForm1.Button1Click(Sender: TObject);
var
DLLHandle: THandle;
DLLSub: LoadDLLFrm;
begin
DLLHandle := LoadLibrary('d:\prjDLL.dll');
if DLLHandle <> 0 then
begin
@DLLSub := GetProcAddress(DLLHandle, 'CreateDLLForm');
if Assigned(DLLSub) then
begin
DLLForm := DLLSub(Application);
end;
DLLForm.Parent:=Panel1;
DLLForm.Align:=alClient;
DLLForm.Show;
end;
end;