|
-
Feb 22nd, 2002, 08:51 PM
#1
Thread Starter
Member
center controls
how do i make a frame center on the form vertically and horizontally when the form is loaded?
-
Feb 22nd, 2002, 08:55 PM
#2
-= B u g S l a y e r =-
VB Code:
Private Sub Form_Load()
Frame1.Move (Me.ScaleWidth - Frame1.Width) / 2, (Me.ScaleHeight - Frame1.Height) / 2
End Sub
-
Feb 22nd, 2002, 08:56 PM
#3
Hyperactive Member
with Frame1
.left = (me.width-.width)/2
.top = (me.height -.height)/2
end with
-
Feb 22nd, 2002, 08:57 PM
#4
Hyperactive Member
Ooops, peet may be more correct, as I forget that the scalemode is different for different controls (form vs. frame). Sorry.
-
Feb 22nd, 2002, 09:04 PM
#5
Thread Starter
Member
didn't work
ok that works, you wouldn't happen to know how to size a form to the size of the screen would you?
-
Feb 22nd, 2002, 09:15 PM
#6
Hyperactive Member
I just learned this today. Me.Windowstate = vbMaximized
-
Feb 22nd, 2002, 09:19 PM
#7
Thread Starter
Member
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
-
Feb 22nd, 2002, 09:27 PM
#8
Hyperactive Member
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.
-
Feb 22nd, 2002, 09:45 PM
#9
Thread Starter
Member
I just needed something to make my form load as fullscreen with controls in the middle, but thanks anyway vbmom.
-
Feb 23rd, 2002, 12:38 AM
#10
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|