如何更改
CMFCPropertyGridCtrl
中的属性(所有其他属性中的单个属性)的颜色?
CMFCPropertyGridCtrl
类派生一个类,并重写 CMFCPropertyGridCtrl::OnDrawProperty
方法。这允许您在调用默认实现之前根据自己的喜好更改设备上下文:
class CMFCMyPropertyGridCtrl : public CMFCPropertyGridCtrl {
public:
virtual int OnDrawProperty( CDC * pDC, CMFCPropertyGridProperty* pProp ) const {
// Implement check to see, if this is the property we are looking for
// If it is, set an appropriate text color
pDC->SetTextColor( RGB( 0xff, 0x0, 0xff ) );
// Call the default implementation to perform rendering
return CMFCPropertyGridCtrl::OnDrawProperty( pDC, pProp );
}
};
CMFCPropertyGridCtrl.SetCustomColors(...)
会做到的。