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 » How can I get the active control bar from the main frame? Collapse All
Subject Author Date
Daisy Peterson May 7, 2008 - 11:56 AM

Is there a way of querying the main frame for the active control bar?  I need to forward some messages to the active control bar instead of the t an active MDI window.


 Kevin Eshbach

Technical Support May 7, 2008 - 2:57 PM

The active control bar is a term specific to MFC/Prof-UIS. It has not to do with the GetActiveWindow() Win32 API. The active control bar contains a focused window. You can get a pointer to the active control bar in this way:

CExtControlBar * GetActiveControlBar()
{
HWND hWnd = ::GetFocus();
      for( ; hWnd != NULL; hWnd = ::GetParent( hWnd ) )
      {
            if( ( ::GetWindowLong( hWnd, GWL_STYLE ) & WS_CHILD ) == 0 )
                  break;
            CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
            if( pWnd == NULL )
                  continue;
            CExtControlBar * pBar = DYNAMIC_DOWNCAST( CExtControlBar, pWnd );
            if( pBar != NULL )
                  return pBar;
      }
      return false;
}
This function can return a pointer to a CExtToolControlBar object if an editor/combo box control attached to some of its buttons and the user is editing text in it. This function can also return a pointer to a CExtPanelControlBar object if some window inside is focused.