how do i make a frame center on the form vertically and horizontally when the form is loaded?
Printable View
how do i make a frame center on the form vertically and horizontally when the form is loaded?
VB Code:
Private Sub Form_Load() Frame1.Move (Me.ScaleWidth - Frame1.Width) / 2, (Me.ScaleHeight - Frame1.Height) / 2 End Sub
with Frame1
.left = (me.width-.width)/2
.top = (me.height -.height)/2
end with
Ooops, peet may be more correct, as I forget that the scalemode is different for different controls (form vs. frame). Sorry.
ok that works, you wouldn't happen to know how to size a form to the size of the screen would you?
I just learned this today. Me.Windowstate = vbMaximized
that wasn't what i was looking for vbmom, but i figured it out...
peet's code wasn't doing much because the form wasn't sized to the size of the screen when it wasn't running. i just used:
Code:Me.Width = Screen.Width
Me.Height = Screen.Height
Don't know what you're doing, but you may be interested in using a timer to do things after the form loads.
If you place a timer on your form with an interval of 1, set Me.WindowState = vbMaximized inside Form_Load, enable the timer as the last statement in the Form_Load, and put peet's code in the Timer's Timer event, that should work.
I just needed something to make my form load as fullscreen with controls in the middle, but thanks anyway vbmom.
Place Peet's code in the resize event. This way the frame still stays centered even if you resize the form by grabbing an edge and dragging it.