GetWindow Function

Declare Function GetWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal wCmd As Long) As Long

GetWindow returns the handle of a window related to a given window. The relations generally deal with child-parent relationships or relationships between children of the same parent window. The exact relation is specified by wCmd. If an error occurs or there is no window having the specified relation, the function instead returns 0.

hwnd
The handle of the first window in the relation.
wCmd
Exactly one of the following flags specifying the relationship between the two windows:
GW_HWNDFIRST = 0
The highest window in the Z-order having the same parent as the given window.
GW_HWNDLAST = 1
The lowest window in the Z-order having the same parent as the given window.
GW_HWNDNEXT = 2
The window below the given window in the Z-order.
GW_HWNDPREV = 3
The window above the given window in the Z-order.
GW_OWNER = 4
The window that owns the given window (not to be confused with the parent window).
GW_CHILD = 5
The topmost of the given window's child windows. This has the same effect as using the GetTopWindow function.

Example:

' Flash the window below Form1 in the Z-order once
next = GetWindow(Form1.hWnd, GW_HWNDNEXT)  ' next window in Z-order
' The next three lines flash this window using FlashWindow and Sleep
x = FlashWindow(next, 1): Sleep 250
x = FlashWindow(next, 1): Sleep 250
x = FlashWindow(next, 0)

Related Calls: GetActiveWindow, GetTopWindow
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/getwindow.html