Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Why can't I toggle menu?

Why can't I toggle menu?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pony
    wrote on last edited by
    #1

    Hello, Why can't I toggle menu? I have system tray menu that I want to toggle the 3rd menu item. But the problem is it doesn't toggle when I click it. Help me, please... ON_COMMAND(ID_FLOAT, OnFloat) void CMainFrame::OnFloat() { CMenu* mmenu = GetMenu(); CMenu* submenu = mmenu->GetSubMenu(2); UINT state = submenu->GetMenuState(ID_FLOAT, MF_BYCOMMAND); if (state & MF_CHECKED) { submenu->CheckMenuItem(ID_FLOAT, MF_UNCHECKED | MF_BYCOMMAND); } else { submenu->CheckMenuItem(ID_FLOAT, MF_CHECKED | MF_BYCOMMAND); } } Thank you, :-O

    T 1 Reply Last reply
    0
    • P Pony

      Hello, Why can't I toggle menu? I have system tray menu that I want to toggle the 3rd menu item. But the problem is it doesn't toggle when I click it. Help me, please... ON_COMMAND(ID_FLOAT, OnFloat) void CMainFrame::OnFloat() { CMenu* mmenu = GetMenu(); CMenu* submenu = mmenu->GetSubMenu(2); UINT state = submenu->GetMenuState(ID_FLOAT, MF_BYCOMMAND); if (state & MF_CHECKED) { submenu->CheckMenuItem(ID_FLOAT, MF_UNCHECKED | MF_BYCOMMAND); } else { submenu->CheckMenuItem(ID_FLOAT, MF_CHECKED | MF_BYCOMMAND); } } Thank you, :-O

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      In MFC you're not using CheckMenuItem etc. Instead, you add special ON_UPDATE_COMMAND_UI handler which gets the CCmdUI object on input. One of the methods is SetCheck, which is all you need to have menu items checked. Tomasz Sowinski -- http://www.shooltz.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups