Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Screen Resolution (VB6)

    Hello all !!

    With the following code, used to load a form dependant on screen resolution.
    A couple of our users have had 17" TFT monitors which run at something like 1105? x ??? instead of 800x600 and 1024 etc.
    The code obviously won't load the form unless the resolution is anything other than declared.
    To combat this, I have changed the "If" statements to "Case" statements.
    The code works ok, but before final compilation, would someone kindly look over it and confirm it will not cause any future problems.

    <pre>Private Sub cmdImage_Click()
    Select Case Screen.Width
    Case 800 * Screen.TwipsPerPixelX
    Form800Image.Show
    Case 1024 * Screen.TwipsPerPixelX
    Form1024Image.Show
    Case Else
    Form1024Image.Show
    End Select


    'If (800 * Screen.TwipsPerPixelX) = Screen.Width And (600 * Screen.TwipsPerPixelY) = _
    'Screen.Height Then Form800Image.Show
    'If (1024 * Screen.TwipsPerPixelX) = Screen.Width And (768 * Screen.TwipsPerPixelY) = _
    'Screen.Height Then Form1024Image.Show
    'If Screen.Width <> 1024 And Screen.Width <> 800 Then Form1024Image.Show
    Me.Hide
    End Sub</pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Screen Resolution (VB6)

    Hi Dave,

    Still finding time to program? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    The code is OK, but since you have two form sizes, you can shorten the code to

    Private Sub cmdImage_Click()
    Select Case Screen.Width
    Case 800 * Screen.TwipsPerPixelX
    Form800Image.Show
    Case Else
    Form1024Image.Show
    End Select
    End Sub

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Screen Resolution (VB6)

    Hans
    Thanks for the help, I had realised the solution after my post, but hey !! Great Minds ??

    Yes it's difficult these days to get on-line, or even to do any programming.

    Thanks again

Posting Permissions

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