Convertir TColor -> HTML  

Enviado Por: Radikal (Q3 Team)
Web : http://www.q3.nu
Email: radikal@q3.nu
Fecha: 11/10/99

Truco accedido 134 veces

 


Util para convertir colores Delphi a colores HTML

Un ejemplo:

  • Pon un TColorDialog (ColorDialog1), un TLabel (Label1) y un TButton (Button1) en tu form
  • Mete éste código en el OnClick de Button1:


     procedure TForm1.Button1Click(Sender: TObject);
    
     function ColorToHtml(DelphiColor:TColor):string;
     var
       tmpRGB : TColorRef;
     begin
       tmpRGB := ColorToRGB(DelphiColor);
       Result:=Format( '#%.2x%.2x%.2x',
                       [GetRValue(tmpRGB),
                        GetGValue(tmpRGB),
                        GetBValue(tmpRGB)]);
     end;
    
    
     begin
       if ColorDialog1.Execute then
         Label1.Caption:=ColorToHtml(ColorDialog1.Color);
     end;