Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » How can i set the backgroundcolor and the textcolor for grid headers ? Collapse All
Subject Author Date
Ulrich Heinicke Aug 21, 2007 - 1:09 AM

Hi,
i don’t want to display the grid contents according to the current theme (like SimpleGrid), i also want to have the header background and the header text displayed according to the current theme. So how can i change the colors?

Thanks
Ulrich

Ulrich Heinicke Aug 21, 2007 - 8:56 AM

Thanks

Ulrich

Technical Support Aug 21, 2007 - 7:10 AM

It is possible to use different paint managers in Prof-UIS classes instead of using one globally installed paint manager by default. This means you should use a global paint manager but for the grid window use the CExtPaintManagerNativeXP paint manager which provides native Windows look on Windows Vista, XP and older versions. You should use the following template class with the grid class:

template < class _BT > 
class CExtPaintManagerCustomT : public _BT
{
public:
    CExtPaintManagerCustomT(
        CExtPaintManager * pCustomPM = NULL 
        )
        : m_pCustomPM( NULL )
    {
        SetCustomPM( pCustomPM );
    }
    ˜CExtPaintManagerCustomT()
    {
        if( m_pCustomPM != NULL )
            delete m_pCustomPM;
        m_pCustomPM = NULL;
    }
    CExtPaintManager * GetCustomPM() const
    {
        return m_pCustomPM;
    }
    bool SetCustomPM( 
        CExtPaintManager * pCustomPM = NULL 
        )
    {
        if( m_pCustomPM != NULL )
        {
            if( pCustomPM == m_pCustomPM )
                return false;
            if( m_pCustomPM != NULL )
            {
                delete m_pCustomPM;
                m_pCustomPM = NULL;
            }
        }
        if( pCustomPM == NULL )
        {
            m_pCustomPM = new __DEFAULT_PAINT_MANAGER_CLASS;
            if(    ! m_pCustomPM->IsKindOf( RUNTIME_CLASS( CExtPaintManager ) ) )
            {
                ASSERT( FALSE );
                return false;
            }
        }
        else
        {
            m_pCustomPM = pCustomPM;
        }
        m_pCustomPM->SyncSysColors();
        m_pCustomPM->InitTranslatedColors();
        m_pCustomPM->InitHelperBrushes();
        return true;
    }
    bool SetCustomPM(
        CRuntimeClass * pRTCCustomPM
        )
    {
        if( pRTCCustomPM == NULL )
            return SetCustomPM( (CExtPaintManager *)NULL );
        CObject * pObj = pRTCCustomPM->CreateObject();
        if( pObj == NULL )
        {
            ASSERT( FALSE );
            return false;
        }
        ASSERT_VALID( pObj );
        CExtPaintManager * pPaintManager = DYNAMIC_DOWNCAST( CExtPaintManager, pObj );
        if( pPaintManager == NULL )
        {
            delete pObj;
            ASSERT( FALSE );
            return false;
        }
        return SetCustomPM( pPaintManager );
    }
    virtual CExtPaintManager * PmBridge_GetPM() const
    {
        CExtPaintManager * pPM = GetCustomPM();
        if( pPM != NULL )
            return pPM;
        else
            return _BT::PmBridge_GetPM();
    }
protected:
    CExtPaintManager * m_pCustomPM;
};
So you can use the CExtPaintManagerCustomT < CExtGridWnd > template type instead of the CExtGridWnd class type and then assign the paint manager to the grid window using the following code:
CExtPaintManagerCustomT < CExtGridWnd > m_wndGrid;
. . .
m_wndGrid.SetCustomPM( RUNTIME_CLASS( CExtPaintManagerXXXX ) );