AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

HTML Code Farben verwenden

Ein Thema von joeyjmr · begonnen am 3. Sep 2003 · letzter Beitrag vom 3. Sep 2003
Antwort Antwort
joeyjmr

Registriert seit: 3. Sep 2003
Ort: Briggow
1 Beiträge
 
Delphi 7 Enterprise
 
#1

HTML Code Farben verwenden

  Alt 3. Sep 2003, 09:37
ich hab da mal ne frage wie kann man in delphi7 htmlcode farben verwenden?? muss man da irgendwas beachten??
  Mit Zitat antworten Zitat
Benutzerbild von Sanchez
Sanchez

Registriert seit: 24. Apr 2003
Ort: Neumarkt Stmk
892 Beiträge
 
Delphi XE6 Enterprise
 
#2

Re: HTML Code Farben verwenden

  Alt 3. Sep 2003, 09:45
hallo,

ich hab da ein Paar Codezeilen aufgeschnappt die, glaube ich, dass erledigen, was du brauchst

Delphi-Quellcode:
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;
grüße, daniel
Daniel
  Mit Zitat antworten Zitat
Alexander

Registriert seit: 28. Aug 2002
Ort: Oldenburg
3.513 Beiträge
 
Turbo Delphi für .NET
 
#3

Re: HTML Code Farben verwenden

  Alt 3. Sep 2003, 15:44
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;
Alexander
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:45 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz