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.
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.