Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.07 KB

sample_044.md

File metadata and controls

49 lines (34 loc) · 1.07 KB

Home

Using GetNearestColor

Code:

DO decl

	* defining a device context for the VFP Main window
	hWnd = GetActiveWindow ()
	hDc = GetDC (hWnd)
	
	crColor = RGB (16, 108, 231)
	matchColor = GetNearestColor (hDc, crColor)
	? LTRIM(STR(crColor)) + " transformed to " + LTRIM(STR(matchColor))

	= ReleaseDC (hwnd, hdc)

PROCEDURE  decl
    DECLARE INTEGER GetDC IN user32 INTEGER hwnd
    DECLARE INTEGER GetActiveWindow IN user32

	DECLARE INTEGER ReleaseDC IN user32;
		INTEGER hwnd, INTEGER hdc

    DECLARE INTEGER GetNearestColor IN gdi32;
		INTEGER hdc,;
		INTEGER crColor  

Listed functions:

GetActiveWindow
GetDC
GetNearestColor
ReleaseDC

Comment:

I ran this code with two color resolutions.

With 32-bit True Color the result was:
15166480 to 15166480

With 256 colors it was:
15166480 to 8421376