The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

A question about proper disposal of unwanted items with an unhelpful answer
May 21, 2013
Post comments count 0
Post likes count 0

A question about proper disposal of unwanted items with an unhelpful answer

Raymond Chen
Raymond Chen

On an internal mailing list about home maintenance and ownership, somebody asked: I have a handful of items that I need to get rid of and probably should not toss into the regular garbage. Any thoughts? The best reply was an unhelpful one. You've pretty much got all the components you need to build a bomb. Why dispose of them?

The importance of remembering parity in a back-and-forth race on your flying bicycle
May 20, 2013
Post comments count 0
Post likes count 0

The importance of remembering parity in a back-and-forth race on your flying bicycle

Raymond Chen
Raymond Chen

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, I also made the team. 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. 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 co...

Copying a file to the clipboard so you can paste it into Explorer or an email message or whatever
May 20, 2013
Post comments count 0
Post likes count 1

Copying a file to the clipboard so you can paste it into Explorer or an email message or whatever

Raymond Chen
Raymond Chen

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. #include <windows.h> #include <shlobj.h> #include <atlbase.h> #include <shlobj.h> class COleInitialize { public: COleInitialize() : m_hr(OleInitialize(NULL)) { } ~COleInitialize() { if (SUCCEEDED(m_hr)) OleUninitialize(); } operator HRESULT() const { return m_hr; } HRESULT m_hr; }; // GetUIObjectOfFile in...

Who sends the initial WM_UPDATEUISTATE message?
May 17, 2013
Post comments count 0
Post likes count 0

Who sends the initial WM_UPDATEUISTATE message?

Raymond Chen
Raymond Chen

Last time, we looked at the confusingly-named WM_UPDATE­UI­STATE and WM_CHANGE­UI­STATE messages. But how does the whole indicator thingie get off the ground? The default state for a window is to show all indicators. But as a special trick, the dialog manager will send a WM_UPDATE­UI­STATE message with UIS_INITIALIZE 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 th...

Your electric fan is trying to kill you, and other cultural superstitions
May 16, 2013
Post comments count 0
Post likes count 0

Your electric fan is trying to kill you, and other cultural superstitions

Raymond Chen
Raymond Chen

In Korea, it is generally believed that leaving a fan on in an enclosed room can be fatal. Ken Jennings looks at cultural superstitions and wrote a Slate article focusing on the scourge of Korean fan death. 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. 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!) Clarification: Please re...

Untangling the confusingly-named WM_UPDATEUISTATE and WM_CHANGEUISTATE messages
May 16, 2013
Post comments count 0
Post likes count 0

Untangling the confusingly-named WM_UPDATEUISTATE and WM_CHANGEUISTATE messages

Raymond Chen
Raymond Chen

I always get confused by the and 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. 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½″×11″ 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 r...

Hey look, now I’m Director of Strategic Planning, oh, and my name also changed to Oliver Lee
May 15, 2013
Post comments count 0
Post likes count 0

Hey look, now I’m Director of Strategic Planning, oh, and my name also changed to Oliver Lee

Raymond Chen
Raymond Chen

It looks like the Visio blog populated a sample organizational chart with pictures of Microsoft employees, and I am now Oliver Lee, Director of Strategic Planning. My secret identity has been revealed. I'm moonlighting at Contoso.

What does GDI use biXPelsPerMeter and SetBitmapDimensionEx for?
May 15, 2013
Post comments count 0
Post likes count 0

What does GDI use biXPelsPerMeter and SetBitmapDimensionEx for?

Raymond Chen
Raymond Chen

What does GDI use and for? Nothing. The and 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. Similarly, the and functions update a structure associated with each bitmap, but GDI does nothing with the values, aside from initializing them to zero when the bitmap is created. 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 prog...

Microspeak: booked
May 14, 2013
Post comments count 0
Post likes count 0

Microspeak: booked

Raymond Chen
Raymond Chen

Remember, the term Microspeak is not tightly scoped to mean jargon used only at Microsoft. It's jargon used at Microsoft more often than in general usage. Today, it's a term that you really need to master if you want to talk with others about project planning. To book a feature is to commit to implementing the feature, including assigning resources to get it done. This means finding designers to design the feature, developers to implement it, and testers to test it, as well as (the hardest part) finding time in the schedule to do it. The resource that is in shortest supply is usually time, since there is no wa...