Showing results for 2011 - Page 3 of 31 - The Old New Thing

Dec 7, 2011
0
0

GetParent, just as confusing as EnumClaw, but it's an actual function!

Raymond Chen
Raymond Chen

The function , documented as returning "the child or the parent of the window", was a joke, but there's a function whose behavior is just as confusing as the joke function : . The function returns the parent window, or owner window, or possibly neither. All that's left is for it to be a floor wax and it'll have everything covered. The idea behi...

Code
Dec 6, 2011
0
0

A feature I didn't even know existed much less had a name: Color hot-track

Raymond Chen
Raymond Chen

I hadn't even noticed this until somebody pointed it out: When you hover your mouse over a button in the Windows 7 taskbar which corresponds to a running application, the taskbar button lights up in a color that matches the colors in the icon itself. (And even more subtly, the lighting effect is centered on the mouse.) This feature even has ...

Tips/Support
Dec 5, 2011
0
0

Why does my program still show up in the Programs and Features folder after my uninstaller exits?

Raymond Chen
Raymond Chen

A customer reported that they were having problems with their program entry in the Programs and Features folder (formerly known as Add and Remove Programs, formerly known as Add/Remove Programs). When the user goes to the Programs and Features folder, selects their program, and clicks Uninstall, the uninstaller runs, but after the uninstaller exits...

Code
Dec 2, 2011
0
0

Don't let more than one process try to read from stdin at the same time

Raymond Chen
Raymond Chen

A customer reported a problem with a program that ran a series of other programs in parallel. We have a main program (call it main.exe) that runs a bunch of child processes with stdout and stderr redirected. (We are not redirecting stdin.) We've found that some of the child processes get stuck inside the C runtime startup code on a call to on the...

Code
Dec 1, 2011
0
0

Our code needs to run on multiple platforms with different rules, so we follow none of them!

Raymond Chen
Raymond Chen

A customer was encountering sporadic crashes in their 64-bit application, and upon investigation, the problem was traced to a misaligned RSP register. We saw some time ago that the Windows x64 calling convention requires the RSP register to be 16-byte aligned. The customer traced the source of the misalignment to a third-party library they were ...

Other
Nov 30, 2011
0
0

If you protect a write with a critical section, you may also want to protect the read

Raymond Chen
Raymond Chen

It is common to have a critical section which protects against concurrent writes to a variable or collection of variables. But if you protect a write with a critical section, you may also want to protect the read, because the read might race against the write. Adam Rosenfield shared his experience with this issue in a comment from a few years ...

Code
Nov 29, 2011
0
0

Things I've written that have amused other people, Episode 8

Raymond Chen
Raymond Chen

In a technical discussion, I opened a reply with Bob's paper which I haven't yet read points out that... Some people wrote to me to say that the've added this quote to their file in the hopes of being able to use it themselves someday. For those who are curious, I found the technical discussion in question. It had to do with whether the foll...

Non-Computer
Nov 28, 2011
0
0

Why is CLIPFORMAT defined to be a WORD rather than a UINT?

Raymond Chen
Raymond Chen

Commenter Ivo wants to know if the function returns a , why is the data type defined to be a ? Since a is smaller than a , you have to stick in a cast every time you assign the result of to a . Rewind to 16-bit Windows. Back in those days, a and a were the same size, namely, 16 bits. As a result, people got lazy about the distinction. ...

History
Nov 25, 2011
0
0

How to insert a large number of items into a treeview efficiently

Raymond Chen
Raymond Chen

Just a quick tip today. If you need to insert a large number of items into a treeview, like tens of thousands, then it's much more efficient to insert them "backwards". (I'm ignoring for now the usability question of having a treeview that large in the first place.) In other words, instead of do it this way: Why is backwards-insertion faster...

Code
Nov 24, 2011
0
0

How can I extend the deadline for responding to the PBT_APMSUSPEND message?

Raymond Chen
Raymond Chen

A customer observed that starting in Windows Vista, the deadline for responding to the message was reduced from twenty seconds to two seconds. Their program needs more than two seconds to prepare for a suspend and they wanted to know how they could extend the deadline. The program communicates with a device, and if they don't properly prepare the...

Code