Article View: borland.public.cppbuilder.nativeapi
Article #7668Re: DrawTextEx
From: Remy Lebeau (TeamB)
Date: Tue, 04 Jan 2005 21:08
Date: Tue, 04 Jan 2005 21:08
30 lines
1868 bytes
1868 bytes
"Jonathan Benedicto" <incorrect@no.server> wrote in message
news:41dae681$1@newsgroups.borland.com...
> I don't know if I'm being stupid, but what about this code ?
That code is altering the original AnsiString. Since Petar did not show how
cFileName is being assigned or whether it is still used after DrawTextEx()
is called, that may not be desirable. That is probably why he is copying it
to a secondary buffer, so that DrawTextEx() alters the buffer and not the
original AnsiString.
Also, the DT_CALCRECT flag should be included as well, so that the text is
not actually drawn visually, only re-formatted in memory:
char a[MAX_PATH+1] = {0};
strncpy(a, cFileName.c_str(), MAX_PATH);
RECT r;
r.left = 0;
r.top = 0;
r.right = lb->Width - 20;
r.bottom = lb->ItemHeight;
if( DrawText(lb->Canvas->Handle, a, -1, &r, CT_CALCRECT |
DT_MODIFYSTRING | DT_PATH_ELLIPSIS | DT_SINGLELINE) )
lb->Items->Add(a);
Gambit
Technical Details
Message-ID:
<41db057f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41d5500e$1@newsgroups.borland.com> <41dae681$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 From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <41d5500e$1@newsgroups.borland.com> <41dae681$1@newsgroups.borland.com> Subject: Re: DrawTextEx Date: Tue, 4 Jan 2005 13:08:46 -0800 Lines: 32 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <41db057f$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1104872831 68.69.17.41 (4 Jan 2005 13:07:11 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail