The information in this article applies to:
SUMMARYSome combinations of modal and modeless dialog boxes create undesirable side effects due to their design and implementation. This article describes the side effects and methods to avoid them. The following list of side effects may not be complete, and will be updated as additional side effects are discovered. Side Effects
MORE INFORMATIONThe following files are available for download from the Microsoft
Download Center. Click the file names below to download the files: http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. Sections A and B below list some characteristics of the design and implementation of modal and modeless dialog boxes. Section C below explains the causes of the side effects listed above and techniques to avoid these side effects. Section A: Characteristics of a Modal Dialog Box
Section B: Characteristics of a Modeless Dialog Box
Section C: Explaining the Side EffectsSide Effect 1SymptomsWhen a modeless dialog box is created as a child of a modal dialog box, the keyboard cannot be used to change the focus. Cause The modal dialog box's message loop does not provide the functionality of the IsDialogMessage() function. Resolution Substitute a modeless dialog box for the modal dialog box. To make the parent modeless dialog box appear modal, disable its owner window in the code to process the WM_INITDIALOG message. When a modal dialog box is in its message loop, all windows in the application, including each modeless dialog box, receive its messages from the modal dialog box's message loop. However, this message loop does not provide the functionality of IsDialogMessage(). Side Effect 2SymptomsWhen a modeless dialog box is owned by a modal dialog box, the keyboard cannot be used to change the focus. Cause The modal dialog box's message loop does not provide the functionality of the IsDialogMessage() function. Resolution Substitute a modeless dialog box for the modal dialog box. To make the parent modeless dialog box appear modal, disable its owner window in the code to process the WM_INITDIALOG message. Side Effect 3SymptomsIf a modeless dialog box is destroyed during the processing of the WM_INITDIALOG message for a modal dialog box owned by the application's top- level window, the focus moves to another application. Cause No window is available to receive the focus. Resolution Substitute a modeless dialog box for the modal dialog box, as above. Disable the owner window (to simulate modality) only after the modeless dialog box is destroyed. Then Windows can put the input focus back to the top window until the simulated modal dialog box is displayed. Windows sends a WM_INITDIALOG message to a modal dialog box just before the dialog is made visible. As part of destroying a window that has the input focus, Windows removes the focus from the window and gives the focus to another window. If the new modal dialog box destroys the modeless dialog box as it processes a WM_INITDIALOG message, the modal dialog box is not yet visible and cannot receive the input focus. Unless the application has other visible windows, the only window that can receive the input focus is the top-level window. However, because the top-level window owns the new modal dialog box, it is disabled and cannot receive the input focus. Because none of the active application's windows are eligible to receive the input focus, Windows activates another application and gives the input focus to one of its windows. When this other application receives the focus, it moves to the front, over the application that created the modal dialog box. As soon as the original application processes the WM_INITDIALOG message, the modal dialog box is displayed and brought to the front. The scenario above causes another application to be "sandwiched" between the application's main window and the modal dialog box, which may confuse the user. The following diagram illustrates the visual effect:
Additional query words:
Keywords : kbfile kbsample kb16bitonly kbDlg kbGrpUser kbWinOS310 kbWinOS300 |
Last Reviewed: December 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |