Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

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
0
sungar
Asked:
sungar
  • 2
1 Solution
 
MirkwoodCommented:
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now