C + + implementation of the color marquee code for the faux office style

Source: Internet
Author: User
Tags bool

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&AMP;0XFF00) | ((RGB&AMP;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);
};

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.