Find the current screen res/color depth in VB5?

How do I obtain the current screen resolution & color depth in VB5?  Is the method the same for Win95/98/NT?

Thanks,

Karsten Wilson
karsten@behsoftware.com
sungarAsked:
Who is Participating?
 
MirkwoodConnect With a Mentor Commented:
Screen resolution can be found on the global screen object
screen.width = width of screen in the number of pixels
screen.height = height of screen in the number of pixels

Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long


The number of bits used for the color is returned by the function below.

Const colorres = 108
Private Function GetColorDepth() as Integer
    Dim hdc As Long
    hdc = GetWindowDC(0)
    getcolordepth = GetDeviceCaps(hdc, colorres)
    ReleaseDC 0, hdc
End Function


0
 
MirkwoodCommented:
Oeps, you have to divide screen.width / screen.twipsperpixelX to get the unit in pixels and screen.height / screen.twipsperpixelY
0
 
sungarAuthor Commented:
Thanks!

Karsten
0
All Courses

From novice to tech pro — start learning today.