主要出错在DrawItem函数中,代码如下:
ASSERT(lpDrawItemStruct->CtlType == ODT_COMBOBOX );
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
CRect rcItem(lpDrawItemStruct->rcItem);
CString csItem;
GetLBText(lpDrawItemStruct->itemID, csItem);
BOOL bSelected = (lpDrawItemStruct->itemState & ODS_SELECTED) ? TRUE : FALSE;
if ( bSelected )
{
dc.FillSolidRect(rcItem, RGB(238, 238, 238));
dc.SetTextColor(RGB(255, 0, 0));
}
else
{
dc.FillSolidRect(rcItem, RGB(218, 218, 218));
dc.SetTextColor(RGB(0, 255, 0));
}
dc.DrawText(csItem, csItem.GetLength(), rcItem, DT_LEFT | DT_SINGLELINE);
调试器显示就出错在这一句,但是不知为何
GetLBText(lpDrawItemStruct->itemID, csItem); ComboBox没有选中Has String属性?
|