Mega Code Archive

 
Categories / Delphi / Graphic
 

Creating Custom Colours

Title: Creating Custom Colours Question: When setting the Color property for controls, are we limited to the predefined values (clWhite, clRed, etc...) Answer: It is possible to define constants for new TColor values; all you have to do is: {--snip--} const clKhaki = TColor($ADAE80); {Later...} procedure TForm1.Button1Click(Sender: TObject); begin Self.Color := clKhaki; //now you have a khaki form! end; {--snip--} As you can see, all you have to do is: define a constant that describes your custom colour (in hexadecimal); typecast it to TColor type and voila! you have a new TColor. If you know how to write color notation for HTML, then it is just a matter of interchanging # with $ (the hex notation for Pascal)