如何更改 CMFCPropertyGridCtrl 中属性的颜色

问题描述 投票:0回答:2

如何更改

CMFCPropertyGridCtrl
中的属性(所有其他属性中的单个属性)的颜色?

c++ mfc mfc-feature-pack
2个回答
3
投票

您需要从

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 );
    }
};

0
投票

CMFCPropertyGridCtrl.SetCustomColors(...)
会做到的。

© www.soinside.com 2019 - 2024. All rights reserved.