<?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>The Old New Thing</title><link>http://blogs.msdn.com/b/oldnewthing/</link><description>not actually to establish a blogging point where individuals can enrich their learns on facilitating and leveraging .NET-related activities most effectively</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Even though mouse-move, paint, and timer messages are generated on demand, it's still possible for one to end up in your queue</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/23/10420741.aspx</link><pubDate>Thu, 23 May 2013 14:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10420741</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10420741</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/23/10420741.aspx#comments</comments><description>&lt;P&gt;
We all know that the
generated-on-demand messages like
&lt;CODE&gt;WM_&lt;WBR&gt;MOUSE&amp;shy;MOVE&lt;/CODE&gt;,
&lt;CODE&gt;WM_&lt;WBR&gt;PAINT&lt;/CODE&gt;,
and &lt;CODE&gt;WM_&lt;WBR&gt;TIMER&lt;/CODE&gt; messages
are not posted into the queue when the corresponding event occurs,
but rather are generated by
&lt;CODE&gt;Get&amp;shy;Message&lt;/CODE&gt; or &lt;CODE&gt;Peek&amp;shy;Message&lt;/CODE&gt;
when they detect that they are about to conclude that there is
no message to return
and
&lt;A HREF="http://blogs.msdn.com/b/oldnewthing/archive/2011/12/19/10249000.aspx"&gt;
the generated-on-demand message can be returned&lt;/A&gt;.
When this happens,
the window manager creates the message on the fly,
posts it into the queue,
and &lt;I&gt;hey, how about that&lt;/I&gt;,
the 
&lt;CODE&gt;Get&amp;shy;Message&lt;/CODE&gt; or &lt;CODE&gt;Peek&amp;shy;Message&lt;/CODE&gt;
function now has a message to return!
&lt;/P&gt;
&lt;P&gt;
Note that this auto-generate can happen even though the queue
is not empty,
because the message filters control what messages in the queue
can be returned.
For example,
suppose the message queue contains the following messages:
&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;{ hwnd1, WM_&lt;WBR&gt;CLIP&amp;shy;BOARD&amp;shy;UPDATE }&lt;/CODE&gt;
&lt;LI&gt;&lt;CODE&gt;{ hwnd2, WM_&lt;WBR&gt;LBUTTON&amp;shy;DOWN }&lt;/CODE&gt;
&lt;/UL&gt;
&lt;P&gt;
(Note that the above diagram is not strictly correct,
because the &lt;CODE&gt;WM_&lt;WBR&gt;LBUTTON&amp;shy;DOWN&lt;/CODE&gt; message
goes into the input queue, not the message queue,
but the distinction is not important here.)
&lt;/P&gt;
&lt;P&gt;
Suppose you now call
&lt;CODE&gt;Get&amp;shy;Message(&lt;WBR&gt;&amp;amp;msg, hwnd1,
WM_&lt;WBR&gt;MOUSE&amp;shy;FIRST, WM_&lt;WBR&gt;MOUSE&amp;shy;LAST)&lt;/CODE&gt;.
None of the messages in the queue satisfy the message filter:
The first message meets the window filter, but the message
is not in range.
The second message meets the message range filter, but
does not meet the window filter.
The &lt;CODE&gt;Get&amp;shy;Message&lt;/CODE&gt; function is about to give up
and say "I guess I need to wait for a message,"
but before it finally concedes defeat,
it says,
"Hang on there.
I see a note that tells me that I should auto-generate a
&lt;CODE&gt;WM_&lt;WBR&gt;MOUSE&amp;shy;MOVE&lt;/CODE&gt; message 
for window &lt;CODE&gt;hwnd1&lt;/CODE&gt;.
And that message satisfies the message filter.
I'll generate it now!"
&lt;/P&gt;
&lt;P&gt;
The &lt;CODE&gt;Get&amp;shy;Message&lt;/CODE&gt; function posts the
&lt;CODE&gt;{ hwnd1, WM_&lt;WBR&gt;MOUSE&amp;shy;MOVE }&lt;/CODE&gt;
message into the queue
(assigning it the current time as the timestamp),
and then it says,
"Hey, lookie here! A message that satisfies the filter!"
It then removes the message from the queue and returns it.
&lt;/P&gt;
&lt;P&gt;
(Note that this algorithm is conceptual.
It doesn't actually work this way internally.
In particular, the window manager does not literally talk to itself,
at least not out loud.)
&lt;/P&gt;
&lt;P&gt;
Okay, so in the &lt;CODE&gt;Get&amp;shy;Message&lt;/CODE&gt; case,
even if the message conceptually goes into the queue,
it comes right back out immediately,
so you never actually observe it there.
&lt;/P&gt;
&lt;P&gt;
Now repeat the exercise with the
&lt;CODE&gt;Peek&amp;shy;Message&lt;/CODE&gt; function.
As before, the
&lt;CODE&gt;WM_&lt;WBR&gt;MOUSE&amp;shy;MOVE&lt;/CODE&gt; message
is posted into the queue with the current time as the timestamp.
If the &lt;CODE&gt;PM_&lt;WBR&gt;REMOVE&lt;/CODE&gt; flag is passed,
then the message is removed from the queue and returned,
just like &lt;CODE&gt;Get&amp;shy;Message&lt;/CODE&gt;.
If the &lt;CODE&gt;PM_&lt;WBR&gt;NO&amp;shy;REMOVE&lt;/CODE&gt; flag is passed,
then things get interesting:
The message is returned but not removed from the queue.
&lt;/P&gt;
&lt;P&gt;
You now have a &lt;CODE&gt;WM_&lt;WBR&gt;MOUSE&amp;shy;MOVE&lt;/CODE&gt; message
&lt;I&gt;physically residing in the queue&lt;/I&gt;!
&lt;/P&gt;
&lt;P&gt;
This is the answer to the puzzle:
If auto-generated messages are generated on demand,
how is it possible for them to end up sitting in your message queue?
&lt;/P&gt;
&lt;P&gt;
I recall a bug investigation from nearly two decades ago which
basically boiled down to this issue:
Somebody &lt;CODE&gt;PM_&lt;WBR&gt;NO&amp;shy;REMOVE&lt;/CODE&gt;'d an auto-generated
message and not only left it in the queue,
but kept generating new ones without processing the old ones.
Eventually, the message queue filled up.
&lt;/P&gt;
&lt;P&gt;
(Note that this is also the answer to the puzzle:
If &lt;CODE&gt;WM_&lt;WBR&gt;MOUSE&amp;shy;MOVE&lt;/CODE&gt; is generated on demand,
how can it be possible to retrieve a
&lt;CODE&gt;WM_&lt;WBR&gt;MOUSE&amp;shy;MOVE&lt;/CODE&gt; message
with a timestamp different from the current time?)
&lt;/P&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10420741" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Code/">Code</category></item><item><title>How do I get a window back on the screen when it moved far, far away? Windows 7 (and 8) edition</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/22/10420443.aspx</link><pubDate>Wed, 22 May 2013 14:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10420443</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>29</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10420443</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/22/10420443.aspx#comments</comments><description>&lt;P&gt;
Some time ago, I showed
&lt;A HREF="http://blogs.msdn.com/b/oldnewthing/archive/2009/05/11/9601136.aspx"&gt;
how to get a window back on the screen when it moved far,
far away&lt;/A&gt;.
That technique still works in Windows 7&amp;nbsp;and&amp;nbsp;8,
but there's an easier shortcut that takes advantage of window
arrangement features added in Windows&amp;nbsp;7.
&lt;/P&gt;
&lt;P&gt;
First, you switch to the application by whatever means.
Then hit
&lt;KBD&gt;Win&lt;/KBD&gt;+&lt;KBD&gt;UpArrow&lt;/KBD&gt; to maximize the window.
That should put the window on-screen, albeit at the wrong size.
Now you just grab the title bar of the window with the mouse
and drag it off the top edge of the screen.
Bingo, the window returns to its original position,
and you can use the mouse to put it wherever you like.
&lt;/P&gt;
&lt;P&gt;
This trick doesn't work for windows that cannot be resized
(such as &lt;I&gt;Calculator&lt;/I&gt;),
but for those windows, you can use
&lt;A HREF="http://blogs.msdn.com/b/oldnewthing/archive/2009/05/11/9601136.aspx"&gt;
the old version of the trick&lt;/A&gt;.
&lt;/P&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10420443" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Tips_2F00_Support/">Tips/Support</category></item><item><title>A question about proper disposal of unwanted items with an unhelpful answer</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/21/10420161.aspx</link><pubDate>Tue, 21 May 2013 14:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10420161</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10420161</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/21/10420161.aspx#comments</comments><description>&lt;P&gt;
On an internal mailing list about home maintenance and ownership,
somebody asked:
&lt;/P&gt;
&lt;BLOCKQUOTE CLASS=q&gt;
&lt;P&gt;
I have a handful of items that I need to get rid of and
probably should not toss into the regular garbage.
Any thoughts?
&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Older TV &amp;mdash; 32&amp;Prime;
&lt;LI&gt;Propane tanks (full)
&lt;LI&gt;Lighter fluid
&lt;LI&gt;Carpet glue adhesive
&lt;LI&gt;Lawn fertilizer
&lt;/UL&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;
The best reply was an unhelpful one.
&lt;/P&gt;
&lt;BLOCKQUOTE CLASS=q&gt;
&lt;P&gt;
You've pretty much got all the components you need
to build a bomb.
Why dispose of them?
&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10420161" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Non_2D00_Computer/">Non-Computer</category></item><item><title>The importance of remembering parity in a back-and-forth race on your flying bicycle</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/20/10419966.aspx</link><pubDate>Mon, 20 May 2013 14:00:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10419966</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10419966</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/20/10419966.aspx#comments</comments><description>&lt;P&gt;
I dreamed that one of my friends had made the U.S. cycling team.
(Perhaps because everybody else got busted for doping.)
Even more implausibly, &lt;I&gt;I&lt;/I&gt; also made the team.
&lt;/P&gt;
&lt;P&gt;
To celebrate, he challenged me to a short race.
The path ran along a river,
in which a medium-sized boat was setting sail.
Our bicycles somehow could fly (which we considered perfectly normal)
and we were flying over the boat, just about keeping pace with it.
&lt;/P&gt;
&lt;P&gt;
The boat reversed direction many times, and we reversed along with it.
At one of the reversals, I thought,
"I could take a shortcut if I kept going straight,"
but I must've lost even/odd count because I flew off the boat...
heading back to the starting line.
&lt;/P&gt;
&lt;P&gt;
&lt;B&gt;Bonus weirdness&lt;/B&gt;:
For some reason,
we were in Sweden,
and the race commentator saw a school labeled
&lt;A HREF="http://en.wikipedia.org/wiki/Gymnasium_(school)"&gt;
Gymnasium&lt;/A&gt;
and made some remark about repurposing buildings
left over from the Olympics.
&lt;/P&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10419966" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Non_2D00_Computer/">Non-Computer</category><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Dream/">Dream</category></item><item><title>Copying a file to the clipboard so you can paste it into Explorer or an email message or whatever</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/20/10419965.aspx</link><pubDate>Mon, 20 May 2013 14:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10419965</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10419965</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/20/10419965.aspx#comments</comments><description>&lt;P&gt;
Today's Little Program takes a fully-qualified file name
from the command line and puts that file onto the clipboard.
Once there, you can paste it into an Explorer window,
or into an email message,
or a word processing document,
or anybody else who understands shell data objects.
&lt;/P&gt;
&lt;PRE&gt;
#include &amp;lt;windows.h&amp;gt;
#include &amp;lt;shlobj.h&amp;gt;
#include &amp;lt;atlbase.h&amp;gt;
#include &amp;lt;shlobj.h&amp;gt;

class COleInitialize {
public:
 COleInitialize() : m_hr(OleInitialize(NULL)) { }
 ~COleInitialize() { if (SUCCEEDED(m_hr)) OleUninitialize(); }
 operator HRESULT() const { return m_hr; }
 HRESULT m_hr;
};

// &lt;A HREF="http://blogs.msdn.com/b/oldnewthing/archive/2004/09/21/231739.aspx"&gt;GetUIObjectOfFile&lt;/A&gt; incorporated by reference

int __cdecl wmain(int argc, PWSTR argv[])
{
 COleInitialize init;
 CComPtr&amp;lt;IDataObject&amp;gt; spdto;

 if (SUCCEEDED(init) &amp;amp;&amp;amp;
     argc == 2 &amp;amp;&amp;amp;
     SUCCEEDED(GetUIObjectOfFile(nullptr, argv[1], IID_PPV_ARGS(&amp;amp;spdto))) &amp;amp;&amp;amp;
     SUCCEEDED(OleSetClipboard(spdto)) &amp;amp;&amp;amp;
     SUCCEEDED(OleFlushClipboard())) {
  // success
 }

 return 0;
}
&lt;/PRE&gt;
&lt;P&gt;
The &lt;CODE&gt;COle&amp;shy;Initialize&lt;/CODE&gt; class is just the OLE
counterpart to
&lt;A HREF="http://blogs.msdn.com/b/oldnewthing/archive/2004/05/20/135841.aspx"&gt;
the &lt;CODE&gt;CCo&amp;shy;Initialize&lt;/CODE&gt; class we saw some time ago&lt;/A&gt;.
&lt;/P&gt;
&lt;P&gt;
All the program does is take the file name on the command line,
asks the shell for the corresponding data object,
then puts that object onto the clipboard,
&lt;A HREF="http://blogs.msdn.com/b/oldnewthing/archive/2010/05/10/10009448.aspx"&gt;
erasing what was there before&lt;/A&gt;.
&lt;/P&gt;
&lt;P&gt;
Once the data is on the clipboard, our job is done so we exit.
&lt;/P&gt;
&lt;P&gt;
No, wait!
If you exit while your application has data on the clipboard,
that clipboard data may be lost.
The documentation for &lt;CODE&gt;Ole&amp;shy;Set&amp;shy;Clipboard&lt;/CODE&gt;
notes:
&lt;/P&gt;
&lt;BLOCKQUOTE CLASS=q&gt;
If you need to leave the data on the clipboard
after your application is closed,
you should call &lt;B&gt;Ole&amp;shy;Flush&amp;shy;Clipboard&lt;/B&gt;
rather than calling
&lt;B&gt;Ole&amp;shy;Set&amp;shy;Clipboard&lt;/B&gt;
with a &lt;B&gt;NULL&lt;/B&gt; parameter value.
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;
Therefore, we stick in a call to
&lt;CODE&gt;Ole&amp;shy;Flush&amp;shy;Clipboard&lt;/CODE&gt;
before exiting.
This forces any delay-rendered content to be rendered immediately,
because we ain't gonna be around to delay-render it no more.
&lt;/P&gt;
&lt;P&gt;
Note that the file on the command line must be fully-qualified,
because we pass it straight to
&lt;CODE&gt;Get&amp;shy;UI&amp;shy;Object&amp;shy;Of&amp;shy;File&lt;/CODE&gt;,
which expects a fully-qualified path.
Fixing the program to allow relative paths (and to actually
print error messages and stuff) is left as an exercise,
because Little Programs don't deal with annoying details like
error checking and reporting.
&lt;/P&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10419965" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Code/">Code</category></item><item><title>Who sends the initial WM_UPDATEUISTATE message?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/17/10419502.aspx</link><pubDate>Fri, 17 May 2013 14:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10419502</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10419502</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/17/10419502.aspx#comments</comments><description>&lt;P&gt;
&lt;A HREF="http://blogs.msdn.com/b/oldnewthing/archive/2013/05/16/10419105.aspx"&gt;
Last time&lt;/A&gt;,
we looked at the
confusingly-named
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
and
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
messages.
But how does the whole indicator thingie get off the ground?
&lt;/P&gt;
&lt;P&gt;
The default state for a window is to show all indicators.
But as a special trick,
the dialog manager will send a
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message
with &lt;CODE&gt;UIS_&lt;WBR&gt;INITIALIZE&lt;/CODE&gt; after the dialog
has been initialized,
which turns off the indicators if the last input event
was a mouse event.
This is its way of inferring whether the dialog box was
triggered by a mouse or keyboard action
and setting the initial indicators accordingly.
(Note that if the user checked
&lt;I&gt;Underline keyboard shortcuts and access keys&lt;/I&gt;,
then the dialog manager leaves the indicators enabled
regardless of the last input event.)
&lt;/P&gt;
&lt;P&gt;
That special
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message
is what gives dialog boxes the extra special feature
of hiding the keyboard accelerators until you use the keyboard.
&lt;/P&gt;
&lt;P&gt;
But notice that only the dialog manager does this.
If you want this behavior in your own non-dialog windows,
you will need to send the message yourself.
&lt;/P&gt;
&lt;PRE&gt;
BOOL MyWindow::OnCreate(...)
{
 ... create and initialize any child windows ...

 &lt;FONT COLOR=blue&gt;// initialize indicators
 BOOL fAlwaysUnderline = FALSE;
 SystemParametersInfo(SPI_GETKEYBOARDCUES, 0,
                      &amp;amp;fAlwaysUnderline, 0);
 if (!fAlwaysUnderline) {
  SendMessage(this-&amp;gt;m_hwnd, WM_UPDATEUISTATE,
              MAKEWPARAM(UIS_INITIALIZE, 0), 0);
 }&lt;/FONT&gt;
}
&lt;/PRE&gt;
&lt;P&gt;
&lt;B&gt;Exercise&lt;/B&gt;:
Why is it important to create and initialize the child windows
before sending the
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message?
&lt;/P&gt;
&lt;P&gt;
&lt;B&gt;Exercise&lt;/B&gt;:
Why can't the window manager do this automatically
after &lt;CODE&gt;WM_&lt;WBR&gt;CREATE&lt;/CODE&gt; returns?
&lt;/P&gt;
&lt;P&gt;
&lt;B&gt;Exercise&lt;/B&gt;:
Explain the behavior this customer observes.
&lt;/P&gt;
&lt;BLOCKQUOTE CLASS=q&gt;
We have a dialog box with three buttons.
Sometimes the dialog displays underlines for the hotkeys,
and sometimes it doesn't.
I know about the feature which hides keyboard accelerators
by default, but that doesn't explain why the setting gets
ignored sometimes.
The first time I show the dialog in my program,
I get the underlines, but the second and subsequent times,
I do not.
&lt;/BLOCKQUOTE&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10419502" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Code/">Code</category></item><item><title>Your electric fan is trying to kill you, and other cultural superstitions</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/16/10419106.aspx</link><pubDate>Thu, 16 May 2013 14:00:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10419106</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>72</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10419106</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/16/10419106.aspx#comments</comments><description>&lt;P&gt;
In Korea, it is generally believed that leaving a fan on in an enclosed room
can be fatal.
Ken Jennings
&lt;A HREF="http://www.amazon.com/gp/product/1451656254/&amp;tag=tholneth-20"&gt;
looks at cultural superstitions&lt;/A&gt;
and wrote a Slate article focusing on
&lt;A HREF="http://www.slate.com/articles/life/foreigners/2013/01/fan_death_korean_moms_think_that_your_electric_fan_will_kill_you.html"&gt;
the scourge of Korean fan death&lt;/A&gt;.
&lt;/P&gt;
&lt;P&gt;
My mother told me that handling cellophane tape makes you sterile.
Though that may have just been her way of getting me to stop
playing with cellophane tape.
&lt;/P&gt;
&lt;P&gt;
What strange cultural superstitions exist in your part of the world?
(Of course, this is a bit of an unfair question, because if you genuinely
believe it, then you won't recognize it  as a strange cultural superstition!)
&lt;/P&gt;
&lt;P&gt;
&lt;B&gt;Clarification&lt;/B&gt;: Please reply in the spirit of the article.
Keep it fun.
&lt;/P&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10419106" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Non_2D00_Computer/">Non-Computer</category></item><item><title>Untangling the confusingly-named WM_UPDATEUISTATE and WM_CHANGEUISTATE messages</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/16/10419105.aspx</link><pubDate>Thu, 16 May 2013 14:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10419105</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10419105</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/16/10419105.aspx#comments</comments><description>&lt;P&gt;
I always get confused by the
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
and
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
messages,
and I have to go figure them out each time I need to mess
with them.
So this time, I'm going to write it down so I don't forget.
Because the act of writing it down helps me to remember.
&lt;/P&gt;
&lt;P&gt;
It's like in school, where the teacher says,
"This is a closed-book, closed-notes exam,
but you are allowed to bring one piece of standard
8&amp;frac12;&amp;Prime;&amp;times;11&amp;Prime; paper with you,
on which you can write anything you like.
No funny business."
You work really hard to create the ultimate sheet of
paper to bring to the exam,
and then it turns out that during the exam,
you barely refer to it at all.
Because the act of deciding what to put on the cheat sheet
made you remember the material.
&lt;/P&gt;
&lt;P&gt;
Part of the problem with the messages
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
and
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
is their confusing names,
because to most people &lt;I&gt;update&lt;/I&gt; and &lt;I&gt;change&lt;/I&gt;
are basically the same concept.
The difference is the direction the message travels.
Before we look at that, let's look at the mysterious &lt;CODE&gt;WPARAM&lt;/CODE&gt;.
&lt;/P&gt;
&lt;P&gt;
The &lt;CODE&gt;WPARAM&lt;/CODE&gt; specifies what action you want
to perform (initialize, set, or clear)
and the target of the action (focus, accelerators, or both).
&lt;/P&gt;
&lt;TABLE BORDER=1 BORDERCOLOR=black STYLE="border-collapse: collapse"&gt;
&lt;TR&gt;
    &lt;TH&gt;Action&lt;/TH&gt;
    &lt;TH&gt;Meaning&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD&gt;&lt;CODE&gt;UIS_SET&lt;/CODE&gt;&lt;/TD&gt;
    &lt;TD&gt;Set the flag (hide the indicator).&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD&gt;&lt;CODE&gt;UIS_CLEAR&lt;/CODE&gt;&lt;/TD&gt;
    &lt;TD&gt;Clear the flag (show the indicator).&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD&gt;&lt;CODE&gt;UIS_INITIALIZE&lt;/CODE&gt;&lt;/TD&gt;
    &lt;TD&gt;Set or clear the flag
    based on whether the last input event was mouse (set)
    or keyboard (clear).&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;
&lt;P&gt;
Setting a flag hides the corresponding indicator.
For example, if you have a &lt;CODE&gt;UIS_&lt;WBR&gt;SET&lt;/CODE&gt; for
&lt;CODE&gt;UISF_&lt;WBR&gt;HIDE&amp;shy;FOCUS&lt;/CODE&gt;, that means that
you want to hide focus indicators.
&lt;/P&gt;
&lt;P&gt;
Clearing a flag shows the corresponding indicator.
For example, if you have a &lt;CODE&gt;UIS_&lt;WBR&gt;CLEAR&lt;/CODE&gt; for
&lt;CODE&gt;UISF_&lt;WBR&gt;HIDE&amp;shy;FOCUS&lt;/CODE&gt;, that means that
you want to show focus indicators.
&lt;/P&gt;
&lt;P&gt;
Yes, it's a bit of a double-negative situation.
&lt;/P&gt;
&lt;P&gt;
Each window has its own internal state that remembers
which indicators have been hidden for that window.
You can query this state by sending the window
a &lt;CODE&gt;WM_&lt;WBR&gt;QUERY&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message.
&lt;/P&gt;
&lt;P&gt;
The
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message travels down the tree:
When a window receives the
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message,
it updates its state according to the &lt;CODE&gt;WPARAM&lt;/CODE&gt;
and then forwards the message to its children.
Therefore, if you want to change the state for an entire
window tree,
you can send the
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message
to the top-level window,
and the message will be delivered to that window and all
its children.
&lt;/P&gt;
&lt;P&gt;
It's called &lt;I&gt;update&lt;/I&gt; because it says,
"Okay, listen up everybody,
this is what we're going to do."
&lt;/P&gt;
&lt;P&gt;
The
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message
is more like a change &lt;I&gt;request&lt;/I&gt;.
It travels up the tree:
When a window receives the message,
it sees if the state being requested matches the
window's current state.
If so, then processing stops since there is nothing to change.
Otherwise, the window forwards the message to its parent.
The idea here is to push the change request up the tree
until it finds the top-level window.
&lt;/P&gt;
&lt;P&gt;
If a top-level window receives a
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message
for a state change that actually changes something,
it turns around and sends itself a
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message, which as we saw before,
tells the entire window tree to set its indicator state
to the value specified.
&lt;/P&gt;
&lt;P&gt;
Okay, let's draw a picture.
Suppose we have a top-level window with two children,
and suppose that everybody starts out with all indicators hidden.
&lt;/P&gt;
&lt;TABLE&gt;
&lt;TR&gt;
&lt;TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0
       SUMMARY="A top-level window named A, with children B and C. All of them are marked hideFocus=1 and hideAccel=1"&gt;
&lt;TR&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD COLSPAN=2 STYLE="width: 6em"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=2 ALIGN=center
         STYLE="border: solid black .75pt; height: 3em; width: 6em;"&gt;
    &lt;FONT SIZE=+2&gt;A&lt;/FONT&gt;&lt;BR&gt;hideFocus=1&lt;BR&gt;hideAccel=1&lt;/TD&gt;
    &lt;TD COLSPAN=2 STYLE="width: 6em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=2
        STYLE="width: 6em; border-bottom: solid black .75pt;
                           border-right: solid black .75pt"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=2
        STYLE="width: 6em; border-bottom: solid black .75pt"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=4
        STYLE="width:12em; border-left: solid black .75pt;
                          border-right: solid black .75pt"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD COLSPAN=2 ALIGN=center
        STYLE="border: solid black .75pt; height: 3em; width: 6em;"&gt;
    &lt;FONT SIZE=+2&gt;B&lt;/FONT&gt;&lt;BR&gt;hideFocus=1&lt;BR&gt;hideAccel=1&lt;/TD&gt;
    &lt;TD COLSPAN=2 STYLE="width: 6em"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=2 ALIGN=center
        STYLE="border: solid black .75pt; height: 3em; width: 6em;"&gt;
    &lt;FONT SIZE=+2&gt;C&lt;/FONT&gt;&lt;BR&gt;hideFocus=1&lt;BR&gt;hideAccel=1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;
&lt;P&gt;
Window&amp;nbsp;B decides that it wants to show accelerators,
say because the user tapped the &lt;KBD&gt;Alt&lt;/KBD&gt; key.
It sends itself a
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message with a &lt;CODE&gt;wParam&lt;/CODE&gt; of
&lt;CODE&gt;MAKEWPARAM(&lt;WBR&gt;UIS_&lt;WBR&gt;CLEAR, UISF_&lt;WBR&gt;HIDE&amp;shy;ACCEL)&lt;/CODE&gt;.
&lt;/P&gt;
&lt;P&gt;
The
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message handler for Window&amp;nbsp;B
sees that the &lt;CODE&gt;UISF_&lt;WBR&gt;HIDE&amp;shy;ACCEL&lt;/CODE&gt;
flag is set,
so the &lt;I&gt;clear&lt;/I&gt; action is meaningful.
It forwards the request to its parent, Window&amp;nbsp;A.
&lt;/P&gt;
&lt;P&gt;
The
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message handler for Window&amp;nbsp;A
also sees that the &lt;CODE&gt;UISF_&lt;WBR&gt;HIDE&amp;shy;ACCEL&lt;/CODE&gt;
flag is set,
so the &lt;I&gt;clear&lt;/I&gt; action is meaningful.
Since it has no parent, Window&amp;nbsp;A converts the
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message to a
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message and sends it to itself.
&lt;/P&gt;
&lt;P&gt;
The
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message handler for Window&amp;nbsp;A
sees that it is being told to clear the &lt;CODE&gt;UISF_&lt;WBR&gt;HIDE&amp;shy;ACCEL&lt;/CODE&gt;
flag,
so it clears the flag and then forwards the mesage to both its children.
&lt;/P&gt;
&lt;P&gt;
Each of the child windows B&amp;nbsp;and&amp;nbsp;C receive the
&lt;CODE&gt;WM_&lt;WBR&gt;UPDATE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt; message
and see that they are also being told to clear the
&lt;CODE&gt;UISF_&lt;WBR&gt;HIDE&amp;shy;ACCEL&lt;/CODE&gt;
flag,
so they do so.
Those windows have no children of their own, so message processing stops.
By this mechanism, Window&amp;nbsp;B has managed to convince
all the other windows in the hierarchy to clear the
&lt;CODE&gt;UISF_&lt;WBR&gt;HIDE&amp;shy;ACCEL&lt;/CODE&gt; flag.
&lt;/P&gt;
&lt;TABLE&gt;
&lt;TR&gt;
&lt;TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0
       SUMMARY="A top-level window named A, with children B and C. All of them are marked hideFocus=1 and hideAccel=0"&gt;
&lt;TR&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD COLSPAN=2 STYLE="width: 6em"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=2 ALIGN=center
         STYLE="border: solid black .75pt; height: 3em; width: 6em;"&gt;
    &lt;FONT SIZE=+2&gt;A&lt;/FONT&gt;&lt;BR&gt;hideFocus=1&lt;BR&gt;hideAccel=0&lt;/TD&gt;
    &lt;TD COLSPAN=2 STYLE="width: 6em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=2
        STYLE="width: 6em; border-bottom: solid black .75pt;
                           border-right: solid black .75pt"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=2
        STYLE="width: 6em; border-bottom: solid black .75pt"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=4
        STYLE="width:12em; border-left: solid black .75pt;
                          border-right: solid black .75pt"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD STYLE="width: 3em"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
    &lt;TD COLSPAN=2 ALIGN=center
        STYLE="border: solid black .75pt; height: 3em; width: 6em;"&gt;
    &lt;FONT SIZE=+2&gt;B&lt;/FONT&gt;&lt;BR&gt;hideFocus=1&lt;BR&gt;hideAccel=0&lt;/TD&gt;
    &lt;TD COLSPAN=2 STYLE="width: 6em"&gt;&amp;nbsp;&lt;/TD&gt;
    &lt;TD COLSPAN=2 ALIGN=center
        STYLE="border: solid black .75pt; height: 3em; width: 6em;"&gt;
    &lt;FONT SIZE=+2&gt;C&lt;/FONT&gt;&lt;BR&gt;hideFocus=1&lt;BR&gt;hideAccel=0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;
&lt;P&gt;
Now, suppose that Window&amp;nbsp;C also decides to clear the accelerator
indicator.
It does the same thing as Window&amp;nbsp;B and sends itself a
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message with a &lt;CODE&gt;wParam&lt;/CODE&gt; of
&lt;CODE&gt;MAKEWPARAM(&lt;WBR&gt;UIS_&lt;WBR&gt;CLEAR, UISF_&lt;WBR&gt;HIDE&amp;shy;ACCEL)&lt;/CODE&gt;.
This time, the
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message handler for Window&amp;nbsp;C
sees that the &lt;CODE&gt;UISF_&lt;WBR&gt;HIDE&amp;shy;ACCEL&lt;/CODE&gt;
flag is already clear,
so the &lt;I&gt;clear&lt;/I&gt; action is redundant.
Message processing stops.
&lt;/P&gt;
&lt;P&gt;
These two examples show
the flow of the UI state change messages.
When somebody wants to suggest a change to the UI state,
they send themselves a
&lt;CODE&gt;WM_&lt;WBR&gt;CHANGE&amp;shy;UI&amp;shy;STATE&lt;/CODE&gt;
message with a description of what they want to change.
The above algorithm then kicks in to decide whether the change
is meaningful,
and if so, it notifies all the other windows in the hierarchy
about the new state.
&lt;/P&gt;
&lt;P&gt;
&lt;!-- forwardref: --&gt;
Next time&lt;/A&gt;,
we'll look at how this whole indicator state thing
gets off the ground.
&lt;/P&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10419105" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Code/">Code</category></item><item><title>Hey look, now I'm Director of Strategic Planning, oh, and my name also changed to Oliver Lee</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/15/10418647.aspx</link><pubDate>Wed, 15 May 2013 14:00:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10418647</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>16</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10418647</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/15/10418647.aspx#comments</comments><description>&lt;P&gt;
It looks like the Visio blog
&lt;A HREF="http://blogs.office.com/b/visio/archive/2013/04/18/data-linked-diagrams-creating-a-diagram-in-visio.aspx"&gt;
populated a sample organizational chart
with pictures of Microsoft employees&lt;/A&gt;,
and I am now Oliver Lee, Director of Strategic Planning.
&lt;/P&gt;
&lt;P&gt;
My secret identity has been revealed.
I'm moonlighting at Contoso.
&lt;/P&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10418647" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Non_2D00_Computer/">Non-Computer</category></item><item><title>What does GDI use biXPelsPerMeter and SetBitmapDimensionEx for?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/15/10418646.aspx</link><pubDate>Wed, 15 May 2013 14:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10418646</guid><dc:creator>Raymond Chen - MSFT</dc:creator><slash:comments>16</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/oldnewthing/rsscomments.aspx?WeblogPostID=10418646</wfw:commentRss><comments>http://blogs.msdn.com/b/oldnewthing/archive/2013/05/15/10418646.aspx#comments</comments><description>&lt;P&gt;
What does GDI use
&lt;CODE&gt;BITMAP&amp;shy;INFO&amp;shy;HEADER.&lt;WBR&gt;biXPels&amp;shy;Per&amp;shy;Meter&lt;/CODE&gt;
and
&lt;CODE&gt;Set&amp;shy;Bitmap&amp;shy;Dimension&amp;shy;Ex&lt;/CODE&gt;
for?
&lt;/P&gt;
&lt;P&gt;
Nothing.
&lt;/P&gt;
&lt;P&gt;
The
&lt;CODE&gt;BITMAP&amp;shy;INFO&amp;shy;HEADER.&lt;WBR&gt;biXPels&amp;shy;Per&amp;shy;Meter&lt;/CODE&gt;
and
&lt;CODE&gt;BITMAP&amp;shy;INFO&amp;shy;HEADER.&lt;WBR&gt;biYPels&amp;shy;Per&amp;shy;Meter&lt;/CODE&gt;
are completely ignored by GDI when loading a bitmap.
The values are there for the benefit of image-editing programs
who want to record additional information about the bitmap,
but GDI ignores them.
&lt;/P&gt;
&lt;P&gt;
Similarly, the
&lt;CODE&gt;Set&amp;shy;Bitmap&amp;shy;Dimension&amp;shy;Ex&lt;/CODE&gt;
and
&lt;CODE&gt;Get&amp;shy;Bitmap&amp;shy;Dimension&amp;shy;Ex&lt;/CODE&gt;
functions update a &lt;CODE&gt;SIZE&lt;/CODE&gt; structure
associated with each bitmap,
but GDI does nothing with the values,
aside from initializing them to zero when the bitmap is created.
&lt;/P&gt;
&lt;P&gt;
The value is there so that, for example,
a program which puts a bitmap on the clipboard can
specify the recommended physical dimensions of the bitmap,
in order to help
another program that reads the bitmap from the clipboard
(for example, a word processor)
decide how big to resize the bitmap when it is pasted.
&lt;/P&gt;
&lt;P&gt;
Whether any programs actually do this sort of thing I do not know.
&lt;/P&gt;
&lt;P&gt;
But that's what it's there for, in case anybody wanted to do it.
&lt;/P&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10418646" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/oldnewthing/archive/tags/Code/">Code</category></item></channel></rss>