MDI的问题exe是fsMDIForm
dll是fsMDIChild
exe静态调用dll创建窗体
麻烦问下为什么exe的 MDIChildCount值为0的说
我看了下MDIChildCount是获取Screen的数量,
难道调用dll创建的不属于Application.MainForm的MDIChild吗?
怎样才可以让调用dll创建出来的Form属于exe的MDIChild?
下面是dll的代码
library dllForm;uses
  SysUtils,
  Classes,
  Forms,
  Windows,
  test_Form in 'test_Form.pas' {testForm};{$R *.res}var
  DLLApp: TApplication;procedure ShowChild(ParentApplication:TApplication;ParentForm:TForm);stdcall;
begin
  Application:=ParentApplication;
  testForm:=TtestForm.Create(ParentForm);
  testForm.Show;
end;procedure DLLUnloadProc(Reason:Integer);register;
begin
  if Reason=DLL_PROCESS_DETACH then Application:=DLLApp;
end;exports
  ShowChild;begin
  DLLApp:=Application;
  DLLProc := @DLLUnloadProc;
end.MDIEXEdllWindowsDelphi

解决方案 »

  1.   

    testForm:=TtestForm.Create(ParentForm);//这句后边加
    testform.parent := parentform; 
      

  2.   

    完全不行哦,这样的话仅仅是设置testform的父控件,testForm还是不在Screen里的
    exe的MDIChildCount任然为0
      

  3.   

    我看网上查了下发现有人把testForm.handle传回exe不知道起什么作用
        formHWND2^:=form1.handle;   //获取HANDLE返回到EXE
      

  4.   

      Application.Handle 要传给dll
      

  5.   

    = =!~好吧我无语了,昨天调试的时候发现screen数据不一致,今天调试了下把exe的screen的值转给dll发现同步了.OK到这里应该是属于正常了是吧.
    但是……但是  问题出到这个但是上了
    我脑抽了下试着又把screen取消掉在次试了下.发现居然exe的MDIChildCount值居然和dll的一致 exe自行创建的ChildForm和dll创建的ChildForm居然任然都正常,exe和dll的Screen两个值居然还是同步的.
    不死心有重建了个工程拿来测试结果仍然正常,嘛嘛这什么和什么啊.害我纠结了2天
      

  6.   

    用dll 方式就是担心这种情况
    用bpl方式比较稳定安全,但是编译发布不方便
      

  7.   

    哎 ,突然发现这个还没解贴.
    经过各种测试最后结论,如果要dll和exe的screen 同步
    只能在dll写入exe的screen.