Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Number of Windows Colors
Message
From
08/02/2010 07:20:46
 
 
To
08/02/2010 04:05:21
Jarid Griesel
The Innovix Technology Group (Pty) Ltd
Johannesburg, South Africa
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01448025
Message ID:
01448028
Views:
119
Hi Jarid,

>Is there a function (Win32 most likely) that can be used to return the number of colors in the current Windows Display setting, eg: 256 Colors, 64k Colors, 1.6m colors etc
>
>TIA

some years ago i found this code somewhere here in UT, however I can't remember who wrote it in the first place.
? getBitsPerPixel()

FUNCTION GetBitsPerPixel
	
	* nBitsPerPixel returns the color depth
	* 8 = 256 Color
	* 16 = High Color (64K)
	* 24 or 32 are TrueColor modes. 
	* There are other values; these are the most common ones encountered.
	
	DECLARE INTEGER GetDC IN WIN32API INTEGER hWnd
	DECLARE INTEGER GetActiveWindow IN WIN32API
	DECLARE INTEGER GetDeviceCaps IN WIN32API INTEGER hDC, INTEGER nIndex
	DECLARE INTEGER ReleaseDC IN WIN32API INTEGER hWnd, INTEGER hDC
	#DEFINE BITSPIXEL 12

	LOCAL nDC, nBitsPerPixel
	nDC = GetDC(GetActiveWindow())
	nBitsPerPixel = GetDeviceCaps(nDC, BITSPIXEL)
	=ReleaseDC(GetActiveWindow(),nDC)

	RETURN nBitsPerPixel
ENDFUNC
Best Regards
-Tom

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.

Oh, and BTW: 010101100100011001010000011110000101001001101111011000110110101101110011
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform