15,979
社区成员
发帖
与我相关
我的任务
分享
void CMulitLineComBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if(lpDrawItemStruct->CtlType==ODT_COMBOBOX)
{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
CRect rcClient = lpDrawItemStruct->rcItem;
UINT state = lpDrawItemStruct->itemState;
CBrush br;
if(state&ODS_SELECTED)
{
br.CreateSolidBrush(RGB(51,153,255));
}
else
{
br.CreateSolidBrush(RGB(255,255,128));
}
dc.FillRect(&rcClient,&br);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(RGB(255,0,255));
//如果不是空项
if(lpDrawItemStruct->itemID!=(UINT)-1)
{
UINT id = lpDrawItemStruct->itemID;
CString strText;
GetLBText(id,strText);
rcClient.DeflateRect(1,1);
dc.DrawText(strText, strText.GetLength(),&lpDrawItemStruct->rcItem, DT_WORDBREAK);
}
dc.Detach();
}
}
void CMulitLineComBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
if( (lpMeasureItemStruct->CtlType==ODT_COMBOBOX)&&
(lpMeasureItemStruct->itemID!=(UINT)-1))
{
CString strText;
GetLBText(lpMeasureItemStruct->itemID,strText);
CRect rect(0,0,100,100);
CDC* pDC = GetDC();
lpMeasureItemStruct->itemHeight = pDC->DrawText(strText, -1, rect, DT_WORDBREAK | DT_CALCRECT);
ReleaseDC(pDC);
}
}
不过 选择到 edit 后 多行怎么办?