The XColorPicker Control

The CColorPicker class is great as far as it goes, but in some applications you might want to have a color palette always available on the form instead of one that pops up in response to your clicking a button. In that case, you want a control. The XColorPicker control looks like the FColorPicker form except that it is on a UserControl. Instead of returning the selected color through a property, it generates a Picked event when a color is selected. You can set the initial color in the Properties window at design time.

Of course, there are significant code differences between a form and a control. The control has a design-time life as well as a run-time life. Those differences caused me quite a bit of trouble, but they aren’t interesting enough to show here. You can see the details in COLORPICKER.CTL.

CHALLENGE Unlike the color picker in the Properties window, CColorPicker and XColorPicker do not include rows for custom colors, nor do they provide a separate tab for picking a system color. That’s your job.