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 » Bug in WidthFromContent function Collapse All
Subject Author Date
Ralph Stadie May 11, 2010 - 8:10 AM

Hi,


There seems to be a bug in the way that the WidthFromContent function of CExtStatusBar behaves for certain themes on Windows 7 (and presumably Vista).


For example, if I run the standard ZoomScrollBar sample and select the VS2005 theme, the text in the status pane is truncated, however if I select one of the newer themes, such as Office 2007, then it’s ok.  Loosely, I’ve determined that only appears to work correctly for the Office 2007 and Office 2010 themes and for all the rest the text is truncated.


I’ve only noticed this behaviour on Windows 7, as it seemed to work fine on Windows XP (I can’t confirm what it’s like on Vista).


It’s not a serious issue as the workaround is to select one of the newer Office themes, but I thought I’d point it out in case anyone can offer up a simple solution to fix it.


Cheers,


Ralph

Technical Support May 11, 2010 - 12:55 PM

Thank you for reporting this issue. To fix it please update the source code for the following method:

void CExtStatusControlBar::WidthFromContent( int nIndex )
{
            ASSERT_VALID( this );
            ASSERT((nIndex >= 0 && nIndex < m_nCount) || m_nCount == 0);
_STATUSBAR_PANE_ * pPane = GetPanePtr( nIndex );
            ASSERT( pPane != NULL );
            if( pPane == NULL )
                        return;
CRect rcText(0,0,0,0);
            if( !pPane->strText.IsEmpty() )
            {
                        HFONT hFont = (HFONT)PmBridge_GetPM()->m_FontNormal.GetSafeHandle();
                        CClientDC dcScreen( NULL );
                        HGDIOBJ hOldFont = NULL;
                        if( hFont != NULL )
                                    hOldFont = dcScreen.SelectObject( hFont );
                        dcScreen.DrawText(
                                    pPane->strText,
                                    pPane->strText.GetLength(),
                                    &rcText,
                                    GetPaneDrawTextFlags( nIndex ) | DT_CALCRECT
                                    );
                        if( hOldFont != NULL )
                                    dcScreen.SelectObject( hOldFont );
            } // if( !pPane->strText.IsEmpty() )
CStatusBarCtrl & _ctrl = GetStatusBarCtrl();
HICON hIcon = (HICON)
                        _ctrl.SendMessage(
                                    SB_GETICON,
                                    WPARAM(nIndex)
                                    );
            // ICON 2.53
CSize szIcon = CSize(0,0);
//          if( hIcon != NULL )
//                      szIcon = CExtCmdIcon::stat_GetIconSize( hIcon );
            if( hIcon != NULL )
            {
                        CExtCmdIcon _icon;
                        _icon.AssignFromHICON( hIcon, false );
                        szIcon = _icon.GetSize();
            }
            SetPaneWidth( 
                        nIndex,
                        szIcon.cx + rcText.Width() + 2
                        );
            RepositionControls();
}

Ralph Stadie May 12, 2010 - 2:46 AM

Thanks - that did the trick!