Solved

Find the current screen res/color depth in VB5?

Posted on 1998-09-15
3
268 Views
Last Modified: 2010-04-30
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
Comment
Question by:sungar
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 20 total points
ID: 1434966
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
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1434967
Oeps, you have to divide screen.width / screen.twipsperpixelX to get the unit in pixels and screen.height / screen.twipsperpixelY
0
 

Author Comment

by:sungar
ID: 1434968
Thanks!

Karsten
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question