|
-
April 7th, 1999, 03:12 AM
#1
Center text in a listbox?
Hiya!
I'm wondering if its possible to center the text in a CListBox. Both vertical and horisontel.
Thanks
Magnus
-
April 7th, 1999, 06:17 AM
#2
Re: Center text in a listbox?
One of the best way is to use an ownder-deawn list box
1 ) modify your resource to have an Owner draw and Has string styles
2 ) intercepeit the owner draw message
3 ) Draw your text
....
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rcLine(lpDrawItemStruct->rcItem);
GetText(lpDrawItemStruct->itemID, strChaine);
there you have a CDC, a CString and a Rect.
DrawText(... DT_CENTER | DT_VCENTER)
there are many samples in code guru
One tip you are supposed to fraw the line diffrently depending of the focus and state
if ((lpDrawItemStruct->itemState & ODS_SELECTED)
or (lpDrawItemStruct->itemAction & ODA_SELECT))
{
CRect Unrect(lpDrawItemStruct->rcItem);
pDC->InvertRect(&Unrect);
...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|