{"id":44964,"date":"2015-05-01T07:00:00","date_gmt":"2015-05-01T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2015\/05\/01\/how-does-the-window-manager-adjust-ptmaxsize-and-ptmaxposition-for-multiple-monitors\/"},"modified":"2019-03-13T12:15:10","modified_gmt":"2019-03-13T19:15:10","slug":"20150501-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20150501-00\/?p=44964","title":{"rendered":"How does the window manager adjust ptMaxSize and ptMaxPosition for multiple monitors?"},"content":{"rendered":"<p>There is a note down in the documentation for <a HREF=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms632605(v=vs.85).aspx\">the <code>MIN&shy;MAX&shy;INFO<\/code> structure<\/a>: <\/p>\n<blockquote CLASS=\"q\"><p>For systems with multiple monitors, the <b>ptMaxSize<\/b> and <b>ptMaxPosition<\/b> members describe the maximized size and position of the window on the primary monitor, even if the window ultimately maximizes onto a secondary monitor. In that case, the window manager adjusts these values to compensate for differences between the primary monitor and the monitor that displays the window. <\/p><\/blockquote>\n<p>People ask about the nature of this &#8220;compensation&#8221; and how they should deal with it. <\/p>\n<p>When the window manager sends the <code>WM_GET&shy;MIN&shy;MAX&shy;INFO<\/code> message to a top-level window, the <code>MIN&shy;MAX&shy;INFO<\/code> structure comes preinitialized with the following information: <\/p>\n<table BORDER=\"1\" STYLE=\"border-collapse: collapse\" CELLPADDING=\"3\">\n<tr>\n<th>Member<\/th>\n<th>Initialized To<\/th>\n<\/tr>\n<tr>\n<td><b>ptMaxSize<\/b><\/td>\n<td>The dimensions of the primary monitor.<\/td>\n<\/tr>\n<tr>\n<td><b>ptMaxPosition<\/b><\/td>\n<td>The upper left corner of the window if it were     maximized on the primary monitor.<\/tD> <\/tr>\n<tr>\n<td><b>ptMinTrackSize<\/b><\/td>\n<td>The minimum size the user can resize the window.<\/td>\n<\/tr>\n<tr>\n<td><b>ptMaxTrackSize<\/b><\/td>\n<td>The maximum size the user can resize the window         (the union of all monitors, basically).<\/td>\n<\/tr>\n<\/table>\n<p>Two of these values are monitor-relative and are therefore subject to adjustment. <\/p>\n<p><b>ptMax&shy;Position<\/b> is easy. The point is moved to a corresponding relative position on the window&#8217;s actual monitor. <\/p>\n<p><b>ptMax&shy;Size<\/b> is trickier. If the specified size is greater than or equal to the size of the primary monitor, then the <b>ptMax&shy;Size<\/b> is adjusted to include the difference in size between the primary monitor and the actual monitor. In other words, if <b>ptMax&shy;Size<\/b> is 20 pixels larger than the primary monitor, then it will be adjusted to being 20 pixels larger than the actual monitor. But if <b>ptMax&shy;Size<\/b> does not completely cover the monitor, then its value is used as-is. <\/p>\n<p>That is what the documentation is referring to when it says &#8220;In that case.&#8221; The case is &#8220;if the window ultimately maximizes onto a secondary monitor.&#8221; <\/p>\n<p>There is a bit of a gotcha here: If your window is larger than the screen in one direction but not another. For example, you may have a narrow maximum width but a tall maximum height. (Think console windows.) In that case, you will need to use <code>Monitor&shy;From&shy;Window<\/code> to get the parameters for the actual monitor so you can set your maximum height appropriately. <\/p>\n<p>We&#8217;ll dig a little deeper into this gotcha next time. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Very carefully.<\/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-44964","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Very carefully.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/44964","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=44964"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/44964\/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=44964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=44964"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=44964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}