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 » Is there a way to make popup menus update their state periodically? Collapse All
Subject Author Date
Offer Har Nov 13, 2008 - 9:34 AM

When I open a menu the OnUpdateXXX function are called for all the menu items.

Now the menu is display until the user selects a command or cancels it.

During this time, the state of the elements changes, and some commands in the displayed menu should become disabled, checked or unchecked.


As fas as I see, the OnUpdateXXX function are called only when the menu-item needs to be rendered - Can I force them to be called, with a timer or something like this?


Thanks.

Technical Support Nov 14, 2008 - 12:13 PM

The CExtPopupMenuWnd::_UpdateCmdUI() protected method does menu items updating using the CExtPopupMenuWnd::CExtPopupMenuCmdUI class. You can replace all the CExtPopupMenuWnd instances in your application with your CExtPopupMenuWnd-derived objects via handling the CExtPopupMenuWnd::g_nMsgInstantiatePopupMenu registered message. The WPARAM parameter of this message is pointer to the CExtPopupMenuWnd::INSTANTIATEPOPUPMENUNOTIFICATION data structure. The CExtPopupMenuWnd::INSTANTIATEPOPUPMENUNOTIFICATION::m_pCreatedPopupMenuInstance is pointer to CExtPopupMenuWnd object and it’s NULL value. You can instantiate your CExtPopupMenuWnd-based objects in this pointer. Please note, the CExtPopupMenuWnd::INSTANTIATEPOPUPMENUNOTIFICATION::m_pMenuRTC property specifies runtime class of required popup menu. You may not need to instantiate list box menus, undo-redo menus, color menus, date picker menus and any other specific menus. So, if your CExtPopupMenuWnd-derived objects will be instantiated and used everywhere in your application where you can see menu, then you can start timers in your menu windows and invoke the CExtPopupMenuWnd::_UpdateCmdUI() protected method for periodic updating of menu items.

We would like to tell you, that if menu is open several hours, then the user is stopped his work day and went into vocation. If some popup menu is opened, the UI of your application assumes that the user should select something in menu before continuing working on some current task. We are very surprised with this feature request.

Of course, we can add some new registered message like g_nMsgQueryMenuPeriodicUpdatingParameters and send it before each popup menu level will appear on the screen. This message will pass pointer to some data structure in WPARAM parameter. This data structure will contain information about how often the command updating for menu items should be invoked.

Technical Support Nov 14, 2008 - 5:16 AM

We can implement this feature. There is no problem to change the state of a menu item (enabled, checked or radio) on timer. And tt’s not difficult to invoke MFC’s command updating mechanism for menu items periodically. The only problem is to change the sizes of menu items when the popup menu is displayed and its menu tree layout is pre-computed. The CCmdUI::SetText() method can change the size of a particular menu item and, as a result, can change the size of a popup sub-menu item and affect the locations of nested menu levels. This requires more time to implement. But first of all, please provide more details about your task. Do you need to update the entire displayed menu tree periodically or only particular sub menus or items? What the new menu APIs related to this feature should be in your opinion?

Offer Har Nov 14, 2008 - 7:27 AM

What I need right now is an option to disable items, because the user can leave the popup menu open for hours... and during that time things change.


I think it will be a nice feature to change also radio-button and check status of elements, and eventual also text and icons, and even adding and removing items, but in general I think it’s less desirable to do the last, because the user might get confused if the menu sizes changes.


How exactly can I envoke the command updating of the menu?


Thanks,


Ron.