Centre a form in VB6

Shaun picture Shaun · Feb 16, 2010 · Viewed 9.3k times · Source

I am writing a programme to be used internaly within our company and have come across the problem below:

How can you get a Child form to centre on the screen when using the MDI parent maximised form as the backgroung

Answer

George Mastros picture George Mastros · Feb 16, 2010

In the MDI child screen, create a Form_Initialize function like this:

Private Sub Form_Initialize()

    Me.Left = (MDIForm1.ScaleWidth - Me.Width) / 2
    Me.Top = (MDIForm1.ScaleHeight - Me.Height) / 2

End Sub

Of course, you'll need to substitute the name of your MDI form where you see MDIForm1 in the code above.