问题描述
我想拥有一个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 (将#修改为@)