I have menu in my resource file, but I want for parts of menu (popups) to be visible and accessible only if user is allowed to see (or for example, if the variable is true). How to do it?
Thanks for all help!
Printable View
I have menu in my resource file, but I want for parts of menu (popups) to be visible and accessible only if user is allowed to see (or for example, if the variable is true). How to do it?
Thanks for all help!
You can use the following functions to hide and show windows:
Code:ShowWindow(hwnd,SW_SHOW); // show a window
ShowWindow(hwnd,SW_HIDE); // hide a window
I used EnableMenu(), ModifyMenu() and DeleteMenu() to do this.
Hooked a function to the dlgs init / create. Created the menu in full in the resource editor. Sent in the users access level and removed menu items based on that.
Watch the by_position flag as an items position changes as you add / remove items.
Thanks - i made it work like this..:
Code:HMENU hMenu = GetMenu(hwnd);
EnableMenuItem(hMenu, (UINT)MAKEINTRESOURCE(IDC_RESOURCE), MF_DISABLED | MF_GRAYED);
You may also be interested in the WM_MENUSELECT notification. This is posted when a menu is selected, enabling you to grey out menu items as needed.