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 » CExtPopupMenuWnd::UpdateFromMenu Collapse All
Subject Author Date
Daniel Tiedy Nov 25, 2003 - 4:52 PM

Is there a way to use CExtPopupMenuWnd::UpdateFromMenu and have all menu states (Enabled/Disabled) stay as they were in the CMenu class when you call TrackPopupMenu. My software currently has an extensive mechanism set up for enabling and disabling menu items using the CMenu class. Before the menu is displayed I want to convert it to CExtPopupMenuWnd and add some more menu items to it. It all works great except it is expecting CmdUI’s for the commands and it is disabling the menu items. I guess what I am looking for is a way to force enable any command that was enabled in the original CMenu class or SUb Window of the CMenu class when it was passed into UpdateFromMenu.

Technical Support Nov 26, 2003 - 6:57 AM

Dear Daniel,

By default the Prof-UIS popup menu uses MFC’s command updating mechanism. Any command items inserted to the Prof-UIS popup menu by invoking CExtPopupMenuWnd::LoadMenu() or CExtPopupMenuWnd::UpdateFromMenu() should have command descriptions registered in the command manager. These command items are auto-updated via MFC’s CCmdUI-based calls.

You can also insert command items to the Prof-UIS menu without the command manager by invoking CExtPopupMenuWnd::ItemInsertCommand(). It is possible to disable the command updating if you specify the TPMX_NO_CMD_UI flag in CExtPopupMenuWnd::TrackPopupMenu().

The recursive algorithm of constructing CExtPopupMenuWnd from Win32’s HMENU handle "as is" is not included to the library, but it can be easily coded:
1) use GetMenuItemCount() before the loop that invokes GetMenuItemInfo() for each item and retrieve Win32’s MENUITEMINFO data structure
2) if the fType field of MENUITEMINFO has the MFT_SEPARATOR flag set on, you should insert a separator to the CExtPopupMenuWnd object
3) if the hSubMenu field of MENUITEMINFO is not NULL, you should insert the submenu and make a recursive call of this function
4) the wID field of MENUITEMINFO is a command identifier and you should use it in CExtPopupMenuWnd::ItemInsertCommand()

To setup the properties of a command item, you should get a reference to the CExtPopupMenuWnd::MENUITEMDATA object first. It can be performed by invoking the CExtPopupMenuWnd::ItemGetInfo() method. The nPos parameter of ItemGetInfo() is an index of the inserted command. MENUITEMDATA has two methods: Check(bool) and Radio(bool).