Hi all,
My program minimises to the SystemTray and i have created a menu that when i right click on the icon in the system tray it popsup. This works fine. Now what I want to do is when the user clicks on one of the options in the menu i want a tick to be put next to it. I have managed to do this using a normal menu on a window but no matter what I try I cannot get it working on the system tray menu. Can you spot what i am doing wrong?
First is my Menu found in Resource.rc
Code:
IDR_POPUP MENU
BEGIN
POPUP "File"
BEGIN
MENUITEM "Open", ID_MENU_OPEN
MENUITEM SEPARATOR
MENUITEM "All Security", ID_MENU_ALL
MENUITEM "Custom Security", ID_MENU_CUSTOM
MENUITEM "No Security", ID_MENU_NONE
MENUITEM SEPARATOR
MENUITEM "Exit", ID_MENU_EXIT
END
END
Now is the code im trying to get to work
Code:
//Get Menu associated with hwnd
HMENU lMainSystemMenu = LoadMenu(hwnd, MAKEINTRESOURCE(IDR_POPUP));
// HMENU lSystemTrayPopupMenu = GetSubMenu(lMainSystemMenu, 0); commented out due to also doesnt work
// check that both lMainSystemMenu and lSystemTrayPopupMenu are valid menus
if(!IsMenu(lMainSystemMenu) /* || !IsMenu(lSystemTrayPopupMenu */)
ASSERT(false);
// Modify menu and assert if failed
if(!ModifyMenu(lMainSystemMenu, ID_MENU_ALL, MF_CHECKED, ID_MENU_ALL, "All" ))
ASSERT(false);
DrawMenuBar(hwnd);
This code compiles fine and even runs without asserting however the item ID_MENU_ALL does not get checked.
You can see that there is a commented out HMENU called lSystemTrayPopupMenu. When that is uncommented and ModifyMenu uses that as its first parameter everything compiled fine but still remains unchecked.
Thanks for any help, this is driving me up the wall