The Old New Thing

Modality, part 7: A timed MessageBox, the cheap version

As we noted at the end of part 3, now that you know the conventions surrounding the message you can put them to your advantage. The more robust you want the function to be, the more work you need to do. Here's the cheap version, based on the sample in the Knowledge Base, but with some additional bug fixes. This function acts ...

Modality, part 6: Interacting with a program that has gone modal

Earlier we saw the importance of setting the right owner window for modal UI. It is also important, when manipulating a window, to respect its modality. For example, consider the program we ended up with last time, the one which calls the function to display a modal dialog. If we wanted to get that program to exit and sent a message to ...

"Support our troops" wristbands provide only 1/3 support

Over at Slate, Timothy Noah notes how much money from so-called "awareness bracelets" actually go to the causes they purport to champion. In summary, I find it ironic that the "Support our troops" bracelet doesn't actually support our troops. And is yellow really the right color to use to demonstrate support for the military...

Two brief reminiscences on the Windows XP "Comments?" button

In beta versions of Windows XP, there was special code in the window manager to give every window a link in the upper right corner called "Comments?" which if clicked on displayed a dialog that allowed you to submit feedback to Microsoft about that window. Since this was a beta release, there was no anonymity when you submitted feedback...

Modality, part 5: Setting the correct owner for modal UI

Here is the very simple fix for the buggy program we presented last time. We have fixed the problem by passing the correct owner window for the modal UI. Since is modal, it disables the owner while the modal UI is being displayed, thereby preventing the user from destroying or changing the owner window's state when it is not expecting ...

Modality, part 3: The WM_QUIT message

After our two quick introductions to modality, we're now going to dig in a little deeper. The trick with modality is that when you call a modal function, the responsibility of message dispatch is handled by that function rather than by your main program. Consequently, if you have customized your main program's message pump, those ...

Modality, part 2: Code-modality vs UI-modality

Last time, we saw an example of code that was UI-modal but not code-modal. The opposite is also true: You can have code-modality without UI-modality. In fact, this is far more common than the UI-modal-but-not-code-modal scenario. You encounter modal loops without a visible change in UI state when you drag the scroll bar thumb, drag the window...

Modality, part 1: UI-modality vs code-modality

From the end-users' point of view, modality occurs when the users are locked into completing a task once it is begun, with the only escape being to cancel the entire operation. Opening a file is an example of a modal operation: Once the "Open" command has been selected, users have no choice but to select a file for opening (or to cancel the ...