Results 1 to 9 of 9

Thread: form size vs. screen resolution

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    Chicago
    Posts
    11

    form size vs. screen resolution

    how do you determine form size (height and width) based on selected system screen resolution?

    example: if monitor resolution is set for 800x600 what would be the form size (height and width) if i wanted the form to be same size as screen?

    what is the relation of the height and width indicated in VB6 to the screen resolution?

  2. #2
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    VB Code:
    1. Form1.Width = Screen.Width
    2.     Form1.Height = Screen.Height

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    VB Code:
    1. Private Sub Form_Load()
    2.     Hide
    3.     ScaleMode = 3: Left = 0
    4.     Width = Screen.Width: Height = Screen.Height:
    5.     Show
    6. End Sub
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    along these lines... let's say I have a few controls I want to center on the screen depending on the resolution.

    I've tried:

    VB Code:
    1. txtbox.Top = Screen.Width/2
    2. txtbox.Left = Screen.Height/2

    But this doesn't work. Help!?
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  5. #5
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Hmmm well you'd want to use Me.Width instead of Screen.Width, make sure ScaleMode = 3, and also, to center, you have to subtract half the width/height of the object from the left/top position too
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    why would it matter whether I use Me or Screen, since they should be the same thing?
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  7. #7
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    txtbox.left = (me.scalewidth - txtbox.width)/2
    txtbox.top = (me.scaleheight - txtbox.height)/2

  8. #8
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Me refers to the current Form, whereas Screen refers to the screen.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  9. #9
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    alright... thanks guys.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

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