Click here to Skip to main content
13,258,269 members (50,214 online)
Click here to Skip to main content
Add your own
alternative version


27 bookmarked
Posted 4 Oct 2001

CColorChooser an IDE style Color Picker

, 4 Oct 2001
Rate this:
Please Sign up or sign in to vote.
CColorChooser an IDE style Color Picker
<table width=100%>


Visual Basic is certainly not my cuppa tea, but the Visual Basic IDE does have some good ideas which applications can benefit from. One these is the Color Chooser popup window which allows the user to select a desired color. I've extended the control to include the Web Colors which are found on the new Visual Studio .NET IDE.

During a recent project I needed to design a color chooser and I turned to the VB IDE for 'help'.


The window components contained in the project are show below:

Due to the lose coupling of the design CPaletteWnd, CSysColorWnd or

can be used in isolation if so required in another project. The CColorChooser contains all the functionality and routes specific user messages back to the parent via PostMessage. Custom colors are persistent to the application and are serialized during CColorChooser construction and destruction (stored in the registy).

The project covers owner draw controls and have to create a custom control.


  1. Include the add the following files to the project.
  2. ColorChooser.h & ColorChooser.cpp
    PaletteWnd.h & PaletteWnd.cpp
    WebColorWnd.h & WebColorWnd.cpp
    SysColorWnd.h & SysColorWnd.cpp
  3. Where the CColorChooser is to be implemented add the include file.
    #include "ColorChooser.h"
    <!------------------------------- That's it! --------------------------->
  4. Create a placeholder for the CColorChooser in the class
    class CYourView : public CView...
    	CColorChooser*	m_pWndColorChooser;
  5. Initialize in the constructor
    CYourView:: CYourView()
    	m_pWndColorChooser = NULL;
  6. My example pops the chooser up when the user right mouse clicks.
    void CPaletteTestView::OnRButtonUp(UINT nFlags, CPoint point) 
    	if (m_pwndChooser == NULL)
    		m_pwndChooser = new CColorChooser(point, this, m_crCurr);
  7. When the user selects or loses focus I destroy the window and 'catch' the selected color respectively.
    LRESULT CPaletteTestView::OnColorChanged(WPARAM wParam, LPARAM lParam)
    	m_crCurr = lParam; // Color is contained in lParam
    	delete m_pwndChooser;
    	m_pwndChooser = NULL;
    	return 0;
    LRESULT CPaletteTestView::OnColorChooserClose(WPARAM wParam, LPARAM lParam)
    	delete m_pwndChooser;
    	m_pwndChooser = NULL;
    	return 0;

This article forms a small part of the future article covering a property list control.

Any bugs,  enhancements or suggestions please don't hesitate to contact me.


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


About the Author

Software Developer (Senior) Software Kinetics
United Kingdom United Kingdom

Software Kinetics
are experts in developing customised and bespoke applications and have expertise in the development of desktop, mobile and internet applications on Windows.

We specialise in:

  • User Interface Design
  • Desktop Development
  • Windows Phone Development
  • Windows Presentation Framework
  • Windows Forms
  • Windows Communication Framework
  • Windows Services
  • Network Applications
  • Database Applications
  • Web Development
  • Web Services
  • Silverlight

Visit Software Kinetics

You may also be interested in...

Comments and Discussions

BugDeprecation Fix Pin
Tosaka Kawashita24-Dec-13 16:23
memberTosaka Kawashita24-Dec-13 16:23 
QuestionHow can I... Pin
Darren Schroeder29-Mar-03 7:18
memberDarren Schroeder29-Mar-03 7:18 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 5 Oct 2001
Article Copyright 2001 by NormDroid
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid