PRB: Disabling All Controls in a Dialog Box Hangs Windows

ID Number: Q84001

3.00

WINDOWS

Summary:

SYMPTOMS

Under Windows 3.0, disabling all controls in a dialog box causes

Windows to hang.

CAUSE

The Dialog Manager enters an infinite loop searching for an enabled

control that can receive the input focus.

RESOLUTION

Modify the design of the dialog box to include a hidden control

that is always enabled.

This situation does not occur under Windows 3.1.

More Information:

An application might encounter conditions under which all controls in

a dialog box should be disabled. For example, an application might

disable an edit control to prevent the user from entering text under

certain circumstances. If conditions occur such that the application

disables all controls in a dialog box, Windows will hang if the user

uses the keyboard to move the input focus between controls.

To address this situation, modify the dialog box template to include

an enabled owner-draw button at coordinates (0, 0). When any controls

in the dialog box are enabled, disable the button to prevent it from

receiving the input focus. When the application disables the last

"regular" control, enable the button. Through this procedure, at least

one control is always enabled.

If the application ignores the WM_DRAWITEM messages that draw the

owner-draw button, the button control is invisible to the user.

Additional reference words: 3.00