The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts

When will GetMessage return -1?

A source of great consternation is the mysterious return value from : If there is an error, the return value is −1. For example, the function fails if is an invalid window handle or is an invalid pointer. That paragraph has caused all sorts of havoc, because it throws into disarray the standard message pump: But don't worry, the standard message pump is safe. If your parameters are exactly then will not fail with . Originally, the function did not have a failure mode. If you passed invalid parameters, then you invoked undefined behavior, and you probably crashed. Later, somebody sai...

Does this operation work when file system redirection is disabled? The default answer is NO

A customer reported that when their program called to get the icon for a folder, the call failed. "It works on some machines but not others. We don't know what the difference is between the working and non-working machines." They included the offending function from their program, but everything in the function looked good. The problem was something outside the function itself. Eventually, the customer confessed that they had called the function to disable file system redirection, and the call to took place while redirection was disabled. "We found that if we re-enable file system redirection before calling ...

The x86 architecture is the weirdo: Structured exception handling

If your reference architecture is x86, then you will think that everything it does is normal and the rest of the world is weird. Except it's the other way around: The x86 architecture is the weirdo. I was reminded of this when commenter 640k complained, on the subject of what I think is table-based structured exception handling, "It would be interesting to know why this 'invention' was introduced in 64-bit Windows when no other version of Windows requires it." (The original text was "when no other OS requires it", but I'm assuming that this was in the context of Windows-based OS, since unix doesn't have struc...

Raymond’s highly scientific predictions for the 2013 NCAA men’s basketball tournament

Once again, it's time for Raymond to come up with an absurd, arbitrary criterion for filling out his NCAA bracket. This year, I look at the number of fans of the basketball team's official Facebook page, or one tenth of the number of fans of the school's athletic department, whichever is greater. The fraction 1/10 is completely arbitrary, but that's what makes this algorithm highly scientific. Notes on this year's algorithm: Once the field has been narrowed to four teams, the results are determined by a coin flip. (I should have done this when the field reduced to eight teams rather than four, b...

Microspeak: Science project

A science project is a feature that is really cool and challenging from a technological standpoint but is way overkill for the end-user scenario at hand. Back in the late 1990's, a bunch of us cooked up this idea for a networked screen saver that ran at night after most people had gone home from work. You told it the physical location and compass orientation of everybody's monitor. The networked screen saver created a virtual red bouncing ball that traveled around the building in three dimensions. The screen saver showed a viewport into the three-dimensional virtual world that contained the bouncing ball. Th...

It may be your birthday, but why stop at just the day? Think big!

I had the pleasure of meeting a friend of a friend who is an odd, quirky sort, in a wholly endearing sort of way. When her birthday comes around, she isn't satisfied to have just one day of celebration. Or even a week. No, she takes the entire month. The entire month of March is open season for taking her to dinner, getting her a gift, or otherwise celebrating what an awesome person she is. Every year I receive an automated reminder, "X's birthday: all day." And I say to myself, "What, just the day?" Bonus chatter: Her father is from Turkey, and her mother is Swiss (so she's a deli sandwich, half turkey, hal...

Manipulating the positions of desktop icons

Just putting together the pieces you already have.

Playing with the Windows Animation Manager: Moving lots of stuff around

We saw last time a sample program that moved a circle around. Today I'll try to build the classic demo of animating a lot of objects in a list. This isn't the prettiest code, but I wanted to make as few changes as possible. Start with the Timer-Driven Animation, and make these changes to the MainWindow.h header file. struct Item { IUIAnimationVariable *m_pAnimationVariableX; IUIAnimationVariable *m_pAnimationVariableY; Gdiplus::Color m_color; }; class MainWindow { ... // HRESULT ChangeColor( // DOUBLE red, // DOUBLE green, // DOUBLE blue // ); ...

Playing with the Windows Animation Manager: Fixing a sample

Windows 7 provides a component known as the Windows Animation Manager, known to some people by its acronym WAM, pronounced "wham". There are some nice sample programs for WAM on MSDN, but for some reason, the authors of the samples decided to animate the three color components of a resultant color. Because apparently the authors of those sample programs can look at a color and say, "Oh, clearly the red component of this color increases gradually at first, then speeds up its rate of increase, and then slows back down until it reaches its final value; while simultaneously the blue component is doing the o...