在DLL中的MDI窗口的问题
MainForm1:TForm1为主表单
MDI表单中从DLL中导出的,在MDI表单中有一状态栏StatusBar1
MDI窗口中使用StatusBar1.Parent:=MainForm1主表单状态栏会不正确。
如果MDI表单与MainForm1在同一个Application中则状态栏会正确显示,这是为什么?

解决方案 »

  1.   

    你要将Application对象传入dll才行
      

  2.   

    有将Application对象传入DLL,要不关闭DLL的时候会报错
      

  3.   

    Library ShowFrmdll;
    uses
      ...
      Unit1 in 'Unit1.pas' {Form1};var
      DLLApp: TApplication;function ShowDllForm(App:TApplication; ACaption:String):Longint;stdcall;
    begin
      
      Application := App;  if not Assigned(Form1) then
        Form1:=TForm1.Create(Application);
      Result:=Longint(Form1);
      Form1.Caption := ACaption;
      Form1.Show;
    end;procedure DLLUnloadProc(Reason : Integer);
    begin
      if Reason = DLL_PROCESS_DETACH then Application := DLLApp;//恢复
    end;exports
      ShowDllForm;begin
      DLLApp := Application; //保存 DLL 中初始的 Application 对象
      DLLProc := @DLLUnloadProc;     //保证 DLL 卸载时恢复原来的 Application
    end.要注意的是,创建的窗体被释放后再卸载 DLLhttp://expert.csdn.net/Expert/topic/1974/1974304.xml?temp=.9995996http://expert.csdn.net/Expert/topic/1962/1962766.xml?temp=.2309839
      

  4.   

    看看我的贴子吧
    http://expert.csdn.net/Expert/topic/2094/2094919.xml?temp=.1091272