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 » changing font in page navigator Collapse All
Subject Author Date
Borremans Pierre Nov 19, 2009 - 3:19 AM

I want to change the font of the button in my page navigator. I use  SendMessage with the parameters : (WM_SETFONT, (WPARAM) hFontBold, 1), but nothing change.

could my problem come from the overdrive of the function OnQueryItemHeight  ?

Borremans Pierre Nov 24, 2009 - 6:50 AM

and how to change the background color for the selected page ?

Technical Support Nov 24, 2009 - 2:17 PM

The pages are windows inserted into the page navigator control. You should repaint the background of your page windows. For example, the TabbedBars sample application demonstrates the inherited background painting feature. You can check the check boxes on the third page in the one note tab page container and see the custom painted hurricane like background distributed between tab page dialogs, their child control and even entire main frame window.

Borremans Pierre Nov 25, 2009 - 4:11 AM

thanks and how to change the background color of the selected button ?

Technical Support Nov 25, 2009 - 12:49 PM

There is no background color. These buttons are painted by the currently installed paint manager. Some paint managers paint a gradient square. Other paint manager paint a bitmap based button skin. You can override the CExtPageNavigatorWnd::OnPageNavigatorDrawCollapsedItemsArea and CExtPageNavigatorWnd::OnPageNavigatorDrawExpandedItemsArea() virtual methods to redraw collapsed and expanded items.

Technical Support Nov 19, 2009 - 1:51 PM

The font of item captions is computed dynamically in the CExtPaintManager::PaintPageNavigatorCaptionText() virtual method:

void CExtPaintManager::PaintPageNavigatorCaptionText(
            CDC & dc,
            const CRect & rcItem,
            __EXT_MFC_SAFE_LPCTSTR strCaption,
            bool bPushed,
            bool bHover,
            bool bAllowInvertTextColor // = true
            )
{
            ASSERT_VALID( this );
            ASSERT( dc.GetSafeHdc() != NULL );
            if( ! dc.RectVisible(&rcItem) )
                        return;
LOGFONT lf = { sizeof(LOGFONT) };
            VERIFY( ::SystemParametersInfo( SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0 ) );
            __EXT_MFC_STRCPY( lf.lfFaceName, LF_FACESIZE, _T("Arial") );
            lf.lfWeight = FW_BOLD;
CFont font;
            font.CreateFontIndirect(&lf);
CFont * pOldFont = dc.SelectObject( &font );
COLORREF clrOldText =
                        dc.SetTextColor( 
                                    bPushed && bHover && bAllowInvertTextColor
                                                ? GetColor( COLOR_WINDOW, this ) 
                                                : GetColor( COLOR_BTNTEXT, this ) 
                                    );
            PaintPageNavigatorCaptionTextImpl( dc, rcItem, strCaption );
            dc.SetTextColor( clrOldText );
            dc.SelectObject( pOldFont );
}

void CExtPaintManagerOffice2007_Impl::PaintPageNavigatorCaptionText(
            CDC & dc,
            const CRect & rcItem,
            __EXT_MFC_SAFE_LPCTSTR strCaption,
            bool bPushed,
            bool bHover,
            bool bAllowInvertTextColor // = true
            )
{
            ASSERT_VALID( this );
            ASSERT( dc.GetSafeHdc() != NULL );
            if( ! dc.RectVisible(&rcItem) )
                        return;
            if( IsHighContrast() )
            {
                        CExtPaintManagerXP::PaintPageNavigatorCaptionText( dc, rcItem, strCaption, bPushed, bHover, bAllowInvertTextColor );
                        return;
            }
LOGFONT lf = { sizeof(LOGFONT) };
            VERIFY( ::SystemParametersInfo( SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0 ) );
            __EXT_MFC_STRCPY( lf.lfFaceName, LF_FACESIZE, _T("Arial") );
            lf.lfWeight = FW_BOLD;
CFont font;
            font.CreateFontIndirect(&lf);
CFont * pOldFont = dc.SelectObject( &font );
COLORREF clrOldText = dc.SetTextColor( bPushed ? m_arrClrPnItemText[0] : m_arrClrPnItemText[1] );
            PaintPageNavigatorCaptionTextImpl( dc, rcItem, strCaption );
            dc.SetTextColor( clrOldText );
            dc.SelectObject( pOldFont );
}

You should override this method in your paint manager class.

Borremans Pierre Nov 23, 2009 - 1:11 AM

thanks it works