我在DLL中的代码是
procedure basy_show(ParentApplication: HWND; ParentForm: TForm);export; stdcall;begin
 Application.Handle:=ParentApplication;
 BaForm:=Tbaform.Create(application.MainForm);
 BaForm.Parent:=ParentForm;
 BaForm.Show;
end;调用方式是:procedure TMenuForm.RzToolbarButton1Click(Sender: TObject);
begin
  basy_show(application.Handle,self);
end;目前现象是,一执行调用操作,子窗口快速显示一下就自动消失了,但是还是驻留在内存中,退出程序时报错想尽办法解决不了,在这里求援了

解决方案 »

  1.   

    直接Show没有问题,可是我希望是子窗口打开后,点击父窗口其它位置,子窗口不会被置于父窗口之后也就是允许在父窗口中同时显示多个子窗口。
      

  2.   

    主程序调用函数:
    procedure TFmMain.LoadDllForm(FileName: String);
    begin
      LibHandle := LoadLibrary(Pchar(FileName));
      if LibHandle = 0 then
        raise Exception.Create('模块装载失败,模块名:' + FileName);
      @ShowChild := GetProcAddress(LibHandle, 'ShowChild');
      if @ShowChild <> nil then
      begin
        ShowChild(@Application);
      end
      else
        raise Exception.Create('入口函数出错!');
    end;
    Dll程序输出函数:
    procedure ShowChild(pMainApp:Pointer);stdcall;
    var
      pForm:^TForm;
    begin         
      Application.Handle:=TApplication(Pointer(pMainApp^)).Handle;
      pForm:[email protected];
      pForm^:= TApplication(Pointer(pMainApp^)).MainForm;  proc := TProc.Create;   //创建业务对象  将在FmMain.destroy 中释放);  
       fmMain:=TfmMain.Create(nil);
       //*******************************
        fmMain.FormStyle := fsMDIChild;
        fmMain.WindowState := wsMaximized;//保证主窗体以最大化方法显示
       //*******************************
       fmMain.show;  
    end;
    procedure DLLUnloadProc(Reason: Integer); register;
    begin
      if Reason = 0 then
      begin
        Application.CancelHint;
        application.Handle := 0;
        if Assigned(fmMain) then FreeAndNil(fmMain);
      end;
    end;exports
      ShowChild;begin
      DllProc := @DLLUnloadProc;
    end.不过你要自己考虑将来的每个模块的释放,最好在主程序中有个维护模块加载状态的List,程序退出时,全部释放。
      

  3.   

    麻烦解释一下:
    proc := TProc.Create;   //创建业务对象  将在FmMain.destroy 中释放);  
    中的proc和TProc.Create是从何而来,
      

  4.   

    欢迎加入Borland DELPHI程序员,参与群里技术讨论!欢迎女孩子,也欢迎男孩子参与技术讨论!群号15154361
      

  5.   

    自己顶一下.......求助,Help.......
      

  6.   

    proc := TProc.Create;   //创建业务对象  将在FmMain.destroy 中释放);  
    这是我从我们的系统中摘出来的代码,这是个业务类,没去掉。
    以为你能看出来,呵呵