问题一:
如何让子窗口在打开时,自动充满主窗口,不是最大化?
如何让子窗口居中?问题二:
在关闭主窗口时,若主窗口中有子窗口未关闭,弹出提示对话框,这应该怎么做?谢谢

解决方案 »

  1.   

    不用设置成MDI的窗体。
    form2在form1里面,把form2的borderstyle设置bsnone,再把align设置为alient;即可
    procedure TForm1.a1Click(Sender: TObject);
    begin
      form2:=Tform2.Create(Panel1);
      form2.Parent:=Panel1;
      form2.Show;
    end;
      

  2.   

    procedure TForm2.Button1Click(Sender: TObject);
    begin
       close;
    end;procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      if messagedlg('您确定关闭吗吗?',mtinformation,[mbyes,mbno],0)=mryes then
      action:=cafree;
    end;
      

  3.   

    忘了,在form1上放一个panel :)
      

  4.   

    若为MID窗口,应该怎么让子窗口打开时充满整个主窗口呢?
      

  5.   

    Answer1:
      设定子窗体的windowstate:=wsMaximized;或者子窗体.top:=值;left:=;...来手动设定;
     postion:=poMainFormCenter就是置于中央位置;
    Answer2:
       在子窗体.onclose事件中写messagebox();就可以了!
      

  6.   

    1、align:=alClient;2、if Screen.FormCount>0 then   showmessage('还有未关闭子窗体');
      

  7.   

    sorry!2、if Screen.FormCount>1 then  //not >0   showmessage('还有未关闭子窗体');
      

  8.   

    你把2、if Screen.FormCount>1 then  //not >0   showmessage('还有未关闭子窗体');放在主窗体的OnCloseQuery中不就行了吗:)
      

  9.   

    好了,搞定,原来还有窗口是隐藏的,请问screen是什么东西啊,谢谢
      

  10.   

    设置:菜单:Project->Options->Forms:把你的子窗体从 Auto Create-forms 转移到 Available forms如果还是不行,你使用这个函数打开你的子窗体:procedure OpenForm(FormClass: TFormClass; var fm; AOwner:TComponent);
    var
      i: integer;
      Child:TForm;
    begin
      for i := 0 to Screen.FormCount -1 do
          if Screen.Forms[i].ClassType=FormClass then
          begin
            Child:=Screen.Forms[i];
            if Child.WindowState=wsMinimized then
               ShowWindow(Child.handle,SW_SHOWNORMAL)
            else
               ShowWindow(Child.handle,SW_SHOWNA);
            if (not Child.Visible) then Child.Visible:=True;
            Child.BringToFront;
            Child.Setfocus;
            TForm(fm):=Child;
            exit;
          end;
      Child:=TForm(FormClass.NewInstance);
      TForm(fm):=Child;
      Child.Create(AOwner);
    end;用法:OpenForm(TfrmChild1,frmChild1, self);如果再不行,没办法了!!!