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 to set caption's font color of a CExtControlBar Collapse All
Subject Author Date
Martin Baumgaertner Aug 17, 2007 - 8:48 AM

Hello,

how can I change the font color of the caption in a CExtContolBar?

Thanks in advance!

Martin

Martin Baumgaertner Aug 22, 2007 - 2:34 AM

Thank you for your answer!

Is there a similar approach to change the background color of that "caption"?

Martin

Technical Support Aug 22, 2007 - 12:41 PM

The following code paints the caption background:

            CExtPaintManager::PAINTGRIPPERDATA _pgd(
                  this,
                  rcGrip,
                  rcText,
                  IsBarWindowActive(),
                  false,
                  bHorz && !bGripperAtTop,
                  !bFixedMode,
                  sCaption.IsEmpty() ? LPCTSTR( NULL ) : sCaption,
                  ( (g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0 ) ? true : false
                  );
            PmBridge_GetPM()->PaintGripper( *pDC, _pgd );
The rcGrip rectangle specifies the caption location for painting. So, you can replace the code above with yours.

Technical Support Aug 18, 2007 - 6:34 AM

We did not implement the font color option for the control bar’s caption because it is painted by the paint manager and each theme can have either a light string and a dark background or vice versa. So, generally the same font color can be well readable under one theme and bad looking under some other one.

If you need a custom color, you should override the CExtControlBar::DoPaintNC() virtual method. Your method should be similar to the original one but you should modify the following part of code at the end of this method:

            CExtSafeString sCaption;
            OnGetBarCaptionText( __EBCT_SINGLE_CAPTION_DOCKED, sCaption );
            CRgn rgnExclude;
            if( rgnExclude.CreateRectRgnIndirect( &rcGrip ) )
                  pDC->SelectClipRgn( &rgnExclude );
            CExtPaintManager::PAINTGRIPPERDATA _pgd(
                  this,
                  rcGrip,
                  rcText,
                  IsBarWindowActive(),
                  false,
                  bHorz && !bGripperAtTop,
                  !bFixedMode,
                  sCaption.IsEmpty() ? LPCTSTR( NULL ) : sCaption,
                  ( (g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0 ) ? true : false
                  );
            PmBridge_GetPM()->PaintGripper( *pDC, _pgd );
            NcButtons_Paint( *pDC );
            pDC->SelectClipRgn( NULL );
The PmBridge_GetPM()->PaintGripper() invokes the paint manager to draw the control bar’s caption depending on the current theme. The pgd data structure includes all the caption parameters for painting. The rcText variable contains a rectangle for painting the caption text. The sCaption variable contains the caption text itself. So, you should construct the pgd data structure using an empty string instead sCaption. This will not give the paint manager any chance to draw the default looking caption text. After the PmBridge_GetPM()->PaintGripper() code is invoked, you should draw the custom caption text using the PmBridge_GetPM()->m_FontNormal font and a custom font color.