-1

In VCL, I could simply call the ColorToString function from System.UIConsts, but this function is VCL only because it uses TColor:

function ColorToString(Color: TColor): string;
begin
  Result := ColorToStringExt(Color, csfIdent);
end;

I would have expected there to be an overloaded version of ColorToString that makes it work for FMX also, but no.

1 Answer 1

0

Ah. After searching for a little bit more, I found that there's the AlphaColorToString function within System.UIConsts:

function AlphaColorToString(Value: TAlphaColor): string;
begin
  AlphaColorToIdent(Integer(Value), Result);
  if Result.Chars[0] = 'x' then
    Result := '#' + Result.SubString(1)
  else
    Result := Result.Remove(0, 3);
end;

So that's what needs to be used in FMX.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.