Board index » cppbuilder » Converting Hex to TColor

Converting Hex to TColor


2006-03-07 09:29:20 PM
cppbuilder6
Hello,
I wonder if there is an easy way to convert a 6-digit HEX RGB value String
to TColor?
Thanks in advance,
SZ
 
 

Re:Converting Hex to TColor

Quote
I wonder if there is an easy way to convert a 6-digit HEX RGB
value String to TColor?
AnsiString HexColor = "0x99DDFF";
TColor C = (TColor)HexColor.ToIntDef(0);
Stefano.
 

Re:Converting Hex to TColor

Hello,
Thanks for the reply but the below code does not work here. I enter
"0xFF0000" which should be red but the colordialog displays blue! When I
append "00" more, (making the string "0xFF000000") it displays pink.
Regards,
SZ
"SF" < XXXX@XXXXX.COM >, haber iletisinde žunlar?
yazd? XXXX@XXXXX.COM ...
Quote
>I wonder if there is an easy way to convert a 6-digit HEX RGB value
>String to TColor?

AnsiString HexColor = "0x99DDFF";
TColor C = (TColor)HexColor.ToIntDef(0);

Stefano.

 

{smallsort}

Re:Converting Hex to TColor

Quote
Thanks for the reply but the below code does not work here. I
enter "0xFF0000" which should be red but the colordialog
displays blue!
As it should be.
The hexadecimal value is so formed: 0xBBGGRR.
Where BB = blue, GG = green and RR = red.
If it doesn't work for you, please show your actual code.
Stefano.
 

Re:Converting Hex to TColor

Ok. So what confused me was it being bbggrr istead of rrggbb the usual way.
;(
Thanks a lot!
"SF" < XXXX@XXXXX.COM >, haber iletisinde žunlar?
yazd? XXXX@XXXXX.COM ...
Quote
>Thanks for the reply but the below code does not work here. I enter
>"0xFF0000" which should be red but the colordialog displays blue!

As it should be.

The hexadecimal value is so formed: 0xBBGGRR.

Where BB = blue, GG = green and RR = red.

If it doesn't work for you, please show your actual code.

Stefano.

 

Re:Converting Hex to TColor

I suppose that you know for the functions:
ColorToString()
StringToColor()
...which handles both descriptive (clRed) and value
based colors ("0xbbggrr00")
--
Best Regards,
Vladimir Stefanovic