Thread View: borland.public.cppbuilder.nativeapi
1 messages
1 total messages
Started by Daryl
Sat, 07 Oct 2006 08:25
DrawTextEx problem when using a TAB character in a listbox
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads