Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Getting amount of available screencolors

Posted on 1997-09-28
2
Medium Priority
?
181 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
2 Comments
 
LVL 1

Accepted Solution

by:
fsanchez earned 200 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

783 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