Declare Function IsChild Lib "user32.dll" (ByVal hWndParent As Long, ByVal hWnd As Long) As Long
IsChild determines if a parent-child relationship exists between two windows. The possible child window must be a direct descendant of the possible parent window. For example, if the possible child window is a child of a child of the possible parent window, the parent-child relationship does not exist.
If a parent-child relationship does not exist between the two windows, the function returns 0. If the relationship does exist, the function returns a non-zero value.
None.
' This code is licensed according to the terms and conditions listed here.
' Demonstrate a parent-child relationship and a non-parent-child
' relationship. Command1, a command button on window Form1, is a child
' of Form1. However, fellow window Form2 is not a child.
Dim result As Long ' result of the function
' Verify that Command1 is a child of Form1.
result = IsChild(Form1.hWnd, Command1.hWnd) ' see if Form1 is Command1's parent
If result = 0 Then
Debug.Print "Form1 is not Command1's parent window." ' won't happen
Else
Debug.Print "Form1 is Command1's parent window." ' will happen
End If
' Verify that Form2 is not a child of Form1.
result = IsChild(Form1.hWnd, Form2.hWnd) ' see if Form1 is Form2's parent
If result = 0 Then
Debug.Print "Form1 is not Form2's parent window." ' will happen
Else
Debug.Print "Form1 is Form2's parent window." ' won't happen
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/ischild.html