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.
Subject |
Author |
Date |
|
Ian McIntosh
|
Mar 18, 2008 - 7:25 AM
|
Is it possible to set the color for a CExtButton?
|
|
Technical Support
|
Mar 19, 2008 - 6:53 AM
|
You can override the following method in your CExtButton -derived class: virtual CExtPaintManager * PmBridge_GetPM() const; This method should return an instance of the required paint manager. The following template class is very handy and implements the virtual method meant above: 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 should use the following button object: CExtPaintManagerCustomT < CExtButton > m_wndButton; And attach any required paint manager to it: m_wndButton.SetCustomPM( RUNTIME_CLASS(CExtPaintManager) );
|
|
Ian McIntosh
|
Mar 19, 2008 - 2:10 AM
|
I’m using mainly the Office 2007 themes, and it is the button color rather than text color I want to change.
If SetBkColor() doesn’t work, what should I use instead?
|
|
Technical Support
|
Mar 18, 2008 - 1:37 PM
|
Yes, you can do this using the following methods: SetTextColorDisabled
SetTextColorNormal
SetTextColorHover
SetTextColorPressed
SetBkColor Please note the SetBkColor() method works only for Office 2000/XP/2003 and Visual Studio 2005 themes. Otherwise it is useless because the buttons are based on bitmaps.
|
|