重载DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)方法 其他属性的修改类似 void CUIText::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC); int iSave = pDC->SaveDC(); CString strText; CRect rtWin; GetClientRect(&rtWin); pDC->SetBkColor(COLOR); // 设置背景色 pDC->SetTextColor(m_txColor); // 设置文本颜色 GetWindowText(strText); // 获取文本 pDC->DrawText(strText,&rtWin,m_dwDrawFlag); // 重新绘制文本 pDC->RestoreDC(iSave); ReleaseDC(pDC); }

评论