VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Determine the number of colors a computer can display

by Anonymous (267 Submissions)
Category: Windows System Services
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 2nd February 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Determine the number of colors a computer can display

API Declarations


Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Const PHYSICALOFFSETX = 112
Private Const PHYSICALOFFSETY = 113
Private Const PLANES = 14
Private Const BITSPIXEL = 12

Rate Determine the number of colors a computer can display



Public Function GetNColors() As Long
  Dim hSrcDC As Integer

  hSrcDC = GetDC(GetDesktopWindow())
  GetNColors = GetDeviceCaps(hSrcDC, PLANES) * 2 ^ GetDeviceCaps(hSrcDC, BITSPIXEL)
  Call ReleaseDC(GetDesktopWindow(), hSrcDC)
End Function

Download this snippet    Add to My Saved Code

Determine the number of colors a computer can display Comments

No comments have been posted about Determine the number of colors a computer can display. Why not be the first to post a comment about Determine the number of colors a computer can display.

Post your comment

Subject:
Message:
0/1000 characters