{"id":33263,"date":"2005-11-21T10:00:10","date_gmt":"2005-11-21T10:00:10","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/11\/21\/whats-the-difference-between-hwnd_top-and-hwnd_topmost\/"},"modified":"2005-11-21T10:00:10","modified_gmt":"2005-11-21T10:00:10","slug":"whats-the-difference-between-hwnd_top-and-hwnd_topmost","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20051121-10\/?p=33263","title":{"rendered":"What&#8217;s the difference between HWND_TOP and HWND_TOPMOST?"},"content":{"rendered":"<p>The special values <code>HWND_TOP<\/code> and <code>HWND_TOPMOST<\/code> have similar names but do completely different things when passed as the <code>hWndInsertAfter<\/code> parameter to the <code>DeferWindowPos<\/code> function (or its moral equivalents such as <code>SetWindowPos<\/code>). As a backgrounder, you should start off by reading <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/winui\/WinUI\/WindowsUserInterface\/Windowing\/Windows\/WindowReference\/WindowFunctions\/DeferWindowPos.asp\"> the MSDN discussion<\/a>, which is perfectly accurate as far as it goes. Here, I&#8217;ll discuss the issue from a historical perspective in the hopes that looking at it from a different direction may improve understanding.<\/p>\n<p> Sibling windows are maintained in an order called the Z-order. (For the purpose of this discussion, top-level windows are also treated as siblings. In fact, it is the Z-order of top-level windows that most people think of when they say &#8220;Z-order&#8221;.) <\/p>\n<p> The Z-order should be visualized as a vertical stack, with windows &#8220;above&#8221; or &#8220;below&#8221; siblings. <\/p>\n<p> Before Windows&nbsp;3.0, the behavior was simple: <code>HWND_TOP<\/code> brings the window to the top of the Z-order. <\/p>\n<p> Windows&nbsp;3.0 added the concept of &#8220;topmost&#8221; windows. These are top-level windows that always remain &#8220;above&#8221; non-topmost windows. To make a window topmost, call <code>DeferWindowPos<\/code> (or one of its moral equivalents) with <code>HWND_TOPMOST<\/code> as the <code>hWndInsertAfter<\/code>. To make a window non-topmost, use <code>HWND_NOTOPMOST<\/code>. <\/p>\n<p> As a result of the introduction of &#8220;topmost&#8221; windows, <code>HWND_TOP<\/code> now brings the window &#8220;as high in the Z-order as possible without violating the rule that topmost windows always appear above non-topmost windows&#8221;. What does this mean in practice? <\/p>\n<ul>\n<li>If a window is topmost, then     <code>HWND_TOP<\/code> puts it at the very top of the Z-order. <\/li>\n<li>If a window is not topmost, then     <code>HWND_TOP<\/code> puts it at the top of all non-topmost windows     (i.e., just below the lowest topmost window, if any). <\/li>\n<\/ul>\n<p> Note: The above discussion completely ignores the issue of owner and owned windows. I left them out because they would add a layer of complication that distracts from the main topic. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The special values HWND_TOP and HWND_TOPMOST have similar names but do completely different things when passed as the hWndInsertAfter parameter to the DeferWindowPos function (or its moral equivalents such as SetWindowPos). As a backgrounder, you should start off by reading the MSDN discussion, which is perfectly accurate as far as it goes. Here, I&#8217;ll discuss [&hellip;]<\/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":[2],"class_list":["post-33263","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>The special values HWND_TOP and HWND_TOPMOST have similar names but do completely different things when passed as the hWndInsertAfter parameter to the DeferWindowPos function (or its moral equivalents such as SetWindowPos). As a backgrounder, you should start off by reading the MSDN discussion, which is perfectly accurate as far as it goes. Here, I&#8217;ll discuss [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/33263","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=33263"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/33263\/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=33263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=33263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=33263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}