VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Center a child form within a parent form

by Dan Burby (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This function centers a child form within a parent form (not MDI), and can be used for custom messageboxes etc... Please try and leave a comment - Dan

Rate Center a child form within a parent form

Public Function CenterChild(Parent As Form, Child As Form)
On Local Error Resume Next
If Parent.WindowState = 1 Then
Exit Function
Else
Child.Left = (Parent.Left + (Parent.Width / 2)) - (Child.Width / 2)
Child.Top = (Parent.Top + (Parent.Height / 2)) - (Child.Height / 2)
End If
End Function

Download this snippet    Add to My Saved Code

Center a child form within a parent form Comments

No comments have been posted about Center a child form within a parent form. Why not be the first to post a comment about Center a child form within a parent form.

Post your comment

Subject:
Message:
0/1000 characters