If you need to change only popup menu items, simply handle the CExtPopupMenuWnd::g_nMsgPrepareMenu
registered windows message in your main frame window:
afx_msg LRESULT OnExtMenuPrepare(WPARAM wParam, LPARAM lParam);
ON_REGISTERED_MESSAGE(
CExtPopupMenuWnd::g_nMsgPrepareMenu,
OnExtMenuPrepare
)
LRESULT CMainFrame::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam)
{
lParam;
CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
reinterpret_cast
< CExtPopupMenuWnd::MsgPrepareMenuData_t * >
( wParam );
ASSERT( pData != NULL );
CExtPopupMenuWnd * pPopup = pData->m_pPopup;
ASSERT( pPopup != NULL );
// MODIFY pPopup MENU HERE
return 1;
}
You can insert some items with pre-defined command identifiers into your menu resource. This will allow the
CMainFrame::OnExtMenuPrepare()
method to find them and replace with other needed menu items:
INT nItemPos = pPopup->ItemFindPosForCmdID( ID_WELL_KNOWN_MENU_ITEM );
if( nItemPos > 0 )
{
pPopup->ItemRemove( nItemPos );
pPopup->ItemInsert( . . . );
. . .
}
It is also possible to rebuild the top level of the menu bar. The menu bar (
CExtMenuControlBar)
is based on a toolbar (
CExtToolControlBar).
The
CExtMenuControlBar::UpdateMenuBar()
method invokes an algorithm that rebuilds the menu bar’s toolbar buttons. You can implement your own algorithm of filling the menu bar with buttons (
CExtBarButton).
Create your own
CExtMenuControlBar
-derived class and override the
CExtMenuControlBar::_UpdateMenuBar()
internal virtual method. Your method can be either based on the original method (you only embed needed buttons) or completely rebuild an array of buttons in your own manner. All the commands inside the menus attached to the menu bar buttons should be registered in the command manager. The top level buttons in the menu bar also have their unique command identifiers and should be allocated exactly like it is done in the
CExtMenuControlBar::_UpdateMenuBar()
method.
We fixed the search feature available in our forums, thank you for the bug report.