{"id":37243,"date":"2004-11-19T07:00:00","date_gmt":"2004-11-19T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/11\/19\/the-various-ways-of-sending-a-message\/"},"modified":"2004-11-19T07:00:00","modified_gmt":"2004-11-19T07:00:00","slug":"the-various-ways-of-sending-a-message","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20041119-00\/?p=37243","title":{"rendered":"The various ways of sending a message"},"content":{"rendered":"<p>There are several variations on <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/winui\/winui\/windowsuserinterface\/windowing\/messagesandmessagequeues\/messagesandmessagequeuesreference\/messagesandmessagequeuesfunctions\/sendmessage.asp\"> the SendMessage function<\/a>, but some are special cases of others.<\/p>\n<p> The simplest version is SendMessage itself, which sends a message and waits indefinitely for the response. <\/p>\n<p> The next level up is <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/winui\/WinUI\/WindowsUserInterface\/Windowing\/MessagesandMessageQueues\/MessagesandMessageQueuesReference\/MessagesandMessageQueuesFunctions\/SendMessageTimeout.asp\"> SendMessageTimeout<\/a> which sends a message and waits for the response or until a certain amount of time has elapsed. SendMessage is just SendMessageTimeout with an INFINITE timeout. <\/p>\n<p> Another version of SendMessage is <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/winui\/WinUI\/WindowsUserInterface\/Windowing\/MessagesandMessageQueues\/MessagesandMessageQueuesReference\/MessagesandMessageQueuesFunctions\/SendNotifyMessage.asp\"> SendNotifyMessage<\/a>, which is like SendMessage except that it doesn&#8217;t wait for the response.  It returns immediately and ignores the result produced by the receiving window. <\/p>\n<p> The last SendMessage-style functions is <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/winui\/WinUI\/WindowsUserInterface\/Windowing\/MessagesandMessageQueues\/MessagesandMessageQueuesReference\/MessagesandMessageQueuesFunctions\/SendMessageCallback.asp\"> SendMessageCallback<\/a>. This sends a message and then returns immediately. When the recipient finally returns a response, the callback is called. <\/p>\n<p> SendNotifyMessage is SendMessageCallback with a callback that does nothing. <\/p>\n<p> That&#8217;s how the four message-sending functions fit together. <\/p>\n<p> Bonus remark: If you use any of the above send-type functions to send a message to a window that belongs to the sending thread, the call is made synchronously.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are several variations on the SendMessage function, but some are special cases of others. The simplest version is SendMessage itself, which sends a message and waits indefinitely for the response. The next level up is SendMessageTimeout which sends a message and waits for the response or until a certain amount of time has elapsed. [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-37243","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>There are several variations on the SendMessage function, but some are special cases of others. The simplest version is SendMessage itself, which sends a message and waits indefinitely for the response. The next level up is SendMessageTimeout which sends a message and waits for the response or until a certain amount of time has elapsed. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=37243"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37243\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=37243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=37243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=37243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}