EnableWindow

Syntax

BOOL EnableWindow(hWnd,bEnable)

This function enables or disables mouse and keyboard input to the specified window or control. When input is disabled, input such as mouse clicks and key presses are ignored by the window. When input is enabled, all input is processed.

The EnableWindow function enables mouse and keyboard input to a window if the bEnable parameter is nonzero, and disables it if bEnable is zero.

Parameter Type/Description  

hWnd HWND Identifies the window to be enabled or disabled.  
bEnable BOOL Specifies whether the given window is to be enabled or disabled.  

Return Value

The return value specifies the outcome of the function. It is nonzero if the window is enabled or disabled as specified. It is zero if an error occurs.

Comments

A window must be enabled before it can be activated. For example, if an application is displaying a modeless dialog box and has disabled its main window, the main window must be enabled before the dialog box is destroyed. Otherwise, another window will get the input focus and be activated. If a child window is disabled, it is ignored when Windows tries to determine which window should get mouse messages.

Initially, all windows are enabled by default. EnableWindow must be used to disable a window explicitly.