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. SendMessage and PostMessage

SendMessage and PostMessage

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 4 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
    Pryabu
    wrote on last edited by
    #1

    In which scenario,Sendmessage and Postmessage should be used? Thanks,

    _ R K 3 Replies Last reply
    0
    • P Pryabu

      In which scenario,Sendmessage and Postmessage should be used? Thanks,

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      You can send a standard Windows message or a user defined message using both SendMessage and PostMessage. SendMessage will wait for the message handler to complete the action, whereas PostMessage will simply queue the message to the target window's message queue. These APIs can be use to send messages to any window whether in the same process or not.

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      P 1 Reply Last reply
      0
      • P Pryabu

        In which scenario,Sendmessage and Postmessage should be used? Thanks,

        R Offline
        R Offline
        rp_suman
        wrote on last edited by
        #3

        PostMessage places a message in the window's message queue and then returns without waiting for the corresponding window to process the message. The SendMessage function calls the window procedure directly and does not return until that window procedure has processed the message.

        -- "Programming is an art that fights back!"

        1 Reply Last reply
        0
        • _ _Superman_

          You can send a standard Windows message or a user defined message using both SendMessage and PostMessage. SendMessage will wait for the message handler to complete the action, whereas PostMessage will simply queue the message to the target window's message queue. These APIs can be use to send messages to any window whether in the same process or not.

          «_Superman_»
          I love work. It gives me something to do between weekends.

          Microsoft MVP (Visual C++)

          Polymorphism in C

          P Offline
          P Offline
          Pryabu
          wrote on last edited by
          #4

          thanks. I want to know in which case we should use sendmessage and postmessage functions?

          _ 1 Reply Last reply
          0
          • P Pryabu

            thanks. I want to know in which case we should use sendmessage and postmessage functions?

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #5

            There can be many uses. One such use is for simple interprocess communication like sending a WM_CLOSE message to an external application. Another frequently used scenario is when you declare your own custom messages like WM_USER + 1 or WM_APP + 1.

            «_Superman_»
            I love work. It gives me something to do between weekends.

            Microsoft MVP (Visual C++)

            Polymorphism in C

            P 1 Reply Last reply
            0
            • _ _Superman_

              There can be many uses. One such use is for simple interprocess communication like sending a WM_CLOSE message to an external application. Another frequently used scenario is when you declare your own custom messages like WM_USER + 1 or WM_APP + 1.

              «_Superman_»
              I love work. It gives me something to do between weekends.

              Microsoft MVP (Visual C++)

              Polymorphism in C

              P Offline
              P Offline
              Pryabu
              wrote on last edited by
              #6

              thanks

              1 Reply Last reply
              0
              • P Pryabu

                In which scenario,Sendmessage and Postmessage should be used? Thanks,

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #7

                as others wrote ist right. I use PostMessage more for better user experience because it is non-blocking. SendMessage only for critical message. It works like a callback.

                Press F1 for help or google it. Greetings from Germany

                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