Enabling/Disabling Menu Items
-
I've used the app wizard (.NET) to create a basic single view app, w/o doc-view architecture. I've added a few things to the file menu using the resource editor (new, load, save, etc..) and added message handlers to the main frame using the wizard. I have no problem checking any of the menu items using "GetMenu()->CheckMenuItem()" but i can't seem to disable any of the menu items "GetMenu()->EnableMenuItem()" I have tried using the sub-menu, and the main menu, and I have tried BYCOMMAND and BYPOSITION but I can't get it to work. I also can't get it to default as disabled using the resource editor. Is there something I'm forgetting? I'd appreciate any suggestions or comments.
-
I've used the app wizard (.NET) to create a basic single view app, w/o doc-view architecture. I've added a few things to the file menu using the resource editor (new, load, save, etc..) and added message handlers to the main frame using the wizard. I have no problem checking any of the menu items using "GetMenu()->CheckMenuItem()" but i can't seem to disable any of the menu items "GetMenu()->EnableMenuItem()" I have tried using the sub-menu, and the main menu, and I have tried BYCOMMAND and BYPOSITION but I can't get it to work. I also can't get it to default as disabled using the resource editor. Is there something I'm forgetting? I'd appreciate any suggestions or comments.
You should add OnUpdate commands to the message map. For example if you have a menu item titled "New" that has OnNew(). You'd have OnUpdateNew(CCmdUI *pCmdUI) { pCmdUI->Enable(FALSE); // disables menu item } Thats the easiest way to do it. Never tried it with GetMenu() so I can't help with that.
-
I've used the app wizard (.NET) to create a basic single view app, w/o doc-view architecture. I've added a few things to the file menu using the resource editor (new, load, save, etc..) and added message handlers to the main frame using the wizard. I have no problem checking any of the menu items using "GetMenu()->CheckMenuItem()" but i can't seem to disable any of the menu items "GetMenu()->EnableMenuItem()" I have tried using the sub-menu, and the main menu, and I have tried BYCOMMAND and BYPOSITION but I can't get it to work. I also can't get it to default as disabled using the resource editor. Is there something I'm forgetting? I'd appreciate any suggestions or comments.
Use the FAQ, Luke 7.1 In my MFC program, I'm trying to disable a menu item with EnableMenuItem(), but it doesn't have any effect on the menu. Why?[^] --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.