那时因为程序执行到showmessage(inttostr(MDIChildCount));
的时候,mdi窗口还没有关闭.不信你等一秒钟之后再showmessage(inttostr(MDIChildCount));
就可以了

解决方案 »

  1.   

    我Sleep(20000)都没用。
    很奇怪的是,在showmessage,或是弹出一个别的对话框之后
    MDIChildCount变成0了
      

  2.   

    if form1.MDIChildCount=0 then showmessage('都关闭了');
      

  3.   

    如下这样就可以了:
       for I := MDIChildCount-1 downto 0 do
        begin
            MDIChildren[I].Close;
            MDIChildren[I].Release ;
            Application.ProcessMessages;  //
        end ;
        showmessage(inttostr(MDIChildCount));
      

  4.   

    for I := MDIChildCount-1 downto 0 do
        begin
            MDIChildren[I].action:=cafree;
            Application.ProcessMessages;  //
        end ;
        showmessage(inttostr(MDIChildCount));