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 » How curtomize dropdown menu for toolbar button Collapse All
Subject Author Date
Alexey Zbritsky Jan 31, 2005 - 11:49 AM

How can i customize (change items text, item count and so on) dropdown menu for toolbar button? Simple way to do this is redefine button’s menu according to program logic (in other handlers), but right way may be other...


can i handle down arrow press event and use other controls than menu, listbox or special dialog?

Technical Support Feb 1, 2005 - 9:01 AM

Dear Alexey,

You can construct Prof-UIS menus on-the-fly immediately before they appear on the screen. The CExtPopupMenuWnd object sends the CExtPopupMenuWnd::g_nMsgPrepareMenu registered windows message. You need to add the handler method to your dialog or frame window and modify the pop-up menu. The most convenient way is to use predefined command identifiers which you can find in the menu and replace them with other commands.

afx_msg LRESULT OnExtMenuPrepare(WPARAM wParam, LPARAM lParam);
 ON_REGISTERED_MESSAGE(
  CExtPopupMenuWnd::g_nMsgPrepareMenu,
  OnExtMenuPrepare
  )
LRESULT CDrawView::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 );
INT nReplacePos =
  pPopup->ItemFindPosForCmdID(ID_OLE_VERB_FIRST);
 if( nReplacePos >= 0 )
 {
   VERIFY( pPopup->ItemRemove(nReplacePos) );
   . . .
 }


Please note that the CExtPopupMenuWnd::ItemInsert() method inserts a pop-up menu item which is based on the command description in the Command Manager. The CExtPopupMenuWnd::ItemInsertCommand() method inserts a pop-up menu item which has no reference to the Command Manager.

If you only need to change text of a menu item, just get pointer to the CExtCmdItem object by calling g_CmdManager->CmdGetPtr(...) and set a new m_sMenuText property value.