
center a child form in a MDI
The Move method is probably better because it means you only need to make
one call. This is the procedure we use:
' Centre one form relative to another.
Public Sub CentreForm(objMainForm As Form, objChildForm As Form)
Dim sngNewX As Single
Dim sngNewY As Single
Dim sngMainFormX As Single
Dim sngMainFormY As Single
On Error Resume Next
If Not objChildForm.MDIChild Then
sngMainFormX = objMainForm.ScaleLeft
sngMainFormY = objMainForm.ScaleTop
End If
sngNewX = (objMainForm.ScaleWidth - objChildForm.Width) / 2 +
sngMainFormX
sngNewY = (objMainForm.ScaleHeight - objChildForm.Height) / 2 +
sngMainFormY
If sngNewX < 0 Then sngNewX = 0
If sngNewY < 0 Then sngNewY = 0
objChildForm.Move sngNewX, sngNewY
End Sub
Quote:
> In Form_Load size the window with the Move method or the Top, Left, Width
> and Height properties.
> > Could someone tell me how to centre a child form in a MDI? Im sure there
> is
> > a simple answer to this??
> > Thanx!!
> > J