CodeItBetter Programming Another VB Programming Blog

How to Center the form relative to MDI form

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
'Forms - How to Center the form relative to MDI form
Option Explicit
 
Public Sub CenterForm(frm As Form, frmMDI As MDIForm)
    ' If frm is an MDI child in a MDI parent then center frm within the parent.
    If frm.MDIChild And Not frmMDI.MDIChild Then
        frm.Move ((frmMDI.Width - frm.Width) / 2), ((frmMDI.Height - frm.Height) / 2)
    Else
        frm.Move ((frmMDI.Width - frm.Width) / 2) + frmMDI.Left, ((frmMDI.Height - frm.Height) / 2) + frmMDI.Top
    End If
End Sub
Filed under: Forms Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.