GetParent Function

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

GetParent returns the handle of the parent window of another window. For example, the parent of a button would normally be the form window it is in. If successful, the function returns a handle to the parent window. If it fails (for example, trying to find the parent of a non-window), it returns 0.

hwnd
The handle of the window to find the parent of.

Example:

' This will work if button Command1 sits directly on form Form1
Debug.Print GetParent(Command1.hWnd)
Debug.Print Form1.hWnd  ' these two should be the same value

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


Back to Paul Kuliniewicz's Home Page
E-mail: Borg953@aol.com
This page is at http://members.aol.com/Borg953/api/functions/getparent.html