How to disable a menu button
-
Hi, any idea on how to disable a menu button. What I mean is, consider internet explorer browser the menu consists of 'File', if you click on it a drop down menu appears, what api could I use to disable the close button. Kind Regards Caoimh
If you are using the MFC in your application, you can handle the ON_UPDATE_COMMAND_UI handler for your menu item (you can do this via Class wizard). Then its a matter of setting the state of your item
pCmdUI->Enable(isEnabled?TRUE:FALSE);
I Dream of Absolute Zero
-
Hi, any idea on how to disable a menu button. What I mean is, consider internet explorer browser the menu consists of 'File', if you click on it a drop down menu appears, what api could I use to disable the close button. Kind Regards Caoimh
If you aren't using MFC, then you can get the menu handle for the window (normally the top level window), and then get a handle for the sub-menu from there (they start at zero, of course!), and finally modify the state of a given item. APIs to check out are: HMENU GetMenu( HWND hWnd ); HMENU GetSubMenu( HMENU hMenu, int nSub ); BOOL SetMenuItemInfo( HMENU hMenu, UINT uItem, BOOL fByPos, LPMENUITEMINFO lpmii); That should take care of most things. Steve S
-
If you aren't using MFC, then you can get the menu handle for the window (normally the top level window), and then get a handle for the sub-menu from there (they start at zero, of course!), and finally modify the state of a given item. APIs to check out are: HMENU GetMenu( HWND hWnd ); HMENU GetSubMenu( HMENU hMenu, int nSub ); BOOL SetMenuItemInfo( HMENU hMenu, UINT uItem, BOOL fByPos, LPMENUITEMINFO lpmii); That should take care of most things. Steve S