Thread: How to put a tick in a windows menu?

  1. #1
    Registered User
    Join Date
    Oct 2004

    How to put a tick in a windows menu?

    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

        POPUP "File"
            MENUITEM "Open",                        ID_MENU_OPEN
            MENUITEM "All Security",                ID_MENU_ALL
            MENUITEM "Custom Security",            	ID_MENU_CUSTOM
            MENUITEM "No Security",                 ID_MENU_NONE
            MENUITEM "Exit",                        ID_MENU_EXIT
    Now is the code im trying to get to work

    //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 */)
    // Modify menu and assert if failed
    if(!ModifyMenu(lMainSystemMenu, ID_MENU_ALL, MF_CHECKED, ID_MENU_ALL, "All" ))
    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

  2. #2
    Join Date
    Jan 2002
    Your ModifyMenu parameters seem to be incorrect - the third parameter should be a set of OR'd flags that determine both the action to be taken and whether your menu item is identified by position or identifier. See the remarks section for ModifyMenu for more details.

    A simpler approach would be to use CheckMenuItem, although you should be aware that SetMenuItemInfo should be preferred over either function.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  3. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  4. Delet Frequency in linked list
    By in forum C Programming
    Replies: 16
    Last Post: 12-13-2003, 02:05 AM
  5. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM