![]() |
HTML Code Farben verwenden
ich hab da mal ne frage wie kann man in delphi7 htmlcode farben verwenden?? muss man da irgendwas beachten??
|
Re: HTML Code Farben verwenden
hallo,
ich hab da ein Paar Codezeilen aufgeschnappt die, glaube ich, dass erledigen, was du brauchst
Delphi-Quellcode:
grüße, daniel
uses SysUtils, Graphics;
// converts a color to an html color string // clRed => #FF0000 function Sto_ColorToHtml(const Color: TColor): String; var iRgb: Longint; iHtml: Longint; begin // convert system colors to rgb colors iRgb := ColorToRGB(Color); // change BBGGRR to RRGGBB iHtml := ((iRgb and $0000FF) shl 16) or // shift red to the left ( iRgb and $00FF00) or // green keeps the place ((iRgb and $FF0000) shr 16); // shift blue to the right // create the html string Result := '#' + IntToHex(iHtml, 6); end; // converts an html color string to a color, // can raise an EConvertError exception // #0000FF -> clBlue function Sto_HtmlToColor(Color: String): TColor; var iHtml: Longint; begin // remove the preceding '#' if (Length(Color) > 0) and (Color[1] = '#') then Delete(Color, 1, 1); // convert html string to integer iHtml := StrToInt('$' + Color); // change RRGGBB to BBGGRR Result := ((iHtml and $FF0000) shr 16) or // shift red to the right ( iHtml and $00FF00) or // green keeps the place ((iHtml and $0000FF) shl 16); // shift blue to the left end; |
Re: HTML Code Farben verwenden
Delphi-Quellcode:
function ConvertToHtmlColor(Col : TColor): string;
var s : string; begin s := IntToHex(ColorToRgb(col),6); s := Copy(s,5,2) + Copy(s,3,2) + Copy(s,1,2); Result := Format('#%s', [s]); end; function ConvertToRGBColor(Col : TColor): string; var i: integer; begin i := ColorToRGB(Col); result := inttostr(GetBValue(i))+inttostr(GetGValue(i))+inttostr(GetRValue(i)); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:54 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz