Dialog boxes and property sheets are similar in that most of the time, you use them modally. You call DialogBox
or PropertySheet
, and the function doesn’t return until the user closes the dialog box or property sheet. But you can also use dialog boxes and property sheets modelessly, using CreateDialog
or by including the PSH_MODELESS
flag when you call PropertySheet
.
One of the more common problems people have when managing a modeless property sheet is finding that keyboard navigation doesn’t work. The reason is the same as with modeless dialog boxes: You forgot to process dialog messages.
But if you use the wrong function to process the dialog messages, then you don’t get the right behavior.
If you get confused and use IsDialogMessage
to process dialog messages for a property sheet, things will seem to work mostly okay, but most notably, the Ctrl+Tab and Ctrl+Shift+Tab keyboard shortcuts won’t work. Those hotkeys are new to property sheets; those keys mean nothing special to dialog boxes, so the IsDialogMessage
function won’t do anything special if the user types them. There are other property sheet behaviors that go beyond plain dialog boxes, but the keyboard navigation among tabs is what users will probably notice first.
The other mix-up I’ve seen is sending the PSM_ISDIALOGMESSAGE
message to a modeless dialog box, even though the dialog box isn’t a property sheet. The PSM_ISDIALOGMESSAGE
message is handled only by property sheets; if you send it to something else, who know what’ll happen? Remember that PSM_ISDIALOGMESSAGE
is in the WM_USER
range, and messages in that range belong to the window class.
This is simply another case of keeping track of what you’re doing and using the mechanism appropriate for what you have. You’re already used to doing this in real life: If you travel to Canada and want to buy something from a vending machine, you have to put in Canadian money, not Turkish lira.
0 comments