Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
16 colors - 256 colors - how to determine?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00109377
Message ID:
00109443
Vues:
38
>I am wanting to put a background on a form having 256 colors. On a machine supporting 16 colors it looks terrible, so I want to change it to a simple rgb() color.
>
>Is there a way to determine how many colors the current windows video mode is capable of displaying? A function or api call? If so could someone help?
>
>Thanks in advance.
>
>Robert
Hi Robert,

You have to use the API. Here's a function that will do it:
FUNCTION NumColors

DECLARE INTEGER GetDC IN Win32API;
  INTEGER hWnd
DECLARE INTEGER GetDeviceCaps IN Win32API;
  INTEGER hDC, INTEGER nIndex
DECLARE INTEGER ReleaseDC IN Win32API;
  INTEGER hWnd, INTEGER hDC
LOCAL lnresult, lnhDC, lnplanes, lnpixels
lnresult = 0
lnhDC = GetDC(0)
IF lnhDC > 0
  lnplanes = GetDeviceCaps(lnhDC, 14) && 14 is the number of planes
  lnpixels = GetDeviceCaps(lnhDC, 12) && 12 is the bits per pixel
  lnresult = 2 ^ (lnplanes * lnpixels)
  = ReleaseDC(0, lnhDC)
ENDIF
RETURN lnresult
hth,
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform