a Delphi component for color selection

Introduction
The Delphi programming environments already contains a dialog form for
color selection.
In some cases however, a simple component, not a pop-up form, for the selection of colors is needed.
This component may also be integrated in complex, home built, dialog forms.

This article describes such a simple component.
At the end, the complete source code is listed as well.

How the component may look
Ancestor Class
The ancestor class is the TGraphicControl component, which is also the ancestor
of the Tpaintbox component.
Basically, the davColorBox is a modified paintbox.

Component Properties

Component Methods

Component Events

OnSelect is derived from the Mouse_Up event.

Component Application
When a mouse_up event occurs on the davColorBox component,
an OnSelect event is received. Remarks
The width and height properties are recalculated by the component,
depending on the colordepth and Csquare values selected.

Within the component, a color is represented by a sequential number in the range 0 .. 511
in the case of 512 color mode.
From this number, the position in the rectangle is calculated for display.
Also the 32 bit Windows color is calculated from this value.
This 32 bit, true color, value is returned at the Onselect event.

Source Code