Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Centring Forms


Message #1 by "Adam Lovell" <adam@d...> on Fri, 7 Mar 2003 07:39:27 +1100
Or you can do this which will do the same thing:

frmChild.Top = (frmMDI.ScaleHeight - frmChild.Height) / 2
frmChild.Left = (frmMDI.ScaleWidth - frmChild.Width) / 2

Barbara

> The MDIChild forms' Left and Top properties are relative to the MDI =
form.
MDIChild forms weren't intended to be positioned relative to Screen.  If =
you
want to do that, you'll need to take into account the MDIForm's Left and =
Top
properties.  In pseudo code...

	Me.Left =3D ((Screen.Width / 2) - (Me.Width / 2) - MDIForm.Left)
	Me.Top =3D ((Screen.Height / 2) - (Me.Height / 2) - MDIForm.Top)

Pete

-----Original Message-----
From: Adam Lovell [mailto:adam@d...]=20
Sent: Thursday, March 06, 2003 3:39 PM
To: professional vb
Subject: [pro_vb] Centring Forms


Hi Everyone,

I am having trouble trying to centre forms. I am using the following =
code.

  me.Left =3D (Screen.Width / 2) - (me.Width / 2)
  me.Top =3D (Screen.Height / 2) - (me.Height / 2)

The problem is that it does not seem to be centring the form evening
vertically, the gap above the top of the form is greater than the gap at =
the
bottom of the form.

Does anyone have any ideas why? Is my code correct?

The environment is an MDI Form with MDI Children and the child forms are =
the
problem.

Thanks in advance

Regards
Adam



---
Change your mail options at http://p2p.wrox.com/manager.asp or=20
to unsubscribe send a blank email to 


  Return to Index