我的对话框中有一个“只读”的编辑框,我在Dialog的OnCtlColor中用以下代码无法改变编辑框为白底黑字。(因为我在CWinApp的InitInstance()中调用了SetDialogBkColor(RGB(33,64,156),RGB(255,255,255));所以这里想改变编辑框)如果将编辑框设置成可编辑,则不用重载OnCtlColor(),编辑框也是白底黑字的。
各位能帮我解决一下吗?
为什么“只读”的编辑框会无法改变底色和字体颜色?HBRUSH CDlgMessage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{ HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (CTLCOLOR_EDIT == nCtlColor)
{
pDC->SetBkColor(RGB(255,255,255));
pDC->SetTextColor(RGB(0,0,0));
}
return hbr;}
各位能帮我解决一下吗?
为什么“只读”的编辑框会无法改变底色和字体颜色?HBRUSH CDlgMessage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{ HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (CTLCOLOR_EDIT == nCtlColor)
{
pDC->SetBkColor(RGB(255,255,255));
pDC->SetTextColor(RGB(0,0,0));
}
return hbr;}
if(nCtlColor == CRLCOLOR_EDIT)
{
hbr = 背景刷子;
}
return hbr;
谁能帮帮忙?
if (CTLCOLOR_EDIT == nCtlColor)
{
pDC->SetBkColor(RGB(255,255,255));
pDC->SetTextColor(RGB(0,0,0)); HBRUSH hbr = CreateSolidBrush(RGB(255,255,255));
return hbr;
}
// ^^^^^注意这里不是EDIT
{
// .....
}
A static control, or an edit control that is read-only or disabled, sends the WM_CTLCOLORSTATIC message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the static control.