如何解决MFC CEdit-将背景画成一定长度
我想拥有一个CEdit控件,它的背景长度为一半,或者在其长度的任何其他部分。
我实现了以下代码
HBRUSH CMyView::OnCtlColor(CDC* pDC,CWnd* pWnd,UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
if (nCtlColor == CTLCOLOR_EDIT)
{
if (pWnd->GetDlgCtrlID() == IDC_MY_NORMAL_PERCENT_BOX)
{
// Set the text color to red
pDC->SetTextColor(RGB(255,0));
CRect rc;
// Get the client area of the edit control
m_CTV_Normal_Percent_Box_Ctrl.GetClientRect(&rc);
m_CTV_Normal_Percent_Box_Ctrl.ScreenToClient(&rc);
// Apply the device context to the client area of the edit control
pDC->Rectangle(0,rc.Width()/2,rc.Height());
// Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT);
// Return handle to our CBrush object
hbr = m_brush;
}
}
return hbr;
}
但是无法实现。有人可以帮忙吗?
这就是我想要得到的
这就是我得到的
谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。