Click here to Skip to main content
15,868,016 members
Articles / Desktop Programming / MFC
Article

A color picker dialog with a color dropper like Photoshop and Frontpage 2000

Rate me:
Please Sign up or sign in to vote.
4.83/5 (10 votes)
23 Jan 20022 min read 94.7K   4.3K   29   6
A color picker and dropper that extends the standard Windows dialogs to behave like Photoshop or Frontpage 2000

Introduction

The key features are as follows:

  1. ColorPicker provides a default color panel, which includes over 144 frequent colors.
  2. ColorPicker provides a custom button for opening Windows Common Color Select Dialog. You can select more color here.
  3. ColorPicker provides the color contrast between current selection and new selection.
  4. ColorPicker provides a select buttonImage 1, when you hold the left button of mouse on select button, the cursor has become to a color dropperImage 2 like Photoshop and Frontpage 2000. You can get any color on the screen via this dropper.
  5. ColorPicker shows both the RGB value and Hex Value of the current selection color.
  6. The color panel will load new palette as soon as the system color range has been changed.
  7. ColorDropper provides 6 color panels for choosing. You can change it during run time.
  8. The most important thing is that, we provide the full source code (100% MFC), ….

Screen Shots

Image 3

(Screen 1)

Image 4

(Screen 2)

Image 5

(Screen 3)

How to use it

 The steps for usage are as follows:

  1. Add code in those head files where you want to display Color Picker Dialog.
    #include "FODropColorButton.h"
    enum { IDD = IDD_DIALOG_COLORPICKER };
    CFODropColorButton m_wndColor3;
    CFODropColorButton m_wndColor2;
    CFODropColorButton m_wndColor1;
    CFOHyperLink m_newVersion;
    //}}AFX_DATA
  2. Add code in those files/events when you need to get color value.
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CNewPickerDlg)
    DDX_Control(pDX, IDC_FO_TEST_BUTTON3, m_wndColor3);
    DDX_Control(pDX, IDC_FO_TEST_BUTTON2, m_wndColor2);
    DDX_Control(pDX, IDC_FO_TEST_BUTTON1, m_wndColor1);
    //}}AFX_DATA_MAP
    DDX_FODropColorButton(pDX,IDC_FO_TEST_BUTTON1,crColor1);
    DDX_FODropColorButton(pDX,IDC_FO_TEST_BUTTON2,crColor2);
    DDX_FODropColorButton(pDX,IDC_FO_TEST_BUTTON3,crColor3);

Everything is done!

Technical Details

 Color Picker Dialog is constructed with classes as follows;

  1. CFOColorButton File Reference:FOColorButton.h, FOColorButton.cpp
  2. CFOColorCellObj File Reference:FOColorCellObj.h, FOColorCellObj.cpp
  3. CFOColorDialogObj File Reference: FOColorDialog.h, FOColorDialog.cpp
  4. CFOColorPaletteControl File Reference:FOColorPaletteControl.h, FOColorPaletteControl.cpp
  5. CFODropPaletteWndFile Reference:FODropPaletteWnd.h, FODropPaletteWnd.cpp
  6. CFODropColorButton File Reference:FODropColorButton.h, FODropColorButton.cpp
  7. CFODropColorPaletteControl File Reference:FODropColorPaletteControl.h, FODropColorPaletteControl.cpp
  8. CFODropColorPaletteWnd File Reference:FODropColorPaletteWnd.h, FODropColorPaletteWnd.cpp
  9. CFOPopupColorPaletteWndFile Reference:FOPopupColorPaletteWnd.h, FOPopupColorPaletteWnd.cpp

All of the class inheritance diagrams are as follows:

<xml>\s Image 6

Image 7<xml>\s

Image 8

<xml>\s Image 9

Image 10

Click here to view Our online profile and report bugs.

Update V1.5(New!)

  • Add color palette support for color dialog.
  • Add a cool drop color picker button.
  • Fixed a few bugs.

Update V1.2

  • Add a specify image static class.
  • Add support 3D color table.
  • Fixed a few bugs.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
jack Mesic is the president of UCanCode Software Technology,Inc..

Comments and Discussions

 
GeneralProblems Pin
2-Feb-02 0:40
suss2-Feb-02 0:40 
QuestionNo keyboard functionalities ? Pin
Jean-Michel LE FOL25-Jan-02 23:28
Jean-Michel LE FOL25-Jan-02 23:28 
GeneralCool!! Pin
23-Jan-02 21:36
suss23-Jan-02 21:36 
GeneralMissing Resources Pin
Uwe Keim23-Jan-02 19:59
sitebuilderUwe Keim23-Jan-02 19:59 
GeneralRe: Missing Resources Pin
jack Mesic23-Jan-02 20:58
jack Mesic23-Jan-02 20:58 
GeneralRe: Missing Resources Pin
Chris Maunder23-Jan-02 23:36
cofounderChris Maunder23-Jan-02 23:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.