The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

That’s about the size of it
Aug 9, 2005
0
0

That’s about the size of it

Raymond Chen
Raymond Chen

News reporters seem to have some difficulty reporting the size of things. In order to make things more accessible to their readers, they try to compare it to the size of an everyday object, but to me it seems they try a bit too hard. For example, this story about the recent rescue of the crew of a sunken submarine noted, [T]he layers of stretched nylon appeared to be as thick as a 1 1/2-inch cable. "As thick as a 1 1/2-inch cable". As opposed to "as thick as a 1 1/2-inch stick" or "as thick as a 1 1/2-inch thing that is about 1 1/2 inches thick". May I humbly suggest, "The laye...

Hey, who flattened the hills?
Aug 8, 2005
0
0

Hey, who flattened the hills?

Raymond Chen
Raymond Chen

This weekend, I went to a friend's house on Mercer Island to see the US Navy Blue Angels flight demonstration team perform. They do this every summer as part of Seattle's Seafair festival, but this was the first time I got to see the show up close and personal. The I-90 bridge is closed for safety reasons, and people are allowed to walk onto the highway (at least for a short distance) to get a better view of the demonstration. Two summers ago my friend invited me to his place, but I made the mistake of trying to drive to Mercer Island—traffic was horrific and I finally arrived just as the show was wrap...

The dangers of playing focus games when handling a WM_KILLFOCUS message
Aug 8, 2005
0
0

The dangers of playing focus games when handling a WM_KILLFOCUS message

Raymond Chen
Raymond Chen

I had noted last year that WM_KILLFOCUS is the wrong time to do field validation. Here's another example of how messing with the focus during a WM_KILLFOCUS message can create confusion. Consider an edit control that displays feedback via a balloon tip. For example, password edit controls often warn you if you're typing your password while CapsLock is in effect. One of the things you probably want to do is to remove the balloon tip if the user moves focus to another control, since there's no point telling the user about a problem with something they aren't using. You might be tempted to subclass the edit cont...

Have you made any assignments in this space?
Aug 5, 2005
0
0

Have you made any assignments in this space?

Raymond Chen
Raymond Chen

Riffing on Larry's profound distaste for the use of the word 'ask' as a noun (a distaste I share)... It's been three years since I heard the question "Have you made any assignments in this space?" during a meeting and I still don't know what the person was trying to say.

Why does the Internet Explorer animated logo arrange its frame vertically?
Aug 5, 2005
0
0

Why does the Internet Explorer animated logo arrange its frame vertically?

Raymond Chen
Raymond Chen

If you ever tried to build a custom animated logo for Internet Explorer, you cetainly noticed that the frames of the animation are arranged vertically rather than horizontally. Why is that? Because it's much more efficient. Recall that bitmaps are stored as a series of rows of pixels. In other words, if you number the pixels of a bitmap like this: 123 456 789 then the pixels are stored in memory in the order 123456789. (Note: I'm assuming a top-down bitmap, but the same principle applies to bottom-up bitmaps.) Now observe what happens if you store your animation strip horizontally: 12AB 34CD ...

On speaking a particular language in the presence of non-speakers
Aug 4, 2005
0
0

On speaking a particular language in the presence of non-speakers

Raymond Chen
Raymond Chen

Having grown up in a household where I didn't speak most of the languages my parents and their friends use, I'm quite accustomed to being surrounded by conversations in a language I have no chance of understanding. If people are more comfortable speaking in a particular language, I say let them. Some people object to this on the grounds that "They might be talking about me." Guess what: They almost certainly aren't. It may hurt your ego to learn this, but it's the truth: You're really not that fascinating to other people. It turns out that over 99.99% of all conversations in the world do not involve you to any ...

Double-clicking radio buttons
Aug 4, 2005
0
0

Double-clicking radio buttons

Raymond Chen
Raymond Chen

A subtlety that adds a level of polish to your dialogs is supporting double-clicked radio buttons as an abbreviation for "select + OK". (Or "select + Next" or "select + Finish" if the page is part of a wizard.) Consider the following dialog template and associated dialog procedure: 1 DIALOGEX DISCARDABLE 32, 32, 200, 76 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Sample" FONT 8, "MS Shell Dlg" BEGIN LTEXT "A mumbler is needed.",-1,7,8,100,10 AUTORADIOBUTTON "Do not &obtain a mumber now", 100,17,24,180,10 AUTORADIOBUTTON "Obtain a mumbler auto...

Watch out, there are Swedes in the hallway!
Aug 3, 2005
0
0

Watch out, there are Swedes in the hallway!

Raymond Chen
Raymond Chen

Whenever I go to IKEA Seattle, I try to speak Swedish with the people who work there, but it never works. Yesterday, I was heading to a colleague's office to drop off Symphony tickets. (A group of friends wanted tickets together, so the order was placed in my name, and I needed to distribute them to the people in the group.) As I neared his office, I noticed a crowd of people outside and realized that they were speaking Swedish. I tried to follow what they were saying, but of course since they were speaking among themselves, they weren't taking very much effort to enunciate clearly enough for a beginner to fo...

Drawing a monochrome bitmap with transparency
Aug 3, 2005
0
0

Drawing a monochrome bitmap with transparency

Raymond Chen
Raymond Chen

Last time, I left you with a brief puzzle. Here are two approaches. I am not a GDI expert, so there may be even better solutions out there. To emphasize the transparency, I'll change the window background color to the application workspace color. BOOL WinRegisterClass(WNDCLASS *pwc) { pwc->hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1); return __super::WinRegisterClass(pwc); } Method 1: A big MaskBlt. void RootWindow::PaintContent(PAINTSTRUCT *pps) { HDC hdcMem = CreateCompatibleDC(pps->hdc); if (hdcMem) { int cxCheck = GetSystemMetrics(SM_CXMENUCHECK); int cyCheck = GetSystemMet...