首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

请教,为什么调用DLL然后关闭, 主程序会自动置后

2013-03-14 
请问,为什么调用DLL然后关闭, 主程序会自动置后。DLL点关闭的时候,主程序就自动置后了,不知为什么。代码如下

请问,为什么调用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;

热点排行