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 » why CExtPopupMenuWnd::ItemEnabledSet() failure? Collapse All
Subject Author Date
Mofei Abudura Sep 19, 2006 - 12:41 AM

I created a pop-up menu, the default menuitem is gray, when i want to enable this menuitem with ItemEnabledSet,
it cause ASSERT fail.
source code are as follow:

POINT    position;
    GetCursorPos(&position);
    
    CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
    VERIFY(
        pPopup->LoadMenu(this->m_hWnd,
            IDR_MENU_KEYWAVE,
            true, // bPopupMenu
            true // bNoRefToCmdMngr
            )
        );
        
    VERIFY(
        pPopup->TrackPopupMenu(
            TPMX_OWNERDRAW_FIXED, // dwTrackFlags
            position.x,
            position.y
            )
        );
    pPopup->ItemBoldSet(1,true); // works fine

    pPopup->ItemEnabledSet(0); // ASSERT fail here

Mofei Abudura Sep 20, 2006 - 1:54 AM

I doubt your answer Technical Support .
what i need to do is move

  &nbsp&nbsp pPopup->ItemEnabledSet(0);

before to

VERIFY(
pPopup->TrackPopupMenu(
TPMX_OWNERDRAW_FIXED, // dwTrackFlags
position.x,
position.y
)
);

Technical Support Sep 20, 2006 - 8:52 AM

Any command item in a Prof-UIS menu by default is updated using the standard MFC’s command updating mechanism based on the CCmdUI class and command updating methods in your project’s classes. The CExtPopupMenuWnd class allows you to disable the command updating mechanism for some or for all menu items. If you construct a popup menu manually by inserting commands item by item, simply use the CExtPopupMenuWnd::ItemInsertCommand() method for inserting command items instead of CExtPopupMenuWnd::ItemInsert(). If you load the menu from resources using the CExtPopupMenuWnd::LoadMenu() method or build the CExtPopupMenuWnd-based menu tree from the MFC’s CMenu object using the CExtPopupMenuWnd::UpdateFromMenu() method, please note that both these methods have the bNoRefToCmdMngr parameter which uses false as the default value. If you specify true, all command items in the menu will not use the MFC’s command updating mechanism and you will heave to set the enabled/disabled command states manually when constructing the menu.

Technical Support Sep 19, 2006 - 7:00 AM

Please use any code that constructs the menu before invoking TrackPopupMenu().