添加 ON_WM_CTLCOLOR() 消息
HBRUSH CDlgCmd::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何特性
if (nCtlColor == CTLCOLOR_DLG)
{
return m_brush;
}
if (nCtlColor == CTLCOLOR_EDIT || nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(220, 220, 220));
pDC->SetBkColor(RGB(30, 30, 30));
//pDC->SetBkMode(TRANSPARENT); // 这样设置 文字会闪烁重叠
hbr = (HBRUSH)m_brush;
}
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}
BOOL CDlgCmd::OnInitDialog()
m_brush.CreateSolidBrush(RGB(30, 30, 30)); // 设置画刷颜色
dlgCmd.h
CBrush m_brush;