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 » Question/Problem removing item from popup Collapse All
Subject Author Date
Offer Har Dec 23, 2008 - 10:28 AM

I have a popup menu with one level only (no sub-menu items)


I need to remove some of the items in it.


I tried to implement the CExtPopupBaseWnd::g_nMsgPrepareMenu message, and did this:



LRESULT CMyView::OnExtMenuPrepareMenu( WPARAM wParam, LPARAM lParam )
{
    lParam; // unused parameter

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

    CExtPopupMenuWnd * pPopup = pData->m_pPopup;
    ASSERT( pPopup != NULL );

    INT nToRemove = pPopup->ItemFindPosForCmdID(ID_TO_REMOVE);
    {
        if (-1!=nToRemove)
        {
            pPopup->ItemRemove(nToRemove);
        }
    }
    pData->m_bMenuChanged = true;
    return 1L;
}

But, I keep on getting - 1 in nToRemove. I’m sure the command is there.


Any ideas? am I doing something wrong?


Thanks,


Ron.


 


 

Technical Support Dec 24, 2008 - 8:36 AM

You can try using the following test version of the CMyView::OnExtMenuPrepareMenu method in debug session:

LRESULT CMyView::OnExtMenuPrepareMenu( 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 nIndex, nCount = pPopup->ItemGetCount();
            TRACE( "\r\n\r\nTRACING MENU COMMANDS (BEGIN) ====================\r\n" );
            for( nIndex = 0; nIndex < nCount; nIndex ++ )
            {
                        const CExtPopupMenuWnd::MENUITEMDATA & mi = pPopup->ItemGetInfo( nIndex );
                        UINT nCmdID = mi.GetCmdID();
                        TRACE3( "index = %d, ID = %d, equal to ID_TO_REMOVE = %s\r\n", nIndex, nCmdID, nCmdID ==  ID_TO_REMOVE ? "YES" : "NO" );
            }
            TRACE( "TRACING MENU COMMANDS (END) ====================\r\n\r\n\r\n" );
            return 1L;
}
The Output window in your Visual Studio will show the real content of your single level popup menu.

Offer Har Dec 24, 2008 - 2:34 PM

Thanks... that helped! had the wrong ID