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. Return data when using SendMessage

Return data when using SendMessage

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

    Hi there. I am currently using a worker thread that communicates to the main thread using a call to sendmessage everything works great but now i need to return a string from that sendmessage handler to my worker thread. How can i return data from there, is it possible? Thanks

    L 1 Reply Last reply
    0
    • M manchukuo

      Hi there. I am currently using a worker thread that communicates to the main thread using a call to sendmessage everything works great but now i need to return a string from that sendmessage handler to my worker thread. How can i return data from there, is it possible? Thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Send a pointer to a buffer in the lParam parameter, so the called function can store data in it. However make sure the buffer is big enough to receive the response. Alternatively you could use a shared buffer and protect it with locks.

      I must get a clever new signature for 2011.

      M 1 Reply Last reply
      0
      • L Lost User

        Send a pointer to a buffer in the lParam parameter, so the called function can store data in it. However make sure the buffer is big enough to receive the response. Alternatively you could use a shared buffer and protect it with locks.

        I must get a clever new signature for 2011.

        M Offline
        M Offline
        manchukuo
        wrote on last edited by
        #3

        Yeah the first solution you tell about was the one i was using but i though it was ugly and not a good practice but it worked, i passed a CString pointer, but the 2nd solution you post how could it be implemented? Thanks

        L 1 Reply Last reply
        0
        • M manchukuo

          Yeah the first solution you tell about was the one i was using but i though it was ugly and not a good practice but it worked, i passed a CString pointer, but the 2nd solution you post how could it be implemented? Thanks

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          manchukuo wrote:

          but the 2nd solution you post how could it be implemented?

          See here[^] for some suggestions on how to implement sharing information between threads.

          I must get a clever new signature for 2011.

          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