Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
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-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated