IsWindowEnabled Function

Declare Function IsWindowEnabled Lib "user32.dll" (ByVal hwnd As Long) As Long

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

IsWindowEnabled determines if a window is currently enabled or disabled. If a window is disabled, it cannot receive the focus and will ignore any attempted input. Many types of windows, such as buttons and other controls, will appear grayed when disabled. The function returns 0 if the window is disabled, or a non-zero value if the window is enabled.

hwnd
A handle to the window to determine if it is enabled or disabled.

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

See Also: EnableWindow
Category: Windows

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/i/iswindowenabled.html