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 Tech Support » Changing Text of DynamicControlBar in document-state. Collapse All
Subject Author Date
Suhai Gyorgy Dec 23, 2005 - 4:06 AM

Hi!

I’d like to change the caption of my controlbars dynamically, as a response of a menucommand. SetWindowText works fine for all controlbars except for those in document-state. I haven’t found any method for setting __EBCT_DOCUMENT_CONTAINER_CAPTION, only for getting it (OnGetBarCaptionText()). I could work around the problem with the following code:

bool bVisible;
if (m_pwndMyBar->BarStateGet(&bVisible) == CExtDynamicControlBar::__EDBS_DOCUMENT) {
  m_pwndMyBar->BarStateSet(CExtDynamicControlBar::__EDBS_DOCKED, true);
  m_pwndMyBar->SetWindowText(strNewCaption);
  m_pwndMyBar->BarStateSet(CExtDynamicControlBar::__EDBS_DOCUMENT, bVisible);
}

, but this causes an ugly flickering. Isn’t there a better solution for this problem? Or maybe this is also solved in your new versions (we’re still using 2.43)?

Thank you for your help! Have a merry and restful holiday (as much as it is possible:))!
Chris.

Technical Support Dec 23, 2005 - 11:10 AM

The caption text computing mechanism for the control bar now works absolutely like as in 2.43. So, please use the following code:

 
m_pwndMyBar->SetWindowText( strNewCaption );
if ( m_pwndMyBar->BarStateGet() == CExtDynamicControlBar::__EDBS_DOCUMENT )
{ 
    HWND hWnd = m_pwndMyBar->OnQueryChildHWND();
    ASSERT( hWnd != NULL && ::IsWindow( hWnd ) );
    hWnd = ::GetParent( hWnd );
    ASSERT( hWnd != NULL && ::IsWindow( hWnd ) );
    CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
    ASSERT_VALID( pWnd );
    CMDIChildWnd * pFrame =
        STATIC_DOWNCAST( CMDIChildWnd, pWnd );
    pFrame->SetTitle( strNewCaption );
}

Suhai Gyorgy Jan 2, 2006 - 3:54 AM

Hi!

This does not work for me:( At the line "CMDIChildWnd * pFrame = STATIC_DOWNCAST( CMDIChildWnd, pWnd );" I get an assertion, because at that point pWnd points to my view, which is of CExtTabPageContainerWhidbeyWnd class that cannot be converted to CMDIChildWnd.
Which other class should I use to call SetTitle then?

Thank you: Chris

Technical Support Jan 2, 2006 - 10:22 AM

The solution we advised you works for MDI applications with the MDI tab window and dynamic resizable control bars. This approach cannot be used for SDI applications which use dynamic resizable control bars and the tab page container window as the main view window. Please use the following code instead:

m_pwndMyBar->SetWindowText( strNewCaption );
if ( m_pwndMyBar->BarStateGet() == CExtDynamicControlBar::__EDBS_DOCUMENT )
{ 
    HWND hWndBarChild = m_pwndMyBar->OnQueryChildHWND();
    ASSERT( hWndBarChild != NULL && ::IsWindow( hWndBarChild ) );
    HWND hWnd = ::GetParent( hWndBarChild );
    ASSERT( hWnd != NULL && ::IsWindow( hWnd ) );
    CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
    ASSERT_VALID( pWnd );
    CExtTabPageContainerWnd * pWndTPC =
        STATIC_DOWNCAST( CExtTabPageContainerWnd, pWnd );
    LONG nIndex = pWndTPC->PageFindByHWND( hWndBarChild );
    ASSERT( nIndex >= 0 );
    pWndTPC->PageTextSet( strNewCaption );
}