This article is about Color Components which is used to select or display Colors. If you are new to ARGB color please refer to this article about Colors in Modern C++
ColorButton (TColorButton)
It is a standard button that displays a color. It can be used to pop up color picker window then backs with selected color. May be to show foreground background colors, etc. It can be used with OnClick() event as in this example below that changes its color randomly on every click;
1 2 3 4 5 6 |
void __fastcall TForm1::ColorButton1Click(TObject *Sender) { ColorButton1->Color=Random(0xFFFFFFFF); } |
ColorBox (TColorBox)
Represents a rectangular-shaped color indicator. This box can be used to show selected color.
1 2 3 4 |
TAlphaColorRec arc=claBlack; ColorBox1->Color=arc.Color; |
ColorComboBox (TColorComboBox)
ColorComboBox shows a combo box that allows you to select a color from a color palette. This example below sets Color of a ColorBox when the Color of ColorListBox is changed;
1 2 3 4 5 6 7 |
void __fastcall TForm1::ColorComboBox1Change(TObject *Sender) { TAlphaColor col=ColorComboBox1->Color; ColorBox1->Color=col; } |
ColorListBox (TColorListBox)
ColorListBox is a combo box that allows you to select an alpha color from a color spectrum, so users can easily select
1 2 3 4 5 6 |
void __fastcall TForm1::ColorListBox1Change(TObject *Sender) { ColorBox1->Color=ColorListBox1->Color; } |
ColorPicker (TColorPicker)
Color picker shows a color selector that displays the entire color spectrum. A TColorPicker component is a color selector that displays a color spectrum and lets you pick any color by moving a dot-style selector. TColorPicker can be attached to a TColorQuad component. It is used with OnChange() event to set selected color to another things as below
1 2 3 4 5 6 7 |
void __fastcall TForm1::ColorButton1Click(TObject *Sender) { ColorButton1->Color=ColorPicker1->Color; ColorButton2->Color=ColorPicker1->Hue; } |
ColorPanel (TColorPanel)
ColorPanel is a color selector component complete with alpha channel selection. A TColorPanel component is a color selector that displays a color spectrum represented as a THueTrackBar, an alpha channel track bar selector, and a color quad. These make the TColorPanel component a great color selector.
1 2 3 4 5 6 |
void __fastcall TForm1::ColorPanel1Change(TObject *Sender) { ColorBox1->Color=ColorPanel1->Color; } |
ColorQuad (TColorQuad)
TColorQuad component is generally attached to TColorPicker to show shades of selected colors. In this way, every time you change the Color in this color picker, the color quad component automatically updates to the color selected in the color picker, further allowing you to tweak the saturation and luminance.
1 2 3 4 5 6 |
void __fastcall TForm1::ColorQuad1Change(TObject *Sender) { ColorBox1->Color=ColorQuad1->Color; } |
Design. Code. Compile. Deploy.
Start Free Trial
Free C++Builder Community Edition