Solved

Converting Delphi color to integer color

Posted on 2014-03-31
1
2,224 Views
Last Modified: 2014-03-31
I have colors stored in the database as strings that contain delphi colors, e.g. $00FFFF80, $000000FF, etc. I have a component that expects an integer color rather than a string. I've tried to convert the existing colors with this code, but, since the colors produced are incorrect, I'm apparently doing something wrong. Appreciate any insight. Thanks.
function HexToTColor(sColor: string): TColor;
begin
  // sColor begins with $00 so trim sColor to the last 6 chars
  if length(sColor) < 6 then sColor := 'FFFFFF'
  else sColor := rightStr(sColor, 6);
  Result := RGB(StrToInt('$'+Copy(sColor, 1, 2)),
                StrToInt('$'+Copy(sColor, 3, 2)),
                StrToInt('$'+Copy(sColor, 5, 2))
                );
end;

Open in new window

0
Comment
Question by:EricTaylor
1 Comment
 

Accepted Solution

by:
EricTaylor earned 0 total points
ID: 39967793
Ended up solving my own issue:
StrToInt64(sColor);

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question