Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleGet the system's color depth and screen size in pixels
Keywordscolor depth, pits per pixel, screen size
CategoriesGraphics
 
To get screen size, use:

  • width in pixels = Screen.Width / Screen.TwipsPerPixelX
  • height in pixels = Screen.Height / Screen.TwipsPerPixelY

To get the color depth, use GetObject to initialize a BITMAP structure. Then look at its bmBitsPixel field.

 
Private Sub Form_Load()
Dim bm As BITMAP

    AutoRedraw = True
    GetObject Image, Len(bm), bm

    MsgBox "The screen is " & _
        Format$(Screen.Width / Screen.TwipsPerPixelX) & _
        " pixels by " & _
        Format$(Screen.Height / Screen.TwipsPerPixelY) & _
        " pixels, using " & _
        Format$(bm.bmBitsPixel) & _
        " bits per pixel"

    Unload Me
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated