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 » Disabling menu-entry of type TYPE_POPUP Collapse All
Subject Author Date
Suhai Gyorgy Mar 22, 2006 - 9:11 AM

Dear Support!

I’m trying to disable one of my menu-entries that has a submenu, so it is of type TYPE_POPUP. I understood from some previous thread that I need to disable all entries in that submenu as well before I could disable their "parent". So I put in the UpdateUI handlers of these submenu entries:

pCmdUI->Enable(bSomeCondition);

and in the handler of message CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel I put the following:

CExtPopupMenuWnd::MsgPrepareMenuData_t *pData =
reinterpret_cast<CExtPopupMenuWnd::MsgPrepareMenuData_t *>( wParam );
ASSERT( pData != NULL );
CExtPopupMenuWnd *pPopup = pData->m_pPopup;
ASSERT( pPopup != NULL );

CExtPopupMenuWnd *pSubPopup;
for (int i = 0; i < pPopup->ItemGetCount(); i++) {
pSubPopup = pPopup->ItemGetPopup(i);
if ( pSubPopup != NULL && pSubPopup->ItemFindPosForCmdID(ID_OF_ONE_SUBMENU_ENTRY) >= 0 )
pPopup->ItemEnabledSet(i, bSomeCondition);
}

In debug mode I can see the ItemEnabledSet is called with the parameters I need, still this "parent" is not disabled, even though all the submenu-entries are. Could you please advise?

I’m using v2.52 with VS2003.

Thank you:
Chris.

Technical Support Mar 22, 2006 - 12:11 PM

A pop-up submenu item becomes disabled automatically if the entire sub tree is disabled. Please check your CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel registered message handler has the following code at the beginning of the method:

CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
        reinterpret_cast
        < CExtPopupMenuWnd::MsgPrepareMenuData_t * >
        ( wParam );
    ASSERT( pData != NULL );
CExtPopupMenuWnd * pPopup = pData->m_pPopup;
    ASSERT( pPopup != NULL );
    pData->m_bMenuChanged = true;
To set m_bMenuChanged property to true is important, so please check this.

Suhai Gyorgy Mar 23, 2006 - 2:30 AM

It did not help:( At the end of my message handler I return 0; as LRESULT...Could that have any connection to this? I even tried to return 1; still no luck.

One more thing popped to my mind... those submenu entries are all commands to ControlBars, so their updater message handlers go like this:

MessageMap:
ON_UPDATE_COMMAND_UI_RANGE(ID_OF_FIRST_SUBENTRY, ID_OF_LAST_SUBENTRY, OnUpdateControlBarMenu)

Handler definition:
void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
{
if (!(pCmdUI->m_nID < ID_OF_FIRST_SUBENTRY || pCmdUI->m_nID > ID_OF_LAST_SUBENTRY || bSomeCondition))
pCmdUI->Enable(false);
else
CExtControlBar::DoFrameBarCheckUpdate( this, pCmdUI, false );
}

Any other suggestions? Thank you: Chris.

Technical Support Mar 23, 2006 - 11:18 AM

As we said in the previous message, a popup sub menu item will be always enabled if at least one menu command is enabled in the menu sub tree. So, do not try to disable the popup sub menu item -- just disable all the commands in the sub menu instead. Simply change you control bar command updating method depending on some condition and disable all the control bar commands.

Suhai Gyorgy Mar 24, 2006 - 3:18 AM

I’ve done just that... I’m sending you a sample project showing the problem.