Question and Answer Database FAQ: FAQ4712C — Converting a TColor to an HTML color string Category: Internet/WEB Platform: All-32Bit Product: All-CBuilder, Question: How can I convert a TColor value to an HTML Color string? Answer: The following example demonstrates converting a TColor to a RGB color, and formating the RGB color to be shown as hexadecimal digits. void __fastcall TForm1::Button1Click(TObject *Sender) { TColorRef rgbVal; if (ColorDialog1->Execute()) { rgbVal = ColorToRGB(ColorDialog1->Color); AnsiString tmp = Format("%2x%2x%2x",OPENARRAY(TVarRec, (GetRValue(rgbVal),GetGValue(rgbVal),GetBValue(rgbVal)))); Label1->Caption = tmp; } } 8/4/99 11:57:31 AM
Last Modified: 01-SEP-99