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. Dynamic Menus

Dynamic Menus

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
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.
  • D Offline
    D Offline
    Dor
    wrote on last edited by
    #1

    Hi, I have created a dynamic menu, but now im not sure how to get the menu item to respond when they are clicked on. The items are created by the user at run time. Is there a simple solution to this? Cheers Dor

    R 1 Reply Last reply
    0
    • D Dor

      Hi, I have created a dynamic menu, but now im not sure how to get the menu item to respond when they are clicked on. The items are created by the user at run time. Is there a simple solution to this? Cheers Dor

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      If you have a menu, if its a popup menu, you can get t ereturn value at the time of the call like this:

      int ret = TrackPopupMenuEx(pSub->m_hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, x, y, this->m_hWnd, NULL);
      switch (ret)
      {
      case IDC_COMMAND1:
      case IDC_ANOTHER_COMMAND:
      }

      The function returns 0 if the menu was cancelled. If its a top level menu, then I would recommend using a set range of menu iDs e.g. 10000 - 11000. You could them map the command using the ON_COMMAND_RANGE() macro for the message map. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003

      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