Autor Beitrag
schermerbua
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: Di 06.12.05 21:06 
ich will von einem Label die Farbe ändern, aber als Farbangabe will ich ne Html code nehmen. also dass ich sage FFFFFF und das Label wird weiß. geht das? bzw wie geht das?
danke für die Hilfe!
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 06.12.05 21:16 
Den HTML-Code umdrehen und ein $00 davor schreiben. Beispiel:
ausblenden Quelltext
1:
2:
#AABBCC   ->   CCBBAA   ->   $00CCBBAA
^- HTML-Code   ^- Umgedreht  ^- $00 hin

ausblenden Delphi-Quelltext
1:
Label1.Font.Color := $00CCBBAA;					

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
schermerbua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: Di 06.12.05 21:33 
Danke, es funktioniert!Ne andere Frage:
wenn ich den Html Wert vorher in eine Variable reinspeichere, kann ich ja nicht
Label1.font.color:=color;
color wäre die Variable für den Farbcode!
schreiben. wie kann ich die Variable umwandeln, dass es auch so funktioniert?
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Di 06.12.05 23:38 
dreh den string entsprechend zurecht und verwende die int<>hex umwandlungsfunktionen
schermerbua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: Mi 07.12.05 06:49 
ich hab davon noch nie was gehört, sorry! Was soll ich da machen? inttohex();?
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Mi 07.12.05 14:19 
du hast ja den Hex-Wert (als string) gegeben und willst einen Integer haben. Afaik geht das mit der Funktion StrToInt, jedoch erwartet die bei hexadezimalen Zahlen die Pascal-notation, nicht die von HTML. Du musst also zuerst den String ins Format $00BBGGRR umwandeln, die ersten beiden Stellen 0, die nächsten zwei für blau, zwei für grün und noch zwei für rot. Diesen String kannst du mit StrToInt umwandeln und das Ergebniss direkt dem Color-Property zuweisen.