改变控件的背景色
- //定义画刷
- CBrush m_greenBrush;
- //在构造函数中初始化
- m_greenBrush.CreateSolidBrush(RGB(210,230,190));
- //实现函数(改变FromView与static控件的背景色,更改其他方法类似,
- //在nCtrlColor处添加)
- HBRUSH CErrKbaseSearchView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
- if(nCtlColor == CTLCOLOR_DLG || nCtlColor == CTLCOLOR_STATIC)
- {
- pDC->SetBkColor(RGB(210,230,190));
- return m_greenBrush;
- }
- return hbr;
- }
不积跬步,无以至千里;不积小流,无以成江海。