WM_CTLCOLOR事件

HBRUSH CFontDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    
    // TODO: Change any attributes of the DC here
    if(nCtlColor == CTLCOLOR_EDIT) //判断是否为编辑框控件
        pDC->SetBkColor(m_Color); //设置文本背景颜色
        //pDC->SetTextColor(m_Color); //设置文本前景颜色

    // TODO: Return a different brush if the default is not desired
    return hbr;
}

相关文章: