+ Reply to Thread
Results 1 to 2 of 2

Thread: What is the difference between PostMessage and SendMessage WIN32 API?

  1. #1

    What is the difference between PostMessage and SendMessage WIN32 API?

    Hi all,

    What is the difference between PostMessage and SendMessage WIN32 API?

    Regards.

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    Hi,

    PostMessage:

    PostMessage posts a message in the queue associated with the thread that created the specified window.
    Once the message in queue it just returns without waiting for the message handle associated with the message to get executed.

    This can be useful where you need to have fire-and-forget scenario. Caller does not wait for actual message to get handled when it returns.

    Example:
    Code:
    PostMessage (hTargetWnd, WM_USER_MESSAGE, lUserData1, lUserData2) ;
    SendMessage:

    Sends the specified message to a window or windows.
    The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.

    You can also use SendMessageTimeout if you have such a need.

    Regards.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts