Autor Beitrag
mambo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win XP
D6 Prof
BeitragVerfasst: Mo 24.02.03 09:23 
Ich möchte die Farbe des Datensatzes hexadezimal in der Oracle Tabelle speichern und dann den Datensatz im TdxDBGrid je nach Farbe anzeigen.

Mein Problem ist nun: wie kann ich einen Farbwert den ich als String (bzw. varchar2) gespeichert habe der Eigenschaft Color zuweisen ???

AColor := $00FFFFFF funktioniert ja, aber
AColor := '$00FFFFFF' nicht!
wie kann ich also den Hexadezimal-String in TColor umwandeln??

Danke
mars
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 238

Debian Woody, Win 2000, Win XP
D7 Ent, Kylix 3
BeitragVerfasst: Mo 24.02.03 10:07 
Diese Funktion sollte dir dabei helfen:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
function HexToColor(sColor: string): TColor;
begin
  Result :=
    RGB(
    StrToInt('$' + Copy(sColor, 1, 2)),
    StrToInt('$' + Copy(sColor, 3, 2)),
    StrToInt('$' + Copy(sColor, 5, 2))
    );
end;


Greets
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 25.02.03 08:19 
Hi
noch simpler geht's mit:
ausblenden Quelltext
1:
AColor := StrToInt('$00FFFFFF');					


Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...