EnableWindow Function

Declare Function EnableWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal fEnable As Long) As Long

Platforms: Win 32s, Win 95/98, Win NT

EnableWindow enables or disables a window. If a window is disabled, it cannot receive the focus and will ignore any attempted input. Some types of windows, such as buttons and other controls, will appear grayed when disabled, although any window can be enabled or disabled. The function returns 0 if the window had previously been enabled, or a non-zero value if the window had been disabled.

hwnd
A handle to the window to enable or disable.
fEnable
If 0, the window will be disabled. If non-zero, the window will be enabled.

Example:

' Reverse the enabled status of window Command1.  If the window is 
' disabled, enable it; if it is enabled, disable it.
Dim wasenabled As Long  ' receives enabled/disabled status of Command1
Dim retval As Long  ' return value

' Determine if the window Command1 is currently enabled or not.
wasenabled = IsWindowEnabled(Command1.hWnd)
If wasenabled = 0 Then  ' if not enabled, enable it
  retval = EnableWindow(Command1.hWnd, 1)
Else  ' if enabled, disable it
  retval = EnableWindow(Command1.hWnd, 0)
End If

Related Call: IsWindowEnabled
Category: Windows
Back to the index.


Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/e/enablewindow.html