Mega Code Archive

 
Categories / Delphi / Graphic
 

Converting TColor to a hexadecimal color

Title: Converting TColor to a hexadecimal color Let me be the first to admit that this isn't my own code. I found it on the web somewhere, all I did was turn it into a function (and add the # sign) instead of a procedure. But my guess is that I am not the only one looking for ways to do this hence I am posting it. Helpful people who are making webpage software. I suggest you use a ColorDialog in conjunction with this function for maximum effect. CODE function ColorToHexColor(thisColor: TColor): string; var RGBValue: TColorRef; begin RGBValue := ColorToRGB(thisColor); Result := '#' + Format('%.2x%.2x%.2x', [GetRValue(RGBValue), GetGValue(RGBValue), GetBValue(RGBValue)]); end;