请问,为什么调用DLL然后关闭, 主程序会自动置后。
DLL点关闭的时候,主程序就自动置后了,不知为什么。代码如下,
这个是普通窗体调用DLL。
procedure TForm1.Button1Click(Sender: TObject);
type
TGetForm = function (H: THandle) : Integer; cdecl;
var
DllForm : TGetForm;
DllHandle : THandle;
nn : integer;
begin
DllHandle := LoadLibrary(PChar('DebtMoney.dll'));
try
if DllHandle <> 0 then
begin
DllForm := GetProcAddress(DllHandle, 'EDebtMoney');
nn := DllForm(Application.Handle) ;
form1.Caption := inttostr(nn);
end;
finally
FreeLibrary(DllHandle);
end;
end;
这个是无边框窗体的DLL:
//DLL入口
Function EDebtMoney(H: THandle):integer;
begin
Application.Handle := H;
with TForm1.Create(Application) do try
KeyPreview :=True;
ShowModal;
Result := MySelect ;
finally
Free; { 调用结束时销毁窗口 }
end;
end;
请时间的老师帮忙看下 谢谢
[解决办法]
贴出来的代码没有问题
是不是你TForm1里有什么事件?
-------------------------------
测试一下, 这样写不出问题的话就找你窗体的问题吧
Function EDebtMoney(H: THandle):integer;
begin
Result := 0;
Application.Handle := H;
{with TForm1.Create(Application) do try
KeyPreview :=True;
ShowModal;
Result := MySelect ;
finally
Free; { 调用结束时销毁窗口 }
end;}
end;