Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Screen color resolution
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00106531
Message ID:
00106672
Views:
31
>Is there a fonction that determines the number of color the user has on his desktop? That way, I would use the best Wallpaper bitmap possible based on the resolution. (16, 256 or 65000 colors).
>
>Thanks
Mario,

Here's pure FoxPro code to determine the number of colors.
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
ENDFUNC
hth,
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform