Solved

Getting amount of available screencolors

Posted on 1997-09-28
2
175 Views
Last Modified: 2010-04-04
Hi,

How do I find out how many colors are available on the screen (16, 256, 16M etc.) ? I need this for an application that uses 256 color bitmaps and I don't want the program to start when less than 256 colors are available.

Michael.
0
Comment
Question by:michaelsanders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
fsanchez earned 50 total points
ID: 1346381
There are two possibilities, both using this function:

function GetDeviceCaps(
  HDC hdc,  { device-context handle }
  int nIndex { index of capability to query }
  ): Integer;

For the first parameter we can use MyForm.Canvas.Handle
For the second parameter there the following two possibilities:
1.- BITSPIXEL -> The function will return 4 for 16 colors palette, 8 for 256 colors palette, 16 for 65536 colors, 24 for 16M.
2.- NUMCOLORS -> The number of colors

For your problem I'll use:
  if GetDeviceCaps(MyForm.Canvas.Handle, BITSPIXEL) < 8
  then { Don't start }
  else { OK, start }

Good luck ;-)
0
 
LVL 1

Author Comment

by:michaelsanders
ID: 1346382
Great, Thanks !
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question