Search code examples
vb6mdiparent

Centre a form in VB6


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


Solution

  • 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.