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. Where did my WM_COMMAND go?

Where did my WM_COMMAND go?

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

    Hello, In my CDialog, I use the following line to send a command to a dialog bar: (((CMainFrame *)AfxGetApp()->m_pMainWnd)->m_SchedDlgBar1).PostMessage(ID_TEST); My m_SchedDlgBar1 class has the following: BEGIN_MESSAGE_MAP(CDiagGlobalSched, CDialogBar)   ...   ON_COMMAND(ID_TEST, RefreshSchedBar) END_MESSAGE_MAP() I have overidden the CMainFrm class's OnCmdMsg to see if this message ever shows up: BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) {   TRACE1("id:%d ", nID);   if (m_SchedDlgBar1.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE;   return CMDIFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); } ... and based on nID never being equal to ID_TEST (and my code not executing the designated function) it never shows up!? I've looked at examples and my code is exactly how they show it should be. Where did my message go? Why did it not show up? thanks! JennyP

    T 1 Reply Last reply
    0
    • J JennyP

      Hello, In my CDialog, I use the following line to send a command to a dialog bar: (((CMainFrame *)AfxGetApp()->m_pMainWnd)->m_SchedDlgBar1).PostMessage(ID_TEST); My m_SchedDlgBar1 class has the following: BEGIN_MESSAGE_MAP(CDiagGlobalSched, CDialogBar)   ...   ON_COMMAND(ID_TEST, RefreshSchedBar) END_MESSAGE_MAP() I have overidden the CMainFrm class's OnCmdMsg to see if this message ever shows up: BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) {   TRACE1("id:%d ", nID);   if (m_SchedDlgBar1.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE;   return CMDIFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); } ... and based on nID never being equal to ID_TEST (and my code not executing the designated function) it never shows up!? I've looked at examples and my code is exactly how they show it should be. Where did my message go? Why did it not show up? thanks! JennyP

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

      Use 'PostMessage(WM_COMMAND, ID_TEST)'. Tomasz Sowinski -- http://www.shooltz.com

      "Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.

      J 1 Reply Last reply
      0
      • T Tomasz Sowinski

        Use 'PostMessage(WM_COMMAND, ID_TEST)'. Tomasz Sowinski -- http://www.shooltz.com

        "Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.

        J Offline
        J Offline
        JennyP
        wrote on last edited by
        #3

        Perfect! Thanks Tomasz! So MSDN says: BOOL PostMessage( UINT message, WPARAM wParam = 0, LPARAM lParam = 0 ); ...and my custom message ID was supposed to be a WPARAM, not a UINT (message)? I'm confused.... but I'll just have to get over it. :) JennyP

        T 1 Reply Last reply
        0
        • J JennyP

          Perfect! Thanks Tomasz! So MSDN says: BOOL PostMessage( UINT message, WPARAM wParam = 0, LPARAM lParam = 0 ); ...and my custom message ID was supposed to be a WPARAM, not a UINT (message)? I'm confused.... but I'll just have to get over it. :) JennyP

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

          WM_COMMAND is message id. WM_COMMAND is sent in response to menu selections, accelerator keys being pressed and some events in controls like edit boxes. wParam contains the command id/control id. message id != command id. Tomasz Sowinski -- http://www.shooltz.com

          "Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.

          J 1 Reply Last reply
          0
          • T Tomasz Sowinski

            WM_COMMAND is message id. WM_COMMAND is sent in response to menu selections, accelerator keys being pressed and some events in controls like edit boxes. wParam contains the command id/control id. message id != command id. Tomasz Sowinski -- http://www.shooltz.com

            "Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.

            J Offline
            J Offline
            JennyP
            wrote on last edited by
            #5

            Thanks Tomasz, I feel bemused by the fact that I couldn't find such a seemingly basic concept in the MSDN... do you know where such a thing would be documented? The MSDN page on CWnd.SendMessage() just says that wParam depends on the command being sent--nothing more. I would be interested to understand the messaging better. Thanks! JennyP

            T 1 Reply Last reply
            0
            • J JennyP

              Thanks Tomasz, I feel bemused by the fact that I couldn't find such a seemingly basic concept in the MSDN... do you know where such a thing would be documented? The MSDN page on CWnd.SendMessage() just says that wParam depends on the command being sent--nothing more. I would be interested to understand the messaging better. Thanks! JennyP

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

              JennyP wrote: The MSDN page on CWnd.SendMessage() just says that wParam depends on the command being sent--nothing more. Sorry, it says that wParam depends on MESSAGE being sent, not command. You should understand the difference if you want to succeed in developing software for Windows. Tomasz Sowinski -- http://www.shooltz.com

              "Yields falsehood when preceded by its quotation" yields falsehood when preceded by its quotation.

              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