CMyListBox是CListBox的一个派生类,主要是用来实现每条记录可以自动换行的功能
为何以下重载的函数中,DrawText函数计算出的绘制文本所需的矩形的高度有时会不正确?
例如:本来两行就可绘制完的,结果计算出来要三行,最后一行是空白,通常这种情况发生在最后一行要满时,就会在后面再多一行空白行
void CMyListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) 
{
// TODO: Add your code to determine the size of specified item
CString str;
GetText(lpMeasureItemStruct->itemID,str); CRect rect;
this->GetWindowRect(&rect);        CDC *pdc=GetDC();
lpMeasureItemStruct->itemHeight=pdc->DrawText(str,&rect,DT_CALCRECT | DT_WORDBREAK | DT_EDITCONTROL);
    
}