September 22nd, 2008

I’ve seen why people steal the foreground window for their dialog box

Now, it may very well be true that many people who use GetForegroundWindow() as the owner for a dialog box because they don’t know any better, but I’m not convinced that everyone who does so did it out of ignorance; I’m sure there’s some malice in there, too. Here’s how it may have gone down:

Bug: I start the product setup, and then I go and work on something else, and then setup hits a problem, but the error message can’t be seen because it’s hidden behind another window.

Result: Setup fails to complete.

Expected: Error dialog is visible so user can address the problem and allow setup to complete.

The programmer who is told to fix the bug, of course, tries to figure out how to fix the bug, and since the bug report said that the error dialog needs to be visible even when other programs are running, the programmer gives a shrug and does what the bug report says should happen.

And that’s how the installation program ends up disabling Task Manager.

(Commenter Jamie has another very plausible scenario.)

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.