function HtmlToColor(AColor: string): TColor; begin Result := StringToColor('$' + Copy(AColor, 6, 2) + Copy(AColor, 4, 2) + Copy(AColor, 2, 2)); end;function HTMLToColor(const s: string; var Color: TColor): Boolean; function No16: Boolean; var i: Integer; begin Result := False; for i := 2 to 7 do if not ((s[i] in ['0'..'9']) or (s[i] in ['A'..'F'])) then begin Break; Result := True; end; end; function GetNum(pos: Byte): Byte; var ms: string; E: Integer; begin ms := '$' + Copy(s, pos, 2); Val(ms, Result, E); end;begin Result := False; if (Length(s) <> 7) then Exit else if (s[1] <> '#') then Exit else if No16 then Exit; Color := GetNum(6) shl 16 or GetNum(4) shl 8 or GetNum(2); Result := True; end; 参照上面两个函数。
begin
Result := StringToColor('$' + Copy(AColor, 6, 2) + Copy(AColor, 4, 2) + Copy(AColor, 2, 2));
end;function HTMLToColor(const s: string; var Color: TColor): Boolean; function No16: Boolean;
var
i: Integer;
begin
Result := False;
for i := 2 to 7 do
if not ((s[i] in ['0'..'9']) or (s[i] in ['A'..'F'])) then
begin
Break;
Result := True;
end;
end; function GetNum(pos: Byte): Byte;
var
ms: string;
E: Integer;
begin
ms := '$' + Copy(s, pos, 2);
Val(ms, Result, E);
end;begin
Result := False; if (Length(s) <> 7) then
Exit
else if (s[1] <> '#') then
Exit
else if No16 then
Exit; Color := GetNum(6) shl 16
or GetNum(4) shl 8
or GetNum(2); Result := True;
end;
参照上面两个函数。