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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDI Forms

Status
Not open for further replies.

Archangelpr

Programmer
Mar 17, 2003
3
US
Hi. Is there any way I can make an MDI Child Form be centralized on my MDI Parent Form? I noticed that my startup position property only allows for manual positioning. Is it only possible by code? I would appreciate any help.

Thanks.
 
No, I would suggest that you look in the MDI Childs properties.

 
You need to do it in code.

Create a function like so

Public Sub CenterForm(frm As Form)
frm.Left = (frmMDIMain.Width - frm.Width) / 2
frm.Top = (frmMDIMain.Height - frm.Height - 1000) / 2
End Sub

change frmMDIMain to the name of your MDI form.

Then on the form load of your child forms, just put

CenterForm me


Transcend
[gorgeous]
 
Oh yeah, you could just use

Public Sub CenterForm(frm As Form)
frm.Left = (frmMDIMain.Width - frm.Width) / 2
frm.Top = (frmMDIMain.Height - frm.Height) / 2
End Sub

I can't remember why i had - 1000 in there ... possibly because my MDI form had a toolbar and a menu or some strange reason .. probably could have used toolbar.height or something similar. Anyhoo this should help.

Transcend
[gorgeous]
 
Thanks to both of you for the help. But specially to Transcend. Your code worked perfectly.

Gracias.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top