Change the property of a menu
-
I am new in Visual C++. I created MDI application, and I want to disable some menu for certain function. For example, I want to disable menu with ID_MENU00 ID, when doDisableMenu() is invoked void doDisableMenu() { CMenu menu; menu.EnableMenuItem(ID_MENU00, MF_GRAYED); } but the result is an error of 'debug assertion failed' what should I do to disable a menu? thank you in advance
-
I am new in Visual C++. I created MDI application, and I want to disable some menu for certain function. For example, I want to disable menu with ID_MENU00 ID, when doDisableMenu() is invoked void doDisableMenu() { CMenu menu; menu.EnableMenuItem(ID_MENU00, MF_GRAYED); } but the result is an error of 'debug assertion failed' what should I do to disable a menu? thank you in advance
It doesn't work that way. When you have a menu item selected in the IDE, there are two messages you can catch. One is the click event, the other is called just before a menu item is shown. You keep a bool in your app to tell you if a menu item is disabled, and in that method, you take the menu item ( which is passed in from memory, as a pointer ), and you set if it's enabled or not using that boolean value. The same goes for check marks, etc. Any change to a menu items state happens in this event handler. Christian Graus - Microsoft MVP - C++
-
I am new in Visual C++. I created MDI application, and I want to disable some menu for certain function. For example, I want to disable menu with ID_MENU00 ID, when doDisableMenu() is invoked void doDisableMenu() { CMenu menu; menu.EnableMenuItem(ID_MENU00, MF_GRAYED); } but the result is an error of 'debug assertion failed' what should I do to disable a menu? thank you in advance
houari_id wrote: I want to disable some menu for certain function The preferred method for this is in the
ON_UPDATE_COMMAND_UI()
handler.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown