如何设置Formview上各控件的颜色?
我参考了VC技术内幕
我的解决办法是:
在视图中添加:
HBRUSH CMyView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetBkColor(RGB(130,220,90));
return m_hRedBrush;
}
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return hbr;
}
在::OnInitialUpdate()下定义
m_hRedBrush=::CreateSolidBrush(RGB(190,210,190));
并且定义:
HBRUSH m_hRedBrush;
和
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
可这种方法有时可行,有时不可行
请问这是为什麽??
另请问还有没有其它或更好的办法?