Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

positioning MDI child forms 1

Status
Not open for further replies.

GrahamUNC

Programmer
Mar 30, 2001
14
0
0
US
I would like all my MDI child forms to come up in the absolute center of my MDI parent form. It seemed logical to me to change the StartUpPosition property of the MDI child form to 1 - CenterOwner but I get an "Invalid Property Value" error with that. Any help would be greatly appreciate. Thanks.
 
Sub Center(frmMe As Form)
Dim iLeft As Integer
Dim iTop As Integer
iTop = ((MDIFORM.Height - frmMe.Height) / 2)
iLeft = ((MDIFORM.Width - frmMe.Width) / 2)
frmMe.Left = iLeft
frmMe.Top = iTop
End Sub
 
I understand what the code does but don't know exactly where to put it. Where should I place it so I can call it whenever a new form is loaded? I'm eventually going to have to call each time after a resize as well, correct?
 
Make it a public routine in a module. When you load/show/resize a child form simply code:
Center Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top