Skip to content

Latest commit

 

History

History
200 lines (161 loc) · 7.37 KB

File metadata and controls

200 lines (161 loc) · 7.37 KB
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
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
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
GetWindow
winuser/GetWindow
dev_langs
c++
topic_type
APIRef
kbSyntax
api_type
DllExport
api_location
ext-ms-win-rtcore-ntuser-window-ext-l1-1-1.dll
ext-ms-win-ntuser-window-l1-1-6.dll
ext-ms-win-ntuser-window-l1-1-5.dll
User32.dll
API-MS-Win-NTUser-IE-Window-l1-1-0.dll
ie_shims.dll
API-MS-Win-RTCore-NTUser-Window-l1-1-0.dll
minuser.dll
Ext-MS-Win-NTUser-Window-l1-1-0.dll
Ext-MS-Win-NTUser-Window-l1-1-1.dll
Ext-MS-Win-NTUser-Window-l1-1-2.dll
Ext-MS-Win-RTCore-NTUser-Window-Ext-l1-1-0.dll
ext-ms-win-ntuser-window-l1-1-3.dll
Ext-MS-Win-NTUser-Window-L1-1-4.dll
api_name
GetWindow
req.apiset ext-ms-win-ntuser-window-l1-1-0 (introduced in Windows 8)

GetWindow function

-description

Retrieves a handle to a window that has the specified relationship (Z-Order or owner) to the specified window.

-parameters

-param hWnd [in]

Type: HWND

A handle to a window. The window handle retrieved is relative to this window, based on the value of the uCmd parameter.

-param uCmd [in]

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
GW_CHILD
5
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.
GW_ENABLEDPOPUP
6
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.
GW_HWNDFIRST
0
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.

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

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

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

GW_OWNER
4
The retrieved handle identifies the specified window's owner window, if any. For more information, see Owned Windows.

-returns

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.

-remarks

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.

-see-also

Conceptual

EnumChildWindows

Reference

Windows