{"id":97595,"date":"2017-12-18T07:00:00","date_gmt":"2017-12-18T22:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=97595"},"modified":"2019-03-13T01:24:10","modified_gmt":"2019-03-13T08:24:10","slug":"20171218-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20171218-00\/?p=97595","title":{"rendered":"What kind of messages can a message-only window receive?"},"content":{"rendered":"<p>There&#8217;s this thing called a <a HREF=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ms632599(VS.85).aspx#message_only\"><i>message-only window<\/i><\/a>, which is a very misleading name because receiving messages is the thing a window spends all its time doing anyway. It&#8217;s like calling something a <i>water-only swimming pool<\/i> or a <i>heat-only oven<\/i>. <\/p>\n<p>It&#8217;s also a very misleading name because it <i>doesn&#8217;t<\/i> receive all messages. &#8220;Wait, the name of this window says that the only thing it can do is receive messages, and now you&#8217;re saying it can&#8217;t do even that!&#8221; <\/p>\n<p>The point of a message-only window is that it receives only messages sent or posted specifically to it. You use it to set up a private channel between the sender and the window. After creating a message-only window, you can put messages in the window&#8217;s queue by calling <code>Post&shy;Message<\/code> and passing that window handle, or you can send a non-queued message by calling <code>Send&shy;Message<\/code> and passing that window handle. <\/p>\n<p>What makes a message-only window interesting is that it doesn&#8217;t particpate in broadcast messages. <\/p>\n<p>Many window messages are sent to all top-level windows. <code>WM_<\/code><code>QUERY&shy;END&shy;SESSION<\/code>, <code>WM_<\/code><code>SETTING&shy;CHANGE<\/code>, <code>WM_<\/code><code>DDE_<\/code><code>INITIATE<\/code>. and anything sent with <code>HWND_<\/code><code>BROADCAST<\/code>. These messages don&#8217;t reach message-only windows. <\/p>\n<p>Internally, message-only windows are treated as child windows of a system-managed common parent window called <code>HWND_<\/code><code>MESSAGE<\/code>. This system-managed common parent window is permanently invisible, which results in message-only windows being permanently invisible. And that&#8217;s also how message-only windows are invisible to enumeration and broadcasts: Enumeration and broadcasting is done to top-level windows, but message-only windows are internally treated as child windows of <code>HWND_<\/code><code>MESSAGE<\/code> and therefore are not considered top-level. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Only messages that are sent directly to that window.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-97595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Only messages that are sent directly to that window.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97595","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=97595"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97595\/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=97595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=97595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=97595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}