Solved

Find the current screen res/color depth in VB5?

Posted on 1998-09-15
3
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

623 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