Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting amount of available screencolors

Posted on 1997-09-28
2
Medium Priority
?
179 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 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: 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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

719 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