Solved

Converting Delphi color to integer color

Posted on 2014-03-31
1
2,182 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

809 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