Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Main menu in a UI (Read 2805 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Main menu in a UI

I'm a little confused how I should be using menu_manager for a main menu in a UI.
I'm wondering if I should be using static void menu_manager::win32_build_menu(HMENU menu,menu_node * parent,int base_id,int max_id); but that creates a popup menu, I'm not sure what I should do with that or when I would call it.
I got it to work by just calling win32_build_menu() and calling SetMenu() with the resulting HMENU.  If thats a good way, is it a bad idea to just call menu_manager::create() on init, and service_release() it on shutdown?
If I don't do that, is there a chance the menu_node ids will change if I release it before I get a WM_COMMAND, it says releasing the menu_manager releases nodes, so I'm guessing it's possible?

 

Main menu in a UI

Reply #1
Quote
If I don't do that, is there a chance the menu_node ids will change if I release it before I get a WM_COMMAND, it says releasing the menu_manager releases nodes, so I'm guessing it's possible?[a href="index.php?act=findpost&pid=328177"][{POST_SNAPBACK}][/a]

No, once initialized the IDs will stay the same, and the menu nodes will not reflect any changes made to the menu after initialisation of the menu_manager instance that owns them, whether this changes are made by the user (rearranging the menu) or by the program (greying out commands, toggling checkmarks). In short it is a bad idea to use a single menu_manager instance and initialize it once.

The preferred way is to refresh the contents of the submenus when they are opened (detectable through WM_INITMENUPOPUP).