pDC->SetBkColor(m_CurBackColor);
//选择刷子
pDC->SelectObject(&m_EdtBrush);
CRect rc;
GetClientRect(&rc);
ScreenToClient(&rc);
//绘制一个矩形
pDC->Rectangle(0, 0, rc.Width(), rc.Height());
//设置文本颜色
pDC->SetTextColor(RGB(0, 0, 0,));
//输出文本
pDC->TextOut(2, 2, m_str.GetBuffer(m_str.GetLength()));
}
2)重载虚拟函数OnChildNotify():
将OnChildNotify()函数的定义为如下形式:
BOOL CEditEx::OnChildNotify(UINT message, WPARAM wParam,LPARAM lParam, LRESULT* pLResult)
{
// We only want to handle WM_CTLCOLOREDIT messages - 32 bit only
//如果消息为WM_CTLCOLOREDIT,则返回基类的OnChildNotify函数
if (message != WM_CTLCOLOREDIT)
{
return CEdit::OnChildNotify(message, wParam, lParam, pLResult);
}