Solved

Converting Delphi color to integer color

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now