CListBox, Ownerdrawvariable and wordwrap

yacht
yacht used Ask the Experts™
on
I am trying to make a CListBox that wordwraps the text instead of using the horiz scrollbar.  I was told that I need to make it ONWERDRAWVARIABLE and use CDC to draw the text in to each by hand.  Does anyone have any sample code that demonstrates this?

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Engineer
Commented:
Yes, you will need to use an ownerdrawn listbox. Then you will need to respond to two additional messages: OnMeasureItem() and OnDrawItem(). In OnMeasureItem, you will be asked to return the size of the item. That means you'll have to have figured out tall each item is going to be (since you'll use the width of the listbox for the width of the itme). You can use DrawText() with DT_WORDWRAP and DT_CALCRECT to figure out the size.

Then in DrawItem, you will need to draw the item with DrawText and specify DT_WORDWRAP.
Tommy HuiEngineer

Commented:
Oops. I meant DT_WORDBREAK and not DT_WORDWRAP.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial