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 » Why to not open a global variable g_AllBars ? Collapse All
Subject Author Date
Buba Jul 18, 2002 - 10:15 PM


She is necessary for me for that what to touch all CExtControlBar. For example:

nCount = CExtControlBar::g_AllBars.GetSize();
for( i = 0; i < nCount; i++ )
{
CExtControlBar* pBar = CExtControlBar::g_AllBars.GetAt( i );
if( pBar->m_hWnd )                    // Ýòî íóæíî äëÿ áàðîâ â òåêóùåì çàêðûâàåìîì îêíå,
pBar->EnableWindow( bEnable ); // ýòîò áàð óæå çàêðûò
}

Best regards.
Mr. Buba

Sergiy Lavrynenko Jul 24, 2002 - 12:32 PM

Dear Mr. Buba

This static array of all CExtControlBar objects is for internal use only. Besides, I am going to remove it in one of the next versions at all.

To enumerate all control bars (docked, floating, visible, hidden, or any other you want) in any frame window, you should use CFrameWnd::listControlBars, which is the non-static public member of CFrameWnd.

// ENUMERATE ALL BARS IN A FRAME
POSITION pos =
pFrame->m_listControlBars.GetHeadPosition();
while( pos != NULL )
{
CControlBar * pTestBar = (CControlBar *)
pFrame->m_listControlBars.GetNext( pos );
ASSERT_VALID( pTestBar );
ASSERT_KINDOF( CControlBar, pTestBar );
if( pTestBar->IsDockBar() )
{
// this is an MFC’s internal object (CDockBar),
// which must be intact!!!
continue;
}

if( pTestBar->IsKindOf(
RUNTIME_CLASS(CStatusBar))
// or CExtStatusBar
)
{
// this is a status bar
CStatusBar * pStatusBar =
STATIC_DOWNCAST( CStatusBar, pTestBar );
// use pStatusBar as you wish
// ...
continue;
}

if( pTestBar->IsKindOf(
RUNTIME_CLASS(CExtControlBar))
)
{ // this is a Prof-UIS control bar

if(((CExtControlBar*)pTestBar)->IsFixedMode())
{ // this is a toolbar, or menu bar

if( pTestBar->IsKindOf(
RUNTIME_CLASS(CExtMenuControlBar))
)
{
// this is a menu bar
CExtMenuControlBar * pMenuBar =
STATIC_DOWNCAST(
CExtMenuControlBar, pTestBar );
// use pMenuBar as you wish
// ...
}
else if( pTestBar->IsKindOf(
RUNTIME_CLASS(CExtToolControlBar))
)
{
// this is a tool bar
CExtToolControlBar * pToolBar =
STATIC_DOWNCAST(
CExtToolControlBar, pTestBar );
// use pToolBar as you wish
// ...
}
else
{
// this is an other kind
// of non-resizable conrol bar,
// Prof-UIS does not have such bars
}
} // this is a toolbar or menu bar
else
{ // this is a resizable bar
CExtControlBar * pResizableBar =
STATIC_DOWNCAST(
CExtControlBar, pTestBar );
// use pResizableBar as you wish
// ...
} // this is a resizable bar
} // this is a Prof-UIS control bar
else
{
// this is a standard MFC’s control bar
// for example: CToolBar, CDialogBar
}
} // while( pos != NULL )