Article View: borland.public.cppbuilder.nativeapi
Article #3108DrawTextEx problem when using a TAB character in a listbox
From: Daryl
Date: Sat, 07 Oct 2006 08:25
Date: Sat, 07 Oct 2006 08:25
45 lines
2262 bytes
2262 bytes
Using BDS2006 on WIN XP SP2
I have a listbox that I want to add several strings with a single tab in
each string to space them within the listbox.
Example Test Application\tc:\ProgramFiles\Testing
I am using the following extract in the listbox OnDrawItem event.
void __fastcall TfrmMain::lbTESTDrawItem(TWinControl *Control,
int Index, TRect &Rect, TOwnerDrawState State)
{
// some code removed.
// Item would hold each string in the listbox i.e. Test
Application\tc:\ProgramFiles\Testing
DRAWTEXTPARAMS dtp;
dtp.cbSize = sizeof(dtp);
dtp.iTabLength = 25;
dtp.iLeftMargin = 0;
dtp.iRightMargin = 0;
r = Rect;
r.Right -= 55; // <== Adjust size of Rect, WHY???
DrawTextEx(lb->Canvas->Handle,
Item.c_str(),
Item.Length(),
&r,
DT_LEFT | DT_SINGLELINE | DT_NOCLIP | DT_VCENTER |
DT_EXPANDTABS | DT_TABSTOP | DT_PATH_ELLIPSIS,
&dtp);
// some code removed.
}
I find that I have adjust the Rect available by using the OnDrawItem event
by approx 55 pixels (in this case) to get the pathname to display the
'ellipsis'. I don't really understand why as I have passed the size of the
TabLength. The only thing I can think of is that it has some thing to do
with Logical units and device units and the TAB is not being compensated
for.
Can anyone help?
thanks
daryl
Technical Details
Message-ID:
<45276475$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6eadc8e565700ec7,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Daryl" <devaccount@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: DrawTextEx problem when using a TAB character in a listbox Date: Sat, 7 Oct 2006 18:25:26 +1000 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 NNTP-Posting-Host: 202.63.48.162 Message-ID: <45276475$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1160209525 202.63.48.162 (7 Oct 2006 01:25:25 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail