<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx</link><description>Because WM_SHOWWINDOW isn't always sent.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118847</link><pubDate>Tue, 15 Jan 2008 19:33:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118847</guid><dc:creator>Good Point</dc:creator><description>&lt;p&gt;I think the really interesting part would be why WM_SHOWWINDOW is not sent under those certain cirsumstances.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118850</link><pubDate>Tue, 15 Jan 2008 19:35:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118850</guid><dc:creator>philq</dc:creator><description>&lt;p&gt;I can't wait for tomorrow. &amp;nbsp;WM_WINDOWPOSCHANGING is hands-down my favorite message. &amp;nbsp;I would say it's everybody's favorite, but there is a surprising lack of discussion of favorite win32 messages on the internet. &amp;nbsp;Between WM_WINDOWPOSCHANGING and AttachThreadInput() the operating system is your oyster.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118877</link><pubDate>Tue, 15 Jan 2008 19:44:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118877</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;Good entry as usual, but don't you mean the opposite of &amp;gt;&amp;gt;&amp;quot;If WM_WINDOWPOSCHANGED is redundant with WM_MOVE, WM_SIZE, and WM_SHOWWINDOW, then why do we have those other messages anyway?&amp;quot;&amp;lt;&amp;lt; ? &lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118917</link><pubDate>Tue, 15 Jan 2008 19:53:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118917</guid><dc:creator>Stephen Eilert</dc:creator><description>&lt;p&gt;@Michael&lt;/p&gt;
&lt;p&gt;&amp;quot;Good entry as usual, but don't you mean the opposite of &amp;gt;&amp;gt;&amp;quot;If WM_WINDOWPOSCHANGED is redundant with WM_MOVE, WM_SIZE, and WM_SHOWWINDOW, then why do we have those other messages anyway?&amp;quot;&amp;lt;&amp;lt; ?&amp;quot;&lt;/p&gt;
&lt;p&gt;I don't think so. If WM_WINDOWPOSCHANGED provides more information, the others are redundant and might as well not exist.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118933</link><pubDate>Tue, 15 Jan 2008 19:57:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118933</guid><dc:creator>Michael</dc:creator><description>&lt;p&gt;Yes I get that, maybe I'm just thick headed but the first part of the sentence makes it sounds like it's WM_WINDOWPOSCHANGED that's redundant, which is clearly not the case. &lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118954</link><pubDate>Tue, 15 Jan 2008 20:04:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118954</guid><dc:creator>ulric</dc:creator><description>&lt;p&gt;hum.. I'm an old-style charles-petzold kinda guy and I like the old messages. Especially since the WM_SIZE notification is generally all that a window needs. &amp;nbsp;Move? Never needed it. &amp;nbsp;WM_SHOWWINDOW is fine.. bizzare the client had a problem with it. &amp;nbsp;I like simple messages.&lt;/p&gt;
&lt;p&gt;btw, that sample code is a little funny, since it implies window could be both shown and hidden..&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118964</link><pubDate>Tue, 15 Jan 2008 20:08:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118964</guid><dc:creator>Blech</dc:creator><description>&lt;p&gt;&amp;quot;It sort of combines the other state change notifications, WM_MOVE, WM_SIZE, and WM_SHOWWINDOW&amp;quot;&lt;/p&gt;
&lt;p&gt;I never could get my head around that. The first two I have no problem with, but WM_SHOWWINDOW? The position isn't changing, is it? Just whether it is shown or not.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118985</link><pubDate>Tue, 15 Jan 2008 20:11:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118985</guid><dc:creator>Blech</dc:creator><description>&lt;p&gt;&amp;quot;What if the window is never shown? Does this mean that the program will never initialize itself?&amp;quot;&lt;/p&gt;
&lt;p&gt;Might make sense in some cases. If a program is, for example, displaying an image but is not visible why go to the expense of loading the file? It really depends what they mean by &amp;quot;initialize its state&amp;quot;.&lt;/p&gt;
&lt;p&gt;&amp;quot;The WM_NCCREATE and WM_CREATE are the more traditional places to do window initialization.&amp;quot;&lt;/p&gt;
&lt;p&gt;Maybe they really did mean application, and not window.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7118987</link><pubDate>Tue, 15 Jan 2008 20:13:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7118987</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Flags like these drive me nuts, especially in the Windows API.&lt;/p&gt;
&lt;p&gt;Presumably you can't both show and hide a window at the same time, so why do you have separate flags for them? &amp;nbsp;Also, why are some flags &amp;quot;negative&amp;quot; when the others are &amp;quot;positive&amp;quot;? &amp;nbsp;Wouldn't it make more sense to check for the presence of a flag rather than the lack of a flag? &amp;nbsp;&amp;quot;If the window was moved&amp;quot; makes more sense than &amp;quot;if the window was not not moved&amp;quot;. &amp;nbsp;This is the same thing you brought up a while ago about checkboxes with text like &amp;quot;Enable whatever&amp;quot; and &amp;quot;Disable whatever&amp;quot;. &amp;nbsp;Very annoying.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7119002</link><pubDate>Tue, 15 Jan 2008 20:17:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7119002</guid><dc:creator>noone in particular</dc:creator><description>&lt;p&gt;Great stuff.&lt;/p&gt;
&lt;p&gt;I just now learned about the existence of WM_WINDOWPOSCHANGED, and I am doing MFC-programming for 4 years now...&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7119119</link><pubDate>Tue, 15 Jan 2008 20:49:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7119119</guid><dc:creator>J</dc:creator><description>&lt;p&gt;&amp;quot;Presumably you can't both show and hide a window at the same time, so why do you have separate flags for them?&amp;quot;&lt;/p&gt;
&lt;p&gt;What if the window is neither shown nor hidden, but instead was resized? &amp;nbsp;What value do you propose to set the SHOW flag if 1 means the window was shown and 0 means the window was hidden? &amp;nbsp;Separate flags are essential for the design of the WM_WINDOWPOSCHANGED handler.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7119331</link><pubDate>Tue, 15 Jan 2008 21:35:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7119331</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;I don't think it's strange at all to do (re-)initialization when the window is shown if you use e.g. DDraw (incl. D3D) which requires it - old contents are almost certainly lost.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7119820</link><pubDate>Tue, 15 Jan 2008 22:38:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7119820</guid><dc:creator>John</dc:creator><description>&lt;p&gt;@J: &amp;nbsp;Oops. &amp;nbsp;You are correct in that regard.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7122312</link><pubDate>Wed, 16 Jan 2008 02:38:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7122312</guid><dc:creator>Miral</dc:creator><description>&lt;p&gt;&amp;quot;I never could get my head around that. The first two I have no problem with, but WM_SHOWWINDOW? The position isn't changing, is it? Just whether it is shown or not.&amp;quot;&lt;/p&gt;
&lt;p&gt;Ah, but WM_SHOWWINDOW is related to the ShowWindow API, which can both show/hide and resize windows (minimising, maximising, and restoring are all size changes). &amp;nbsp;So they are related.&lt;/p&gt;
&lt;p&gt;&amp;quot;Also, why are some flags &amp;quot;negative&amp;quot; when the others are &amp;quot;positive&amp;quot;? &amp;nbsp;Wouldn't it make more sense to check for the presence of a flag rather than the lack of a flag?&amp;quot;&lt;/p&gt;
&lt;p&gt;Because new flags are added over time, and existing programs won't be providing that flag. &amp;nbsp;Therefore &amp;quot;flag not present&amp;quot; must always be &amp;quot;default behaviour&amp;quot; and &amp;quot;flag present&amp;quot; must be &amp;quot;modified behaviour&amp;quot;. &amp;nbsp;Sometimes the modified behaviour is telling it to do something it wasn't doing before, other times it's telling it to *not* do something that it was doing before.&lt;/p&gt;
&lt;p&gt;So yes, it leads to non-ideal names for things, but there's not much else you can do to maintain backwards compatibility short of defining an entire new API (which is a bit of overkill for a simple flag).&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7122713</link><pubDate>Wed, 16 Jan 2008 03:13:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7122713</guid><dc:creator>AK</dc:creator><description>&lt;p&gt;SWP_NOxxx flags come from SetWindowPos, has nothing to do with new flags added over time AFAIK (but, SetWindowPos should probably been implemented the other way around, where you specify a mask of valid params instead of excluding stuff, but too late for that now ofcourse)&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7123298</link><pubDate>Wed, 16 Jan 2008 03:59:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7123298</guid><dc:creator>Sarath</dc:creator><description>&lt;p&gt;I've used this message before to detect Scrollbar available or not by GetWindowLog()&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7125995</link><pubDate>Wed, 16 Jan 2008 07:47:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7125995</guid><dc:creator>hexatron</dc:creator><description>&lt;p&gt;I suppose if I thought about this, it would explain why, under Windows 3.0, I never used ShowWindow, but instead moved the windows off- or on-screen with MoveWindow. But I won't.&lt;/p&gt;
&lt;p&gt;I notice the WM_WINDOWPOSCHANGED documentation says all this good stuff I never knew (this message generates the WM_MOVE,etc, and you are better off reacting to these in the WM_WINDOWPOSCHANGED). It makes me think I should re-read all the Win32 documentation (never mind MFC and the outer darkness of non-C/C++ windows programming). &amp;nbsp;Then I remember I probably only have one human lifetime at my disposal, and I've already squandered most of that.&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7126387</link><pubDate>Wed, 16 Jan 2008 08:18:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7126387</guid><dc:creator>hexatron</dc:creator><description>&lt;p&gt;As for flag, I just did a count of the 2002 Windows SDK:&lt;/p&gt;
&lt;p&gt;The include files together contain about 100,000 #defines.&lt;/p&gt;
&lt;p&gt;Of these, 625 are evaluate directly as 0 (or 0L, 0x0000, etc). Of course, many more are indirectly zero (#define ZERO 0 &amp;amp; #define HIDDENZERO ZERO)&lt;/p&gt;
&lt;p&gt;The memorable one is FILE_ATTRIBUTE_NORMAL, as in&lt;/p&gt;
&lt;p&gt;if(attributes &amp;amp; FILE_ATTRIBUTE_NORMAL){&lt;/p&gt;
&lt;p&gt; /// in your dreams, sucker!!!&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
</description></item><item><title>re: Use WM_WINDOWPOSCHANGED to react to window state changes</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#7142540</link><pubDate>Thu, 17 Jan 2008 20:02:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7142540</guid><dc:creator>Blech</dc:creator><description>&lt;p&gt;&amp;gt; Ah, but WM_SHOWWINDOW is related to the ShowWindow API, which can both show/hide and resize windows (minimising, maximising, and restoring are all size changes). &amp;nbsp;So they are related.&lt;/p&gt;
&lt;p&gt;I'm related to my father, but it doesn't mean he can get passed to all the functions I can.&lt;/p&gt;
</description></item><item><title>Custom Window Chrome in WPF</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx#8934302</link><pubDate>Mon, 08 Sep 2008 21:05:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8934302</guid><dc:creator>Windows Presentation Foundation SDK </dc:creator><description>&lt;p&gt;Guest post by Joe Castro, WPF product team developer This document covers the design and some implementation&lt;/p&gt;
</description></item></channel></rss>