Introduction
When I created this colour selector I was creating a 3D graphics program; I was using the standard windows common colour selection dialog box however it became a bit tedious selecting the "Define Custom Colours >>" button to select custom colours. So I designed this colour selector which I find much easier to use.
Using the code
All colour boxes can be dragged and dropped onto the custom colour boxes. Custom colour values are automatically restored each time the dialog box is displayed. The colours can all be dragged onto the "New Colour:" box to select that colour.
Clicking on the "Current Colour:" colour box will select the original colour again. However it is not possible (without modifications) to drag a colour on-top of the "Current Colour:" colour box as that would defeat the object of having it.
It is possible to change the colour reference, hue value, saturation value, lumination value, red value, green value, and the blue value.
I hope that this is of some use to you.
COLORREF rgbColor = RGB(255, 0, 0);
CSelColorDlg dlgSelColor(GetRValue(rgbColor), GetGValue(rgbColor),
GetBValue(rgbColor));
if(dlgSelColor.DoModal() == IDOK)
{
rgbColor = dlgSelColor.GetColor();
Invalidate();
}
Points of Interest
Most of the visual appearance of the colour selector has relied on the use of GetBitmapBits()
and SetBitmapBits()
to save on processing time. When the colour images are generated the image is stored within a CBitmap
object; then later to be drawn as usual.
History
- Fixed major bug regarding desktop colour depths.