473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the display bitcount (i.e. 'colour depth')

Robbie
180 New Member
Hi again, does anybody know how to get the number of colours / colour depth which the display is set to use, in Visual Basic 6?
(i.e. 8-bit, 16-bit or 32-bit)

I know how to find out the horizontal/vertical resolution, but it's the depth I need...
Jul 1 '07 #1
4 1726
Killer42
8,435 Recognized Expert Expert
Hi again, does anybody know how to get the number of colours / colour depth which the display is set to use, in Visual Basic 6?
(i.e. 8-bit, 16-bit or 32-bit)

I know how to find out the horizontal/vertical resolution, but it's the depth I need...
Sourced from another forum...

Author: James Crowley

This piece of code shows you how to find out the colour depth of the screen using the GetDeviceCaps API.

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetDeviceCaps Lib "GDI32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
  2.  
  3. Function DeviceColors(hDC As Long) As Single
  4.     Const PLANES = 14
  5.     Const BITSPIXEL = 12
  6.     DeviceColors = 2 ^ (GetDeviceCaps(hDC, PLANES) * GetDeviceCaps(hDC, BITSPIXEL))
  7. End Function
  8.  
  9. Private Sub cmdGetColours_click()
  10.     Dim fColours As Single
  11.     fColours = DeviceColors(hDC)
  12.     If fColours = 4294967296# Then
  13.         Debug.Print "Colors: " & fColours & " - True Color (32 bit)"
  14.     ElseIf fColours = 65536# Then
  15.         Debug.Print "Colors: " & fColours & " - High Color (16 bit)"
  16.     Else
  17.         Debug.Print "Colors: " & fColours
  18.     End If
  19. End Sub


(Edited by Killer42. The original code contained bugs. I'll post it in another message, for historical interest.)
Jul 2 '07 #2
Killer42
8,435 Recognized Expert Expert
Just in case anyone is interested, here is the original code, before I edited it.

Warning: This code contains at least one serious bug (in the test code, not the actual function)
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function GetDeviceCaps Lib "GDI32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
  2.  
  3. Function DeviceColors(hDC As Long) As Single
  4.     Const PLANES = 14
  5.     Const BITSPIXEL = 12
  6.     DeviceColors = 2 ^ (GetDeviceCaps(hDC, PLANES) * GetDeviceCaps(hDC, BITSPIXEL))
  7. End Function
  8.  
  9. Private Sub cmdGetColours_click()
  10.     Dim fColours As Single
  11.     fColours = DeviceColors((hDC))
  12.     If fColours = "4.294967E+09" Then
  13.         lblColours.Caption = "Colors: " & Colours & " -True Color (32 bit)"
  14.     ElseIf fColours = "65536" Then
  15.         lblColours.Caption = "Colors: " & Colours & " - High Color (16 bit)"
  16.     Else
  17.         lblColours.Caption = "Colors: " & Colours
  18.     End If
  19. End Sub
Jul 2 '07 #3
Robbie
180 New Member
Sourced from another forum...

This piece of code shows you how to find out the colour depth of the screen using the GetDeviceCaps API.

...

(Edited by Killer42. The original code contained bugs. I'll post it in another message, for historical interest.)
Thanks very much! ^^
Works just like it should.
Jul 2 '07 #4
Killer42
8,435 Recognized Expert Expert
Thanks very much! ^^
Works just like it should.
Glad to hear it! :)

I might add this to the Articles area.
Jul 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

17
4690
by: John Hunter | last post by:
I have a largish data set (1000 observations x 100 floating point variables), and some of the of the data are missing. I want to try a variety of clustering, neural network, etc, algorithms on the data, and to keep life simple I want to reduce the dimensions of the matrix so that I have no missing values, since not all the algorithms are able to handle them and there is sufficient redundancy in the variables that I can afford to lose...
21
3990
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
3
6580
by: scoobydoo | last post by:
hi, I have a problem displaying icons at the right colour depthin a ListView. I've made an icon file, (using IconWorkshop 5), it has 3 icons within it. A 32x32 32bpp XP style icon, a 32x32 32bpp non-xp icon (no transparency), and a 16x16 version. I add these icons to an ImageList, which is then assigned to the LargeImageList property of the ListView.
0
1138
by: Paul Cheetham | last post by:
Hi, I have several Colour custom cursors embedded in my application resource. In order to load and use them I use the following function: public static Cursor LoadCursor (string CursorName) { Cursor myCursor; Stream cursorStream; Assembly thisAssembly;
26
8126
by: johkar | last post by:
I need to cancel the link and execute a function onclick of all the links within the span tag which has a class of "container" assigned. There will be only one span tag with this class applied. I know you can get a specific tag using document.getElementsByTagName('span'), but I am unsure how to get the one with the class="container". I know there is a getAttribute method, just need a pointer or two to put it all together. Once I know...
5
12875
by: Dave White | last post by:
Hello Everyone, I have not had any luck finding a tool that will: Shows me the color when I highlight a Hex color code in an HTML source document. Are there any utilities that do this? Thanks in advance,
2
2093
by: kuratkull | last post by:
Hello, I haven't asked If I wasn't really confused :) OK, so I am just beginning SDL programming in C, and I was running fine, until I tried getting a pixel colour. Basically, I am trying to run the code from this page: http://www.libsdl.org/cgi/docwiki.cgi/Pixel_20Access This is the cut down version of my code:
4
3565
by: cjstuttle | last post by:
Could anyone help me, I'm a python noob and need some help. im trying to find some code that will, given a screen co-ordinate, will give me the colour of that pixel in RGB. i have found a lot about getting the pixel colour from a picture file with a given co-ordinate, but is it possible to do it from the whole screen output regardless what application the selected pixel is in? any help would be help. thanks, Chris
21
10135
Mas Juliza Alias
by: Mas Juliza Alias | last post by:
Hi, I am building a program on Information System for Reservoir Operation for my Masters research. Now I have a text file which is an output file from a processing software (Terramodel) that lists out Elevation Range and Volume in columns and rows. The text file looks like this; ------------------------------------------------- -software's distributor address- -project description- Depth range Volume (m) ...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.