Power Color Picker

Features :

This new control derived from CWnd provides an interface for users to select colors for an object. It is more intuitive than CColorDialog in windows API.

Interface description :

  • right rectangle : luminance.
  • left rectangle : saturation on x axis, hue on y axis.
  • bottom rectangle : currently selected color.

This control is fully resizable on the fly. You could specify a size for each rectangle.
When you move the cursor with shift or ctrl, the color change only on one axis (hue or saturation)


How to use it in a dialog :

  • a member variable must be added to the dialog :

    PowerColorPicker picker;

  • create the picker in the method OnInitDialog() of your dialog :

//specify the control size
RECT rect={10,10,390,300}; 
//create control in OnInitDialog()
 picker.Create(NULL,"Haha",WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS ,rect,this, NULL, NULL);

  • define a callback when the user click/move on picker :
    //define a callback 
    void testfunc(COLORREF ref,void *ClientData)
    	CColorPickerDlg * local= (CColorPickerDlg*)ClientData;
    	char str[256];
    	sprintf(str,"RED: %ld\nGREEN: %ld\nBLUE: %ld",GetRValue(ref),GetGValue(ref),GetBValue(ref));
    //register callbacks in OnInitDialog()
  • you could define the width of the luminance bar anywhere in your source :


Download Source Code - 31 Kb
Download Demo Application - 9 Kb


  • Excellent

    Posted by Ajay Vijay on 11/20/2004 06:04am


  • Typo and fix for memory leaks...

    Posted by Legacy on 12/29/2000 12:00am

    Originally posted by: Chetan

    First, the typo :

    In PowerColorPicker.cpp, currently line 585 is

    currentColor = HLStoRGB(currentHue,currentSaturation,currentLuminance);

    to be changed to

    currentColor = HLStoRGB(currentHue,currentLuminance,currentSaturation);

    Second, these lines to be added to the class destructor, in the same file

    if (pickerDC)
    delete pickerDC;
    pickerDC = NULL;

    if (luminanceBarDC)
    delete luminanceBarDC;
    luminanceBarDC = NULL;

    That will remove the memory leaks.

    Otherwise, a very good piece of work.


  • There are memory leaks!

    Posted by Legacy on 12/06/1999 12:00am

    Originally posted by: pxz

    There are memory leaks!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date