|
|
|
|
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.
Subject |
Author |
Date |
|
Daniel Tiedy
|
Nov 10, 2003 - 5:34 PM
|
I’m looking for a way to modify menu items in the chevrons of the toolbars. What I am dealing with is there are toolbars listed in the Hide/Show and Customize Buttons section of the chevron menu that I do not want listed here, but I do want thenm listed when a user goes to the Customize dialog. How do I obtain a handle to this menu. Also I would be just as happy to have the Hide/Show and Customize Buttons menu removed all together and have the chevron menu only appear when there are buttons not visible. This would save interface space and the user can still hide and show toolbars by right clicking.
|
|
Technical Support
|
Nov 11, 2003 - 2:01 AM
|
Dear James,
It is possible to modify any Prof-UIS menus on-the-fly, including chevron menu. Prof-UIS sends the CExtControlBar::g_nMsgConstructPopupMenu registered message to the frame window. WPARAM is pointer to CExtControlBar::POPUP_MENU_EVENT_DATA structure which describes type of the CExtPopupMenuWnd object to be constructed dynamically. Frame window receives this message two times for each type of menu. First time, the menu object is empty and frame window may construct it starting from scratch. If frame window returns not-zero value - framework will use the constructed menu as is. In other case, when zero returned first time, frame window receives this message again, but popup menu already constructed and contains default items. Second message can be used to modify default menus. This technique used by the CMainFrame::OnConstructPopupMenuCB() method of the ProfStudio example. Implementation rules are not very complicated:
1) Please add this line to your frame window class definition:
afx_msg LRESULT OnConstructPopupMenuCB( WPARAM wParam, LPARAM lParam );
2) Then add this line to your frame message map:
ON_REGISTERED_MESSAGE( CExtControlBar::g_nMsgConstructPopupMenu, OnConstructPopupMenuCB )
3) your message handler should look like this:
LRESULT CMainFrame::OnConstructPopupMenuCB(
WPARAM wParam, LPARAM lParam )
{
ASSERT_VALID( this );
lParam;
CExtControlBar::POPUP_MENU_EVENT_DATA * p_pmed =
CExtControlBar::POPUP_MENU_EVENT_DATA::
FromWParam( wParam );
ASSERT( p_pmed != NULL );
ASSERT_VALID( p_pmed->m_pPopupMenuWnd );
ASSERT_VALID( p_pmed->m_pWndEventSrc );
if( p_pmed->m_nHelperNotificationType ==
CExtControlBar::POPUP_MENU_EVENT_DATA
::__PMED_??? )
{
if( p_pmed->m_bPostNotification )
return 0;
// construct your menu here
// (use p_pmed->m_pPopupMenuWnd object)
return (!0);
}
return 0;
} Type of the popup menu is described by p_pmed->m_nHelperNotificationType. Here is the list of all the menu types:
__PMED_DOCKBAR_CTX - dockbar context menu
__PMED_CONTROLBAR_CTX - any control bar context menu (client area)
__PMED_CONTROLBAR_NC_CTX - any control bar context menu (non-client area)
__PMED_STATUSBAR_CTX - statusbar context menu
__PMED_AUTOHIDESLIDER_CTX - autohide slider window context menu
__PMED_MINIFRAME_NC_CTX - miniframe context menu (non-client area)
__PMED_MDICLIAREA_CTX - mdi client area context nenu
__PMED_MDITABS_CTX - mdi-tabs window
__PMED_AUTOHIDETABS_CTX - autohide-tabs window
__PMED_DYNCBCTABS_CTX - dynamic control bar container tabs window
__PMED_CONTROLBAR_NCBTNMENU_TOP - control bar nc-area-menu-button - top level
__PMED_CONTROLBAR_NCBTNMENU_BARS - control bar nc-area-menu-button - control bars list
__PMED_CTXEXPBTN_TOP - content expand button(chevron) - top level
__PMED_CTXEXPBTN_APPEND - content expand button(chevron) - append to buttons list
__PMED_CTXEXPBTN_BARS - content expand button(chevron) - control bars list
To modify the chevron button behavior (its visibility) you should use your own button class derived from CExtBarContentExpandButton and override IsVisible() virtual method (return value should depend on item count in the CExtBarContentExpandButton::m_buttons array of buttons hidden in the chevron). To make toolbars use your chevron button you also should use your CExtToolControlBar -derived class and override the OnCreateBarRightBtn() method. It just should return new CExtBarContentExpandButton object. Please do not hesitate contact us if you will come across with any difficulties.
|
|
Daniel Tiedy
|
Nov 11, 2003 - 5:19 PM
|
Thanks for all your help. I was able to modify the menus and hide the Chevron menus when needed. However one of my reasons for hiding the Chevron menus was for real estate reasons, and I noticed the toolbars seem to be the same length regardless. See ftp://ftp.hash.com/pub/misc/ButtonSpace.jpg
|
|
Technical Support
|
Nov 13, 2003 - 1:42 AM
|
Dear Daniel,
We have coded "auto-hide" chevron buttons. It seems to us the following source code should fit your requirements:
class CMyRightBtn :
public CExtBarContentExpandButton
{
public:
CMyRightBtn(
CExtToolControlBar * pBar = NULL
) : CExtBarContentExpandButton( pBar )
{
}
virtual CSize CalculateLayout(
CDC & dc,
CSize sizePreCalc,
BOOL bHorz
)
{
if( GetStyle() & TBBS_HIDDEN )
return CSize( 0, 0 );
return CExtBarContentExpandButton::
CalculateLayout(
dc, sizePreCalc, bHorz );
}
void _AdjustVisibility()
{
if( m_buttons.GetSize() == 0 )
ModifyStyle( TBBS_HIDDEN );
else
ModifyStyle( 0, TBBS_HIDDEN );
}
};
class CMyToolControlBar : public CExtToolControlBar
{
public:
virtual CExtBarContentExpandButton *
OnCreateBarRightBtn()
{
return new CMyRightBtn( this );
}
CSize _CalcLayout(
DWORD dwMode, int nLength = -1 )
{
CExtBarContentExpandButton *
pRightButton = GetRightButton();
if( pRightButton == NULL )
{
VERIFY( InitContentExpandButton() );
pRightButton = GetRightButton();
ASSERT( pRightButton != NULL );
} // if( pRightButton == NULL )
_RecalcPositionsImpl();
CSize _sizeLayout =
CExtToolControlBar::_CalcLayout(
dwMode, nLength );
_RecalcPositionsImpl();
((CMyRightBtn *)pRightButton)->
_AdjustVisibility();
_sizeLayout =
CExtToolControlBar::_CalcLayout(
dwMode, nLength );
return _sizeLayout;
}
CSize CalcDynamicLayout(
int nLength, DWORD dwMode)
{
if( (nLength == -1)
&& !(dwMode & (LM_MRUWIDTH|LM_COMMIT))
&& (dwMode & (LM_HORZDOCK|LM_VERTDOCK))
)
return
CalcFixedLayout(
dwMode & LM_STRETCH,
dwMode & LM_HORZDOCK
);
ASSERT(
(dwMode&(LM_HORZ|LM_HORZDOCK))
||
(!(dwMode&LM_HORZDOCK))
);
return _CalcLayout( dwMode, nLength );
}
CSize CalcFixedLayout(
BOOL bStretch,
BOOL bHorz
)
{
DWORD dwMode = bStretch ? LM_STRETCH : 0;
dwMode |= bHorz ? LM_HORZ : 0;
ASSERT(
(dwMode&(LM_HORZ|LM_HORZDOCK))
||
(!(dwMode&LM_HORZDOCK))
);
return _CalcLayout( dwMode );
}
};
|
|