Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Lazarus] [Delphi?] StrToColorDef

21 views
Skip to first unread message

Terrmit

unread,
May 20, 2010, 4:02:15 PM5/20/10
to
Witam,

Taka sobie prosta rzecz. Wnerwiło mnie, że StringToColor
wywala błąd, gdy poda się mu bzdurną nazwę koloru
(u mnie zdarzały się puste stringi). Ale skoro jest
IntToStrDef, StrToFloatDef itp., to czemu nie StrToColorDef?
Nieco więc "poprawiłem" StringToColor.
Może komuś się przyda.

function StrToColorDef(const S: shortstring; Default: TColor): TColor;
begin
Result := Default;
if not IdentToColor(S, Longint(Result)) then
Result := TColor(StrToIntDef(S, Integer(Default)));
end;

Jakby ktoś mógł sprawdzić, czy działa to w Delphi, bo ja nie mam.

Sławek

0 new messages