一个ListBox的问题
我想实现一个Item可以占多行的效果,但不知怎样做。
现在我只能用DrawText实现换行(自画),但Listbox的其它特征都没了。
有哪位做过?能告诉我怎样实现吗?有例程也可以啊。
问题点数:50、回复次数:1Top
1 楼Earthdog(没有女朋友,郁闷!)回复于 2003-06-03 22:52:08 得分 50
这是MSDN上面的一个例子
// CMyListBox is my owner-drawn list box derived from CListBox. This
// example measures an item and sets the height of the item to twice the
// vertical extent of its text. The list box control was created with the
// following code:
// pmyListBox->Create(
// WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|
// LBS_SORT|LBS_MULTIPLESEL|LBS_OWNERDRAWVARIABLE,
// myRect, pParentWnd, 1);
//
void CMyListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
ASSERT(lpMeasureItemStruct->CtlType == ODT_LISTBOX);
LPCTSTR lpszText = (LPCTSTR) lpMeasureItemStruct->itemData;
ASSERT(lpszText != NULL);
CSize sz;
CDC* pDC = GetDC();
sz = pDC->GetTextExtent(lpszText);
ReleaseDC(pDC);
lpMeasureItemStruct->itemHeight = 2*sz.cy;
}
Top



