Solved

Converting Delphi color to integer color

Posted on 2014-03-31
1
2,430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month6 days, 21 hours left to enroll

623 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