🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.pascal
Article #93013

[Lazarus] [Delphi?] StrToColorDef

#93013
From: Terrmit
Date: Thu, 20 May 2010 20:02
19 lines
1407 bytes
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
Technical Details
Message-ID: <ht44k7$7r5$1@news.mm.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.task.gda.pl!news.mm.pl!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.task.gda.pl!news.mm.pl!not-for-mail
From: Terrmit <terrmitv@poczta.onet.pl>
Newsgroups: pl.comp.lang.pascal
Subject: [Lazarus] [Delphi?] StrToColorDef
Date: Thu, 20 May 2010 22:02:15 +0200
Organization: Multimedia Polska SA
Lines: 19
Message-ID: <ht44k7$7r5$1@news.mm.pl>
NNTP-Posting-Host: host-89-231-112-128.warszawa.mm.pl
Mime-Version: 1.0
X-Trace: news.mm.pl 1274385863 8037 89.231.112.128 (20 May 2010 20:04:23 GMT)
X-Complaints-To: abuse@multimedia.pl
NNTP-Posting-Date: Thu, 20 May 2010 20:04:23 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc12 Lightning/1.0b2pre Thunderbird/3.0.4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit