S
soFTangeL
Unregistered / Unconfirmed
GUEST, unregistred user!
好像DLL和MainForm都有一个Application信息?加载DLL时使用 Dll.Application.Handle:=MainForm.Application.Handle,然后在DLL里面不能正确获取MainForm的Application.Title。[]
主窗口:
procedure TfrmMain.miAboutClick(Sender: TObject);
var
AboutHandle: THandle;
ShowAboutForm: TShowModalForm;
begin
AboutHandle := LoadLibrary('./About.dll');
if AboutHandle = 0 then
Exit;
@ShowAboutForm := GetProcAddress(AboutHandle, 'ShowModalForm');
if not (@ShowAboutForm = nil) then
ShowAboutForm(Application.Handle);
FreeLibrary(AboutHandle);
end;
Dll部分:
procedure ShowModalForm(AHandle: THandle)
stdcall;
procedure ShowModalForm(AHandle: THandle);
begin
Application.Handle := AHandle;
with TfrmAbout.Create(Application) do
begin
try
ShowModal;
finally
Free;
end;
end;
end;
procedure TfrmAbout.FormShow(Sender: TObject);
begin
lblAppName.Caption := Application.Title
//此处不能获取主窗口所在Application的Title。
end;
主窗口:
procedure TfrmMain.miAboutClick(Sender: TObject);
var
AboutHandle: THandle;
ShowAboutForm: TShowModalForm;
begin
AboutHandle := LoadLibrary('./About.dll');
if AboutHandle = 0 then
Exit;
@ShowAboutForm := GetProcAddress(AboutHandle, 'ShowModalForm');
if not (@ShowAboutForm = nil) then
ShowAboutForm(Application.Handle);
FreeLibrary(AboutHandle);
end;
Dll部分:
procedure ShowModalForm(AHandle: THandle)
stdcall;
procedure ShowModalForm(AHandle: THandle);
begin
Application.Handle := AHandle;
with TfrmAbout.Create(Application) do
begin
try
ShowModal;
finally
Free;
end;
end;
end;
procedure TfrmAbout.FormShow(Sender: TObject);
begin
lblAppName.Caption := Application.Title
//此处不能获取主窗口所在Application的Title。
end;