IsWindow Function

Declare Function IsWindow Lib "user32.dll" (ByVal hWnd As Long) As Long

Platforms

Desctiption & Usage

IsWindow determines if a given handle refers to a window or not. The function verifies that the handle in fact refers to a window, instead of one of the many other objects which handles can represent.

Return Value

If the handle does not refer to a window, the function returns 0. If the handle does refer to a window, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

hWnd
The handle to check if it refers to a window or not.

Example

' This code is licensed according to the terms and conditions listed here.

' Demonstrate handles refering to a window and not refering to a window.
Dim hWindow As Long  ' handle to a window (Form1, to be exact)
Dim hPen As Long  ' handle to a pen (the solid black stock pen)
Dim result As Long  ' result of the test

' Initialize the two handles.
hWindow = Form1.hWnd  ' hWindow now equals window Form1's handle
hPen = GetStockObject(BLACK_PEN)  ' hPen refers to a pen
' Verify that hWindow refers to a window.
result = IsWindow(hWindow)
If result = 0 Then
  Debug.Print "hWindow does not refer to a window."  ' won't happen
Else
  Debug.Print "hWindow refers to a window."  ' will happen
End If
' Verify that hPen does not refer to a window.
result = IsWindow(hPen)
If result = 0 Then
  Debug.Print "hPen does not refer to a window."  ' will happen
Else
  Debug.Print "hPen refers to a window."  ' won't happen
End If

See Also

IsChild

Category

Windows

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


Last Modified: August 1, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000 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/iswindow.html