Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > Graphics Games Programming sample source codes
Getting the Colour Depth
Getting the Colour Depth 'API Declarations Declare Function GetDesktopWindow Lib "User32" () As Long Declare Function GetDC Lib "User32" _ (ByVal hWnd As Long) As Long Declare Function ReleaseDC Lib "User32" _ (ByVal hWnd As Long, ByVal hDC As Long) As Long Declare Function GetDeviceCaps Lib "GDI32" _ (ByVal hDC As Long, ByVal nIndex As Long) As Long 'Choose this version for use in a .BAS Module. Public Function GetColours() As Long 'Define some Constants we will use. Const PLANES = 14 Const BITSPIXEL = 12 'We use the hDC of the Desktop Window. hDC = GetDC(GetDesktopWindow()) 'Calculate the colour depth. GetColours = 2 ^ (GetDeviceCaps(hDC, PLANES) * _ GetDeviceCaps(hDC, BITSPIXEL)) 'Clear up. ReleaseDC GetDesktopWindow(), hDC End Function
Privacy Policy
|
Link to Us
|
Links