MDI多文档程序的问题,求教! ( 积分: 50 )

  • 主题发起人 主题发起人 zgp2000
  • 开始时间 开始时间
Z

zgp2000

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个MDI多文档含数据库程序。为避免各窗口之间数据源冲突,我想每次只打开<br>一个窗口,其它窗口禁止打开,要如何做?
 
我做了一个MDI多文档含数据库程序。为避免各窗口之间数据源冲突,我想每次只打开<br>一个窗口,其它窗口禁止打开,要如何做?
 
&nbsp;按你的要求可以这样做:<br> &nbsp;在每次要创建子窗口的时候进行判断,也就是下面的第一句<br> &nbsp;if Screen.FormCount &amp;gt; 1 then Exit;<br> &nbsp;Application.CreateForm(TForm2, Form2);<br> &nbsp;Form2.Show;
 
以下是我的一段代码,不只对你是否有用:<br>procedure TFrmMain.OpenForm(FormClass: TFormClass; var Frm);<br>var Child:TForm;<br>begin<br> &nbsp;if FrmMain.MDIChildCount &amp;gt;0 then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;if MDIChildren[0].ClassType = FormClass then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MDIChildren[0].BringToFront;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MDIChildren[0].SetFocus;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Exit;<br> &nbsp; &nbsp; &nbsp; &nbsp;end else<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Editing then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Application.MessageBox(PChar('您正在进行的 〖'<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+MDIChildren[0].Caption+'〗 '+#13+<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'将被关闭! &nbsp;所有未保存信息将会丢失!'),'警告',<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MB_OKCANCEL)=ID_OK then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MDIChildren[0].Close else<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Exit else<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MDIChildren[0].Close;<br> &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp;end;<br> &nbsp;Child := TForm(FormClass.NewInstance);<br> &nbsp;TForm(Frm):= Child;<br> &nbsp;Child.Create(Self);<br> &nbsp;with Child do<br> &nbsp;begin<br> &nbsp; &nbsp;BorderIcons := [];<br> &nbsp; &nbsp;BorderStyle := bsNone;<br> &nbsp; &nbsp;FormStyle := fsMDIChild;<br> &nbsp; &nbsp;WindowState := wsMaximized;<br> &nbsp; &nbsp;KeyPreview := True;<br> &nbsp; &nbsp;Show;<br> &nbsp;end;<br>end;
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部