vc 设置文本编辑框的背景颜色??
这是我的代码HBRUSHCMmDlg::OnCtlColor(CDC*pDC,CWnd*pWnd,UINTnCtlColor){HBRUSHhbr=CDialog::On...
这是我的代码
HBRUSH CMmDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
//case CTLCOLOR_EDIT:
//case CTLCOLOR_MSGBOX://假设控件是文本框或者消息框,则进入下一个switch
switch (pWnd->GetDlgCtrlID())//对某一个特定控件进行判断
{
// first CEdit control ID
case IDC_INPUTSTATE: // 输入测试
// here
if(m_inputstate=="pass")
{
pDC->SetBkColor(m_greencolor); // change the background
// color [background colour
// of the text ONLY]
pDC->SetTextColor(m_textcolor); // change the text color
hbr = (HBRUSH) m_bluebrush; // apply the blue brush
break;
}
if(m_inputstate=="fail")
{
pDC->SetBkColor(m_redcolor); // change the background
// color [background colour
// of the text ONLY]
pDC->SetTextColor(m_textcolor); // change the text color
hbr = (HBRUSH) m_bluebrush; // apply the blue brush
break;
}
为什么当结果是fail是出来的背景颜色是这样的??
只有一半是红的??我要他全部是红的啊 展开
HBRUSH CMmDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
//case CTLCOLOR_EDIT:
//case CTLCOLOR_MSGBOX://假设控件是文本框或者消息框,则进入下一个switch
switch (pWnd->GetDlgCtrlID())//对某一个特定控件进行判断
{
// first CEdit control ID
case IDC_INPUTSTATE: // 输入测试
// here
if(m_inputstate=="pass")
{
pDC->SetBkColor(m_greencolor); // change the background
// color [background colour
// of the text ONLY]
pDC->SetTextColor(m_textcolor); // change the text color
hbr = (HBRUSH) m_bluebrush; // apply the blue brush
break;
}
if(m_inputstate=="fail")
{
pDC->SetBkColor(m_redcolor); // change the background
// color [background colour
// of the text ONLY]
pDC->SetTextColor(m_textcolor); // change the text color
hbr = (HBRUSH) m_bluebrush; // apply the blue brush
break;
}
为什么当结果是fail是出来的背景颜色是这样的??
只有一半是红的??我要他全部是红的啊 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询