如何使的MDI子窗体在MDI主窗体的正中间 (50分)

  • 主题发起人 主题发起人 odbc1230
  • 开始时间 开始时间
O

odbc1230

Unregistered / Unconfirmed
GUEST, unregistred user!
如何使的MDI子窗体在MDI主窗体的正中间,就是在出去工具栏大小后MDI主窗体的那块深
灰色的区域,让MDI子窗体在这个区域居中
 
Here is the formular: (It has been tested by using D5, D6 under both Win9X and WinNT(2000,XP)), Good luck and enjoy it.
...
impkmentatuon
uses Main; //Main is the unit of your MDI main window
...

procedure TfrmMDIChild.FormCreate(Sender : TObject);
begin
//frmMain is the MDI Main window
Left := (frmMain.ClientWidth-Width) div 2;
//if you have StatusBar in your MDI Main window, otherwise, take out 'frmMain.StatusBar.Height'
Top := (frmMain.ClientHeight-frmMain.StatusBar.Height-Height) div 2 - (frmMain.Height-frmMain.ClientHeight);
end;
 
set

mdichildform 的 position = poMainFormCenter
 
如果是用楼上两位的方法,应该是置中在MDIform的空白区的中间,如果用要放在屏幕中间
可以在mdichildform的show事件中写.
with mdichildformname do
begin
left:=(screen.width-width) div 2;
top:=(screen.height-height) div 2;
end;
 
多人接受答案了。
 
后退
顶部