Color is an important element in the pictures and images generated by Windows applications. Windows API functions use COLORREF data struct to specify an RGB color:
typedef DWORD COLORREF; typedef DWORD *LPCOLORREF;
When specifying an explicit RGB color, the value has the following hexadecimal form:
The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.
To create a COLORREF color value, you can use the RGB macro. The RGB macro selects a red, green, blue (RGB) color based on the arguments supplied and the color capabilities of the output device.
COLORREF RGB( BYTE byRed, // red component of color BYTE byGreen, // green component of color BYTE byBlue // blue component of color );
Example codes:
{ // Directly use hex color code to create a red COLORREF color value: COLORREF t_crMyColor = 0x0000FF; HPEN CreatePen(PS_SOLID, 10,t_crMyColor ); ... } { // Use the RGB macro to create a red COLORREF color value COLORREF t_crMyColor = RGB(255,0, 0); HPEN CreatePen(PS_SOLID, 10,t_crMyColor ); ... }
ACA Color Picker supports for capturing the color value of any screen pixel and displays its value in WinAPI Color Code, you can use it on your source code based Windows API such as VC++. To apply this feature, please do following steps:
Free Trial ACA Color Picker Now | Buy ACA Color Picker Now
See Also