| UID | NF:winuser.GetWindow | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| title | GetWindow function (winuser.h) | ||||||||||||||
| description | Retrieves a handle to a window that has the specified relationship (Z-Order or owner) to the specified window. | ||||||||||||||
| helpviewer_keywords |
|
||||||||||||||
| old-location | winmsg\getwindow.htm | ||||||||||||||
| tech.root | winmsg | ||||||||||||||
| ms.assetid | VS|winui|~\winui\windowsuserinterface\windowing\windows\windowreference\windowfunctions\getwindow.htm | ||||||||||||||
| ms.date | 12/05/2018 | ||||||||||||||
| ms.keywords | GW_CHILD, GW_ENABLEDPOPUP, GW_HWNDFIRST, GW_HWNDLAST, GW_HWNDNEXT, GW_HWNDPREV, GW_OWNER, GetWindow, GetWindow function [Windows and Messages], _win32_GetWindow, _win32_getwindow_cpp, winmsg.getwindow, winui._win32_getwindow, winuser/GetWindow | ||||||||||||||
| req.header | winuser.h | ||||||||||||||
| req.include-header | Windows.h | ||||||||||||||
| req.target-type | Windows | ||||||||||||||
| req.target-min-winverclnt | Windows 2000 Professional [desktop apps only] | ||||||||||||||
| req.target-min-winversvr | Windows 2000 Server [desktop apps only] | ||||||||||||||
| req.kmdf-ver | |||||||||||||||
| req.umdf-ver | |||||||||||||||
| req.ddi-compliance | |||||||||||||||
| req.unicode-ansi | |||||||||||||||
| req.idl | |||||||||||||||
| req.max-support | |||||||||||||||
| req.namespace | |||||||||||||||
| req.assembly | |||||||||||||||
| req.type-library | |||||||||||||||
| req.lib | User32.lib | ||||||||||||||
| req.dll | User32.dll | ||||||||||||||
| req.irql | |||||||||||||||
| targetos | Windows | ||||||||||||||
| req.typenames | |||||||||||||||
| req.redist | |||||||||||||||
| ms.custom | 19H1 | ||||||||||||||
| f1_keywords |
|
||||||||||||||
| dev_langs |
|
||||||||||||||
| topic_type |
|
||||||||||||||
| api_type |
|
||||||||||||||
| api_location |
|
||||||||||||||
| api_name |
|
||||||||||||||
| req.apiset | ext-ms-win-ntuser-window-l1-1-0 (introduced in Windows 8) |
Retrieves a handle to a window that has the specified relationship (Z-Order or owner) to the specified window.
Type: HWND
A handle to a window. The window handle retrieved is relative to this window, based on the value of the uCmd parameter.
Type: UINT
The relationship between the specified window and the window whose handle is to be retrieved. This parameter can be one of the following values.
| Value | Meaning |
|---|---|
|
The retrieved handle identifies the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved handle is NULL. The function examines only child windows of the specified window. It does not examine descendant windows. |
|
The retrieved handle identifies the enabled popup window owned by the specified window (the search uses the first such window found using GW_HWNDNEXT); otherwise, if there are no enabled popup windows, the retrieved handle is that of the specified window. |
|
The retrieved handle identifies the window of the same type that is highest in the Z order.
If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window. |
|
The retrieved handle identifies the window of the same type that is lowest in the Z order.
If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window. |
|
The retrieved handle identifies the window below the specified window in the Z order.
If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window. |
|
The retrieved handle identifies the window above the specified window in the Z order.
If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window. |
|
The retrieved handle identifies the specified window's owner window, if any. For more information, see Owned Windows. |
Type: HWND
If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is NULL. To get extended error information, call GetLastError. The function does not clear the last error information. To determine success or failure in case of NULL return value, clear the last error information by calling SetLastError function with 0 value, then call GetWindow. Function failure will be indicated by a return value of NULL and a GetLastError function result that is nonzero.
The EnumChildWindows function is more reliable than calling GetWindow in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed.
Conceptual
Reference