Solved

Getting amount of available screencolors

Posted on 1997-09-28
2
163 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 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now