如何在没有覆盖区域的情况下绘制CEdit控件? [英] How can I paint CEdit Control without uncovered area?
本文介绍了如何在没有覆盖区域的情况下绘制CEdit控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在对话框上有CDialg和CEdit控件.因此,要绘制CEdit控件而不对CEdit类进行子类化,我像这样使用CDialog::OnCtlColor
.
I have CDialg and CEdit Control on dialog. So, to paint CEdit control without sub-classing CEdit Class, I used CDialog::OnCtlColor
like this.
if( nCtlColor == CTLCOLOR_EDIT )
{
pDC->SetBkColor(RGB(200, 255, 200));
}
但是正如您所看到的,它省略了编辑控件的某些空白区域.
But as you can see, that it omits some margin area of edit control.
如何在CEdit的整个窗口Rect中绘制它?
How can I paint it whole window Rect of CEdit?
推荐答案
您还需要返回颜色正确的画笔,因此请在对话框构造函数中创建画笔
You also need to return a brush with the correct colour, so create a brush in the dialog constructor
#define EDITCOLOR RGB(200, 255, 200)
m_brEdit.CreateSolidBrush(EDITCOLOR);
并在OnCtlColor()
函数中,
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_EDIT)
{ pDC->SetBkColor(EDITCOLOR);
hbr = m_brEdit;
}
return hbr;
这篇关于如何在没有覆盖区域的情况下绘制CEdit控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文