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. change message handler prototype's name

change message handler prototype's name

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
4 Posts 3 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.
  • S Offline
    S Offline
    Sujay chakraborty
    wrote on last edited by
    #1

    hello everyone, This is a kind of strange question but it just got stuck to me this morning while writing my MFC application. Every time we define a message macro in MESSAGE MAP, we use default prototype for handling that message, i.e. for handling WM_CHAR() message we have OnChar() handler, what i want to know is whether there's a way change this default handler and provide our own message handler, with our defined name.......... I know we can work around this by calling our defined function in the default message handler but what i want is i don't want to mention the default handler in my application code. your help is highly awaited........ thanks in advance Regards

    A 1 Reply Last reply
    0
    • S Sujay chakraborty

      hello everyone, This is a kind of strange question but it just got stuck to me this morning while writing my MFC application. Every time we define a message macro in MESSAGE MAP, we use default prototype for handling that message, i.e. for handling WM_CHAR() message we have OnChar() handler, what i want to know is whether there's a way change this default handler and provide our own message handler, with our defined name.......... I know we can work around this by calling our defined function in the default message handler but what i want is i don't want to mention the default handler in my application code. your help is highly awaited........ thanks in advance Regards

      A Offline
      A Offline
      Adam Roderick J
      wrote on last edited by
      #2

      Yes you can add your own message handler for that. Firstly remove OnChar() function from MESSAGE MAP and remove all entries related to it. then just add the ON_MESSAGE for WM_CHAR in .cpp file BEGIN_MESSAGE_MAP(CMDI_CharView, CEditView) //{{AFX_MSG_MAP(CMDI_CharView) //}}AFX_MSG_MAP ON_MESSAGE( WM_CHAR, MyOnCharMessageHandlerFunction ) END_MESSAGE_MAP() and in .h file add your message handler function. protected: //{{AFX_MSG(CMDI_CharView) //}}AFX_MSG afx_msg void MyOnCharMessageHandlerFunction (UINT nChar, UINT nRepCnt, UINT nFlags); DECLARE_MESSAGE_MAP() :)

      Величие не Бога может быть недооценена.

      N 1 Reply Last reply
      0
      • A Adam Roderick J

        Yes you can add your own message handler for that. Firstly remove OnChar() function from MESSAGE MAP and remove all entries related to it. then just add the ON_MESSAGE for WM_CHAR in .cpp file BEGIN_MESSAGE_MAP(CMDI_CharView, CEditView) //{{AFX_MSG_MAP(CMDI_CharView) //}}AFX_MSG_MAP ON_MESSAGE( WM_CHAR, MyOnCharMessageHandlerFunction ) END_MESSAGE_MAP() and in .h file add your message handler function. protected: //{{AFX_MSG(CMDI_CharView) //}}AFX_MSG afx_msg void MyOnCharMessageHandlerFunction (UINT nChar, UINT nRepCnt, UINT nFlags); DECLARE_MESSAGE_MAP() :)

        Величие не Бога может быть недооценена.

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #3

        ARJ 09 wrote:

        afx_msg void MyOnCharMessageHandlerFunction (UINT nChar, UINT nRepCnt, UINT nFlags);

        Just a correction... The handler of the ON_MESSAGE should be in the format LRESULT MyOnCharMessageHandlerFunction(WPARAM wParam, LPARAM lParam);

        nave [OpenedFileFinder] [My Blog]

        A 1 Reply Last reply
        0
        • N Naveen

          ARJ 09 wrote:

          afx_msg void MyOnCharMessageHandlerFunction (UINT nChar, UINT nRepCnt, UINT nFlags);

          Just a correction... The handler of the ON_MESSAGE should be in the format LRESULT MyOnCharMessageHandlerFunction(WPARAM wParam, LPARAM lParam);

          nave [OpenedFileFinder] [My Blog]

          A Offline
          A Offline
          Adam Roderick J
          wrote on last edited by
          #4

          Yes exactly, thanks naveen for correcting me :)

          Величие не Бога может быть недооценена.

          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