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

How do I access the magic IEEE floating point values like NaN in code?

There are functions like , , , and for detecting that a floating point value is one of the special values like NaN, but how do you actually generate one of these values? You can access these values from the template. Wait, where's negative infinity? The compiler folks provided these handy little definitions for when you need to generate a special value (as opposed to merely detecting one), and for which the template comes up short. Disclaimer: Applies to Microsoft Visual Studio. Your mileage may vary. Use the template when available. Bonus chatter: Note that you must use functions like to detect...

Everyday is Grammer Day

March fourth is not just a pun on march forth, but it's also National Grammar Day, sponsored by the Society for the Promotion of Good Grammar.

What happens if I drag the mouse by exactly the amount specified by SM_CXDRAG?

The drag sensitivity is specified by the system metrics and . What happens if I drag the mouse by exactly the amount specified by these two parameters? Nothing. These parameters control the drag insensitivity of the mouse. If your mouse motion is less than or equal to this amount, then nothing happens. This is spelled out in the documentation for : The number of pixels on either side of a mouse-down point that the mouse pointer can move before a drag operation begins. It's how far the mouse can move before the system detects a drag. In code, the algorithm is as follows: Some people appear to have re...

Voicemail security, even stronger than bank security

Microsoft's telephone department takes security very seriously. Your voicemail password must be at least eight digits long. By comparison, the password for my ATM card is only four digits long. Because voicemail is that important, I guess. (Yes, I know about two-factor authentication. I'm writing this only half-jokingly.)

Microspeak: Dialogue

Why have a conversation when you can dialogue? I think this is minimal work, but do others care? If they don't, then this is one for the ideas that failed bin. If they do, well let's dialogue... No need to talk when you can dialogue.

Chilly Hilly 2010 kicked my butt

This year, I was woefully unprepared for the annual Chilly Hilly ride, not having gotten on my bicycle for the entire month of February. And I paid dearly for this lack of preparation, conking out and ending up walking up some of the last few hills. I rode with a few other people, but I quickly ended up lagging behind them. They would sometimes stop to let me catch up, but I told them not to bother and just go at their own pace. At one point, I ran over a nail and lost precious time to a flat tire. (I took the flat tire as an opportunity to take my midpoint break, since it occurred just a half mile or so from t...

When does STARTF_USESHOWWINDOW override the parameter passed to ShowWindow()?

kokorozashi wants to know what the rules are which govern when the second parameter to is overridden by the flag. The guiding principle is that the parameter is ignored if the window manager thinks that the window you're creating is the application's main window. The details behind the implementation of this principle change over time, so everything from here down is implementation detail and should not be relied upon. I'm providing it merely to satisfy your curiosity. To reiterate, do not rely on information in the second half of this article because it can and will change. In fact, just to emphasize the ...

Microwave popcorn enthusiast proudly proclaims, "I *am* popcorn!"

Oscar Night is a few weeks away, but when you settle in to watch the show with your bowl of popcorn, please be aware that inhaling deeply from the fumes of a freshly-opened bag of microwave popcorn is not the greatest decision you can make from a health standpoint. (Then again, you probably ought to reconsider eating microwave popcorn in the first place, but let's leave that aside.) A disease informally known as popcorn lung afflicts people who work in popcorn factories and has been known since 2002. But in 2007, doctor diagnosed the first case of popcorn lung in an end-user. The risk is not from eating the popc...

It's fine to use fibers, but everybody has to be on board with the plan

We saw fibers a long time ago when I looked at how you can use fibers as a form of coroutines to simplify the writing of enumerators. A fiber is a handy tool, but it's a tool with very sharp edges. Since fibers are promiscuous with threads, you have to be careful when running code that cares about what thread it is running on, because that code may discover that its thread changed out from under it. For example, critical sections and mutexes remember which thread owns them. If you enter a critical section on a fiber, and then you unschedule the fiber, then reschedule it onto a different thread, and then you l...