VC wrote a color selection box, imitation Office style with VC wrote a color marquee, imitation office style, no MFC what the framework, call very simple to specify the display position point and the default color, such as:
POINT pt;
pt.x = 100; pt.y = 100;
CColorPicker *clrpk = new CColorPicker(&pt, HexClr(0xFF0000));
Effect Chart:
Color Pickup box for C + +
Code:
ColorPicker.h
#define HEXCLR (RGB) ((DWORD) (rgb>>16) | ( RGB&0XFF00) | ((RGB&0XFF) <<16))
#define COLORPICKERWINNAME "Colorpickerwin"
#define Wm_colorselected wm_user+2938
Static DWORD colormap[5][8] =
{
{HEXCLR (0x000000), HEXCLR (0x993300), HEXCLR (0x333300), HEXCLR (0x003300), HEXCLR (0x003366), HEXCLR (0x000080), HEXCLR ( 0x333399), HEXCLR (0x333333)},
{HEXCLR (0x800000), HEXCLR (0xff6600), HEXCLR (0x808000), HEXCLR (0x008000), HEXCLR (0x008080), HEXCLR (0X0000FF), HEXCLR ( 0x666699), HEXCLR (0x808080)},
{HEXCLR (0xff0000), HEXCLR (0xff9900), HEXCLR (0X99CC00), HEXCLR (0x008080), HEXCLR (0X33CCCC), HEXCLR (0x3366FF), HEXCLR ( 0x800080), HEXCLR (0x999999)},
{HEXCLR (0XFF00FF), HEXCLR (0XFFCC00), HEXCLR (0XFFFF00), HEXCLR (0X00FF00), HEXCLR (0X00FFFF), HEXCLR (0x00CCFF), HEXCLR ( 0x993366), HEXCLR (0XC0C0C0)},
{HEXCLR (0xff99cc), HEXCLR (0xffcc99), HEXCLR (0xffff99), HEXCLR (0xCCFFCC), HEXCLR (0xCCFFFF), HEXCLR (0X99CCFF), HEXCLR ( 0XCC99FF), HEXCLR (0xFFFFFF)}
};
Class Ccolorpicker
{
Public
HINSTANCE m_hinstance; Debug
Ccolorpicker (Point *pt, DWORD defaultcolor);
~ccolorpicker ();
HWND GetHwnd ();
DWORD GetColor ();
void OnPaint ();
void OnLButtonDown (long x, long y);
void OnLButtonUp (long x, long y);
void OnMouseMove (long x, long y);
Private
HWND m_hwnd;
DWORD M_color;
byte M_hotrow, M_hotcol;
BOOL M_bcustomcolor;
BOOL M_bmousedown;
void Createcolorpicker (point *pt);
void Draw (HDC HDC, byte row, byte col, bool hot, byte correction);
void Redraw (byte row, byte col, bool hot);
};