Solved

Find the current screen res/color depth in VB5?

Posted on 1998-09-15
3
265 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now