Autor Beitrag
KeinePanik
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 131



BeitragVerfasst: Mo 05.08.02 00:14 
Bin ich jetzt richtig ??? :D

Also ich schreib gerade ein Programm, dass HTML-Code erstellt ...

Ich möchte nun die Farben, die der User per ''ColorDialog'' gewählt hat, in HTML ''umrechnen'' ... sprich :

Farbe ''clgreen'' zu
''<body bgcolor="#008000">'' in die erstellte HTML-Seite schreiben ... (z.B.)


Hat jemand ne Idee ???

_________________
Es gibt keine dummen Fragen ... Nur blöde Antworten !!!
t-ob-i
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 31



BeitragVerfasst: Mo 05.08.02 00:32 
Faq's sind doch ganz praktisch was?

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
function ColorToHTMLColor(Color: TColor): String;
var
  C: packed record case Integer of
       0: (Int: LongInt);
       1: (B0, B1, B2, B3: Byte);
    end;
  H: Byte;
begin
  // convert negative (SysColor) values like clBtnFace
  C.Int := ColorToRGB(Color);
  // red value of TColor is in byte 0, of HTML in byte 2: swap
  H := C.B0;
  C.B0 := C.B2;
  C.B2 := H;
  // output hex value
  Result := Format('"#%.6x"', [C.Int]);
end; {Michael Winter}
KeinePanik Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 131



BeitragVerfasst: Mo 05.08.02 00:53 
Bin ich schon drin ? ........ Na das ging aber schnell !!! :lol: :lol: ..

Ich schaus mir morgen mal an ... Danke erstmal ...

_________________
Es gibt keine dummen Fragen ... Nur blöde Antworten !!!
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 08.08.02 19:29 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
function html(color: TColor): string;
var
  i : integer;
begin
  i      := ColorToRGB(color);
  i      := RGB(GetBValue(i),GetGValue(i),GetRValue(i));
  Result := '#' + lowercase(inttohex(i,6));
end;

Geht auch und ist kürzer, weil einfach nur der Rot- und der Blau-Wert vertauscht werden. :wink: