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. MFC ON_COMMAND problem

MFC ON_COMMAND problem

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
7 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.
  • F Offline
    F Offline
    FredrickNorge
    wrote on last edited by
    #1

    Hi, for some reason i can only call ON_COMMAND in my main dialog, how can i call it in a child dialog? Any ideas would be much apreciated!

    M 1 Reply Last reply
    0
    • F FredrickNorge

      Hi, for some reason i can only call ON_COMMAND in my main dialog, how can i call it in a child dialog? Any ideas would be much apreciated!

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      How can you call ON_COMMAND?  ON_COMMAND is not a function or method AFAIK. Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      F 1 Reply Last reply
      0
      • M Mark Salsbery

        How can you call ON_COMMAND?  ON_COMMAND is not a function or method AFAIK. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        F Offline
        F Offline
        FredrickNorge
        wrote on last edited by
        #3

        Hi Mark, I call it via afx_msg void OnAddNewItem(); and ON_COMMAND(ID__ADDITEM, &CItemDlg::OnAddNewItem) Edit: the menu item is created via CMenu and if i move ON_COMMAND(ID__ADDITEM, &CItemDlg::OnAddNewItem) to the main dialog it works fine. But i want to know why i cant call it in the child dialog

        M 1 Reply Last reply
        0
        • F FredrickNorge

          Hi Mark, I call it via afx_msg void OnAddNewItem(); and ON_COMMAND(ID__ADDITEM, &CItemDlg::OnAddNewItem) Edit: the menu item is created via CMenu and if i move ON_COMMAND(ID__ADDITEM, &CItemDlg::OnAddNewItem) to the main dialog it works fine. But i want to know why i cant call it in the child dialog

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          You aren't calling anything.  You've added a method that will get called when the window you've added it to receives a WM_COMMAND message corresponding to a menu item or child window with the id "ID__ADDITEM". Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          F 1 Reply Last reply
          0
          • M Mark Salsbery

            You aren't calling anything.  You've added a method that will get called when the window you've added it to receives a WM_COMMAND message corresponding to a menu item or child window with the id "ID__ADDITEM". Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            F Offline
            F Offline
            FredrickNorge
            wrote on last edited by
            #5

            Ok, how do i associate the menu to the dialog? The menu opens when right mouse button is pressed and so i dont care to attatch it to the Child Dialogs system menu.

            M 1 Reply Last reply
            0
            • F FredrickNorge

              Ok, how do i associate the menu to the dialog? The menu opens when right mouse button is pressed and so i dont care to attatch it to the Child Dialogs system menu.

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              FredrickNorge wrote:

              ...how do i associate the menu to the dialog? The menu opens when right mouse button is pressed...

              The TrackPopupMenu() API/method takes a window handle/ptr to the window that should receive the command messages. Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              F 1 Reply Last reply
              0
              • M Mark Salsbery

                FredrickNorge wrote:

                ...how do i associate the menu to the dialog? The menu opens when right mouse button is pressed...

                The TrackPopupMenu() API/method takes a window handle/ptr to the window that should receive the command messages. Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                F Offline
                F Offline
                FredrickNorge
                wrote on last edited by
                #7

                Thanks, that made it work :)

                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