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. Dialog app - menu

Dialog app - menu

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • A Offline
    A Offline
    Andre Massada
    wrote on last edited by
    #1

    I have a dialog app. i work with a menu: CMenu * menu = this->GetMenu(); menu->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED); and so,so. - and i have a boolean variable that i modify on each click. Then i have to hide the menu. SetMenu(NULL). Then when i load it again,now it executes all the commands, but it does not check or uncheck any items... what could i do ? Thanks.

    A 1 Reply Last reply
    0
    • A Andre Massada

      I have a dialog app. i work with a menu: CMenu * menu = this->GetMenu(); menu->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED); and so,so. - and i have a boolean variable that i modify on each click. Then i have to hide the menu. SetMenu(NULL). Then when i load it again,now it executes all the commands, but it does not check or uncheck any items... what could i do ? Thanks.

      A Offline
      A Offline
      Andrzej Markowski
      wrote on last edited by
      #2

      This is a working example:

      CMenu m_menu; // declared in CYourDlg header file
      //
      // Load the menu and assign to the dialog
      BOOL CYourDlg::OnInitDialog()
      {
      ...
      m_menu.LoadMenu(IDR_MENU1);
      SetMenu(&m_menu);
      ...
      }
      // on menu command (ID_XXX) message-handler function
      void CYourDlg::OnMenuXXXCommand()
      {
      CMenu * menu = GetMenu();
      if(menu)
      {
      // check/uncheck the menu item
      CMenu* pPopup = menu->GetSubMenu(0);
      if(pPopup->GetMenuState(ID_XXX,MF_BYCOMMAND)&MF_CHECKED)
      pPopup->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_UNCHECKED);
      else
      pPopup->CheckMenuItem(ID_XXX, MF_BYCOMMAND | MF_CHECKED);
      // do something
      }
      // on some button click message-handler function
      void CYourDlg::OnButtonClick()
      {
      // show/hide the menu
      if(GetMenu())
      SetMenu(NULL);
      else
      SetMenu(&m_menu);
      }

      Regards, Andrzej Markowski

      My Latest ArticlesCCustomBitmapButton: An owner-draw button and a frame for the caption bar, in one class. CCustomTabCtrl: A clone of the Excel tab sheet control.

      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