Results 1 to 6 of 6

Thread: Make form center on screen? [RESOLVED]

  1. #1

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Make form center on screen? [RESOLVED]

    And i dont mean when it starts up.

    VB Code:
    1. Private Sub mnuViewFileEditorMode_Click()
    2. 'Size window according to users preference
    3.     If mnuViewFileEditorMode.Checked = True Then
    4.         mnuViewFileEditorMode.Checked = False
    5.         Me.Width = 5730
    6.     ElseIf mnuViewFileEditorMode.Checked = False Then
    7.         mnuViewFileEditorMode.Checked = True
    8.         Me.Width = 11520
    9.     End If
    10. End Sub

    This sizes my form when the menu is clicked, the problem is, sometimes my form is left right at the far left off the screen.

    Is there any way to make it go to the center?

    Thanks
    Last edited by Madboy; Mar 11th, 2004 at 09:52 AM.

  2. #2
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    Try this...

    VB Code:
    1. Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2

  3. #3

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Gr8 M8

    But, i only want it centering for when the form is made small. If it isnt then just position as it does normally when my form first starts up:

    VB Code:
    1. Private Sub mnuViewFileEditorMode_Click()
    2. 'Size window according to users preference
    3.     If mnuViewFileEditorMode.Checked = True Then
    4.         mnuViewFileEditorMode.Checked = False
    5.         Me.Width = 5730
    6.         Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
    7.     ElseIf mnuViewFileEditorMode.Checked = False Then
    8.         mnuViewFileEditorMode.Checked = True
    9.         Me.Width = 11520
    10.     End If
    11. End Sub


  4. #4

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    DOH! fixed, needed to add the code again under Elseif

    Thanks mate

  5. #5
    Lively Member
    Join Date
    Jun 2010
    Posts
    68

    Re: Make form center on screen? [RESOLVED]

    Quote Originally Posted by demotivater View Post
    Try this...

    VB Code:
    1. Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
    thanks bro

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Make form center on screen? [RESOLVED]

    Please don't bump old threads (like this one that has been dead for almost 7 years). If you want to show appreciation to someone that help, you can use the rating system, next to every post on the left beneath user info there is a "Rate this post" link which you can use to thank someone and add points to their reputation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width