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. Creating user defined messages and events in MFC

Creating user defined messages and events in MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
3 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.
  • J Offline
    J Offline
    jossion
    wrote on last edited by
    #1

    Hi, I would like to get hints as to how to create messages in MFC. I wanted to sense the serial port buffer and then if the bytes received is above a threshold I would like to post a message and handle it with a function. How could it be done. The main issue is creating message or events to be handled.

    C M 2 Replies Last reply
    0
    • J jossion

      Hi, I would like to get hints as to how to create messages in MFC. I wanted to sense the serial port buffer and then if the bytes received is above a threshold I would like to post a message and handle it with a function. How could it be done. The main issue is creating message or events to be handled.

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      That is not a difficult task. You have to: 1. define your own message, choosen inside the user messages range. 2. Create the message handler with proper signature. 3. add an entry in your class message map. all of the above steps are well shown in the following documentation page: http://msdn2.microsoft.com/en-us/library/k35k2bfs(VS.80).aspx[^] :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      [my articles]

      1 Reply Last reply
      0
      • J jossion

        Hi, I would like to get hints as to how to create messages in MFC. I wanted to sense the serial port buffer and then if the bytes received is above a threshold I would like to post a message and handle it with a function. How could it be done. The main issue is creating message or events to be handled.

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

        In addition to CPallini's reply... I would recommend using messages ID(s) in the range WM_APP through 0xBFFF instead of a WM_USER-based ID as shown in the MS sample code. That way there's much less of a chance your message will conflict with any messages used by certain private window classes. You can also get a system-wide unique message ID with RegisterWindowMessage(). Mark

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

        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