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. Not Able to Get Message

Not Able to Get Message

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
5 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
    paresh_joe
    wrote on last edited by
    #1

    I am working on a project, where i have to catch event on Update of the particular control , message is already defined for it. Between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP i am putting ON_MESSAGE (Messagename,UpdateFunction) statement with message and function name as a parameter. i have written definition of UpdateFunction in the same class. Problem :( is while running and updating control UpdateFunction is not getting executed. :wtf: is there anything i am missing for handling this ?

    H 1 Reply Last reply
    0
    • P paresh_joe

      I am working on a project, where i have to catch event on Update of the particular control , message is already defined for it. Between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP i am putting ON_MESSAGE (Messagename,UpdateFunction) statement with message and function name as a parameter. i have written definition of UpdateFunction in the same class. Problem :( is while running and updating control UpdateFunction is not getting executed. :wtf: is there anything i am missing for handling this ?

      H Offline
      H Offline
      Hamed Musavi
      wrote on last edited by
      #2

      Do you SendMessage or PostMessage to the class that you defined message in it or the framework should do that for you? Did you define a custom message or just redirect the same message? Which message is it? What type of control? Is it a custom control for example? Would you please provide some of your codes or at least more details.

      // "In the end it's a little boy expressing himself." Yanni
      while (I'm_alive)
      {
      cout<<"I love programming.";
      }

      P 1 Reply Last reply
      0
      • H Hamed Musavi

        Do you SendMessage or PostMessage to the class that you defined message in it or the framework should do that for you? Did you define a custom message or just redirect the same message? Which message is it? What type of control? Is it a custom control for example? Would you please provide some of your codes or at least more details.

        // "In the end it's a little boy expressing himself." Yanni
        while (I'm_alive)
        {
        cout<<"I love programming.";
        }

        P Offline
        P Offline
        paresh_joe
        wrote on last edited by
        #3

        yah its a custom control and message is also a custom one , redirecting to other message ... , i mean to say that its a custom table control when i update a cell value it should get to that method which i have specified in On_Message ... I just wanted to ask that is there anything that we have to do while handling messages 1)Define entry in message map 2)provide declaration and definition of Method (which you want to execute on event of message) Tahnx

        H 1 Reply Last reply
        0
        • P paresh_joe

          yah its a custom control and message is also a custom one , redirecting to other message ... , i mean to say that its a custom table control when i update a cell value it should get to that method which i have specified in On_Message ... I just wanted to ask that is there anything that we have to do while handling messages 1)Define entry in message map 2)provide declaration and definition of Method (which you want to execute on event of message) Tahnx

          H Offline
          H Offline
          Hamed Musavi
          wrote on last edited by
          #4

          paresh_joe wrote:

          anything that we have to do while handling messages

          If it's a CUSTOM message, then we shall follow the instruction: 1. Event handler MUST return LRESULT 2. Message variable should be defined in a right way, easiest: #define MyTestMessage WM_USER+1 3. Function declaration in the header file should should be written before DECLARE_MESSAGE_MAP() (e.g LRESULT OnSomething(WPARAM wParam, LPARAM lParam); ) 4. In .cpp it should be declared in a MESSAGE_MAP block: (e.g.ON_MESSAGE(MyTestMessage, OnSomthing)) 5. ALWAYS return 0 in the message handler function. 6. Only a window can accept messages, unless you create a custom message mapping, sending, dispatching, ... mechanism. So a CWnd object or derived classes can handle a message.

          // In .h file
          ...
          //}}AFX_MSG
          LRESULT OnSomething(WPARAM wParam, LPARAM lParam);
          DECLARE_MESSAGE_MAP()

          // In .Cpp file
          ...
          BEGIN_MESSAGE_MAP(CMyClass, CDialog)
          ...
          ON_MESSAGE(MyTestMessage, OnSomething)
          END_MESSAGE_MAP()

          .
          .
          .

          LRESULT CMyClass::OnSometing(WPARAM wParam, LPARAM lParam)
          {
          // Do Something
          return 0;
          }

          // "In the end it's a little boy expressing himself." Yanni
          while (I'm_alive)
          {
          cout<<"I love programming.";
          }

          modified on Friday, December 07, 2007 9:29:01 AM

          P 1 Reply Last reply
          0
          • H Hamed Musavi

            paresh_joe wrote:

            anything that we have to do while handling messages

            If it's a CUSTOM message, then we shall follow the instruction: 1. Event handler MUST return LRESULT 2. Message variable should be defined in a right way, easiest: #define MyTestMessage WM_USER+1 3. Function declaration in the header file should should be written before DECLARE_MESSAGE_MAP() (e.g LRESULT OnSomething(WPARAM wParam, LPARAM lParam); ) 4. In .cpp it should be declared in a MESSAGE_MAP block: (e.g.ON_MESSAGE(MyTestMessage, OnSomthing)) 5. ALWAYS return 0 in the message handler function. 6. Only a window can accept messages, unless you create a custom message mapping, sending, dispatching, ... mechanism. So a CWnd object or derived classes can handle a message.

            // In .h file
            ...
            //}}AFX_MSG
            LRESULT OnSomething(WPARAM wParam, LPARAM lParam);
            DECLARE_MESSAGE_MAP()

            // In .Cpp file
            ...
            BEGIN_MESSAGE_MAP(CMyClass, CDialog)
            ...
            ON_MESSAGE(MyTestMessage, OnSomething)
            END_MESSAGE_MAP()

            .
            .
            .

            LRESULT CMyClass::OnSometing(WPARAM wParam, LPARAM lParam)
            {
            // Do Something
            return 0;
            }

            // "In the end it's a little boy expressing himself." Yanni
            while (I'm_alive)
            {
            cout<<"I love programming.";
            }

            modified on Friday, December 07, 2007 9:29:01 AM

            P Offline
            P Offline
            paresh_joe
            wrote on last edited by
            #5

            Thanx

            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