🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7660

Re: DrawTextEx

#7660
From: Hans Galema
Date: Tue, 04 Jan 2005 12:31
26 lines
1952 bytes
Remy Lebeau (TeamB) wrote:

> It does not need to be since the length of the buffer is being passed to
> DrawTextEx().

Ok. I did not look further to where a was used. But still
consider it bad programming style. If one would add a Showmessage(a);
or a logit(a); then there could be trouble.

>     char a[200] = {0};
>     strncpy(a, cFileName.c_str(), 199);
>     int length = min(cFileName.Length(), 199);
> 
>     DrawTextEx(lb->Canvas->Handle, a, length, &r, DT_MODIFYSTRING |
> DT_PATH_ELLIPSIS, NULL)

That still is not nice. As length depends now on cFileName and not directly
on the contents of a.

     char a[200] = {0};
     strncpy(a, cFileName.c_str(), 199);

     DrawTextEx(lb->Canvas->Handle, a, strlen(a), &r,
	DT_MODIFYSTRING | DT_PATH_ELLIPSIS, NULL);

Hans.
Technical Details
Message-ID: <41da8cbd$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41d5500e$1@newsgroups.borland.com> <41d983be@newsgroups.borland.com> <41d99396$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,42d3caa052e60398
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 04 Jan 2005 13:31:12 +0100
From: Hans Galema <notused@notused.nl>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: DrawTextEx
References: <41d5500e$1@newsgroups.borland.com> <41d983be@newsgroups.borland.com> <41d99396$1@newsgroups.borland.com>
In-Reply-To: <41d99396$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 129.125.201.248
Message-ID: <41da8cbd$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1104841917 129.125.201.248 (4 Jan 2005 04:31:57 -0800)
Lines: 26
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail