473,473 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to: Determine number of colours

8,435 Recognized Expert Expert
This simple function may be called to determine the colour "depth" of the display, 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.  
To use this function, just pass it the hDC of your current form.
Some typical values returned...
4,294,967,296 = "True Color" (32 bit)
65,536 = "High Color" (16 bit)
Jul 2 '07 #1
0 3550

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

Similar topics

3
by: tjh | last post by:
hi - i'm a bit new to PHP - i've been messing around with the GD2 image functions and was wondering: i see a lot of information about converting a color image to grayscale but i can't figure...
4
by: Els | last post by:
Hi, I would like an opinion on the following: I have a page which is made up of background-images with transparent linked images in front of it, which on hover show text in CSS popups. Due to...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
8
by: Doug Laidlaw | last post by:
I tried to grab an image from a Web page the other day. It turned out that the page was made up of three horizontal bands, and part of the image was in each. One band was a JPEG, another was a...
6
by: MLH | last post by:
I have a command button with black letters on it. The default value in A97's forecolor property for that button is -2147483630. I didn't choose the color. That was the default when I created the...
7
by: Big Dave | last post by:
I'm going insane!!!!! I set a font color using documentDOTexecuteCommand("ForeColor"). That works, but now I'm trying to read the color in another method. I used...
6
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future,...
0
MetalMartian
by: MetalMartian | last post by:
I'm trying to write code for a game based on the original Pacman in Visual Basic .NET 2003, however I can't figure out how to make the character move around the screen and not go through the walls....
5
by: Jameson | last post by:
Hi, I have a list of known colours, generated using: Dim colorNames As New System.Collections.Generic.List(Of String) For Each known As KnownColor In .GetValues(GetType(KnownColor)) Dim...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.