Voila les deux fonctions réciproques :
{ ***************************************************************************** - Méthode : TPlanning.HexToColor(s: string): TColor; - Description : Cette méthode permet de convertir un string (Hex) en TColor. - Entrees : s (la chaine de caractères, couleur hexadécimale). - Sorties : TColor (le TColor Créé). } function TPlanning.HexToColor(s: string): TColor; begin if pos('#', s) <> 0 then Delete(s, pos('#', s), 1); if pos('$', s) <> 0 then Delete(s, pos('$', s), 1); Result := rgb(StrToInt('$' + Copy(s, 1, 2)), StrToInt('$' + Copy(s, 3, 2)), StrToInt('$' + Copy(s, 5, 2))); end; { ***************************************************************************** - Méthode : TPlanning.ColorToHex(Color: TColor): string; - Description : Cette méthode permet de convertir TColor en string (Hex). - Entrees : Color (la couleur à convertir). - Sorties : string (le résultat de la conversion). } function TPlanning.ColorToHex(Color: TColor): string; begin Result := intToHex(GetRValue(Color), 2) + intToHex(GetGValue(Color), 2) + intToHex(GetBValue(Color), 2); end; ----------------------------- Membre de la blindprod : http://www.blindprod.fr.st
|