Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread How to get a TColor from a string
Mon, Jun 8 2020 7:19 PMPermanent Link

Paul Coshott


Hi All,

I have a list of colors such as :

"clOrange = $FFFFA500"

Each color is an item in a string list.

How can I use either the clOrange part or the $FFFFA500 part to get a TColor value that I can use in my app?

Tue, Jun 9 2020 4:23 AMPermanent Link

Matthew Jones

Paul Coshott wrote:

> the $FFFFA500

Looking at my code, the key is the Javascript parseint which is used by StrToInt, which takes 0x as a hex prefix. So replace the $ with 0x and it should work for you.
It may be you have to rearrange the order of the RGB bytes after that.


Matthew Jones
Tue, Jun 9 2020 9:30 AMPermanent Link

Paul Coshott


"Matthew Jones" wrote:

>> replace the $ with 0x and it should work for you.

Thanks Matthew,

Worked perfectly. I didn't need to play with the RGB bytes. For anyone interested:

   myColor : TColor;
   myStrCol : string;
   myStrCol := '0xFFFFA500';
   myColor := TColor(StrToInt(myStrCol));