A demo project is included. I hope someone else can get some use out of this code, too. :-)
How to include in your project
- Copy ColorBtn.cpp and ColorBtn.h into your project directory.
- Add ColorBtn.cpp to your project.
How to use
- Create a button on your dialog. Mark it as "Owner Draw".
- Declare a variable in your dialog class, like this:
- At OnInitDialog, call SubclassDlgItem, like this:
colorbtn.SubclassDlgItem(IDC_BUTTON,this); // Use your button ID here
- Add Colors to the button's color dialog using AddColorWell or SetColorsFromArray
- Customize the button's color dialog by setting the number of columns, border widths, and shape variables
- Repeat the process for each button you want. (See the sample project provided for more details)
You can set and read the selected color using the "m_CurrentColor" member variable.
Date Last Updated: February 3, 1999