刘华世的官方博客

C++语言 颜色对话框调用

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;
}
posted @ 2012-11-21 17:09  pythonschool  阅读(304)  评论(0编辑  收藏  举报
刘华世的官方博客