I would like to assign some color to label (TNewStaticText - property Color: TColor; read write;) on my form.
I have my color stored as '$RRGGBB' (String) and I would like to convert it to TColor using Delphi function StringToColor() but Inno Setup shows me an error if I use this function in script. How to tell Inno Setup to use this function or how to convert String to TColor in Inno to use it with this property?
@Andreas Rejbrand:
When I downloaded Inno's sources I noticed function StringToColor() in sources. Here is fragment of Compiler.pas:
As you can see Inno has it's own implementation of StringToColor() which can also parse colors by names [like IdentToColor('clBlack')].
I was hoping for some quick hack how to use this function from script but it seems that this function is not pulled to public interface (ScriptFunc_R.pas or ScriptFunc_C.pas).
As Andreas mentioned in his comment to the question, there's no built-in function. You can craft your own, example:
Should you have been storing your colors like
$BBGGRR
, you could simply convert it withSertac Akyuz's approach is fine, but I solved this few minutes after writing this question, sorry :) This is my function - there is a little more handling:
The whole magic does function StrToInt() which converts String to Integer - but if you add '$' before string it treats the string as Hex number and it will be converted automatically to Decimal number. Result is Integer TColor created from that number.