WinBeginEnumWindows: Difference between revisions
Created page with "This function begins the enumeration process for all of the immediate child windows of a specified window. ==Syntax== WinBeginEnumWindows(hwnd); ==Parameters== ;hwnd (HWND..." |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
This function begins the enumeration process for all of the immediate child windows of a specified window. | This function begins the enumeration process for all of the immediate child windows of a specified window. | ||
==Syntax== | ==Syntax== | ||
WinBeginEnumWindows(hwnd) | WinBeginEnumWindows(hwnd) | ||
==Parameters== | ==Parameters== | ||
;hwnd (HWND) - input | ;hwnd ([[HWND]]) - input:Handle of the window whose child windows are to be enumerated. | ||
:Handle of the window whose child windows are to be enumerated. | :;HWND_DESKTOP:Enumerate all main windows | ||
:;HWND_OBJECT:Enumerate all object windows | |||
:;HWND_DESKTOP | :;Other:Enumerate all immediate children of the specified window. | ||
:;HWND_OBJECT | |||
:;Other | |||
==Returns== | ==Returns== | ||
; henumHenum (HENUM) - returns | ;henumHenum (HENUM) - returns:Enumeration handle. | ||
:Enumeration handle. | |||
:This is used in subsequent calls to the WinGetNextWindow function to return the immediate child-window handles in succession. | :This is used in subsequent calls to the WinGetNextWindow function to return the immediate child-window handles in succession. | ||
:When the application has finished the enumeration, the enumeration handle must be destroyed with the WinEndEnumWindows call. | :When the application has finished the enumeration, the enumeration handle must be destroyed with the WinEndEnumWindows call. | ||
Line 23: | Line 17: | ||
==Errors== | ==Errors== | ||
Possible returns from WinGetLastError | Possible returns from WinGetLastError | ||
;PMERR_INVALID_HWND (0x1001) | ;PMERR_INVALID_HWND (0x1001):An invalid window handle was specified. | ||
:An invalid window handle was specified. | |||
==Remarks== | ==Remarks== | ||
This function remembers the window hierarchy at the time of invocation of the call. Thereafter the information is referenced by use of the henumHenum parameter and does not change during the enumeration by the WinGetNextWindow call. The windows are enumerated in the z-order at the time enumeration is begun, with the topmost child window enumerated first. | This function remembers the window hierarchy at the time of invocation of the call. Thereafter the information is referenced by use of the henumHenum parameter and does not change during the enumeration by the [[WinGetNextWindow]] call. The windows are enumerated in the z-order at the time enumeration is begun, with the topmost child window enumerated first. | ||
Only the immediate children of the specified window are enumerated; child windows of the child windows are excluded. | Only the immediate children of the specified window are enumerated; child windows of the child windows are excluded. | ||
The enumerated windows are not locked by this function and can thus be destroyed between the time that it is called and the time that the WinGetNextWindow function is used to obtain the handle for the window. | The enumerated windows are not locked by this function and can thus be destroyed between the time that it is called and the time that the WinGetNextWindow function is used to obtain the handle for the window. | ||
==Example Code== | ==Example Code== | ||
This example begins window enumeration of all main windows (i.e. all immediate children of the Desktop), after which WinGetNextWindow is called in a loop to enumerate all the children, until all children are found and the enumeration ends. | This example begins window enumeration of all main windows (i.e. all immediate children of the Desktop), after which WinGetNextWindow is called in a loop to enumerate all the children, until all children are found and the enumeration ends. | ||
<pre> | <pre> | ||
#define INCL_WINWINDOWMGR /* Window Manager Functions */ | #define INCL_WINWINDOWMGR /* Window Manager Functions */ |
Latest revision as of 04:11, 6 April 2025
This function begins the enumeration process for all of the immediate child windows of a specified window.
Syntax
WinBeginEnumWindows(hwnd)
Parameters
- hwnd (HWND) - input
- Handle of the window whose child windows are to be enumerated.
- HWND_DESKTOP
- Enumerate all main windows
- HWND_OBJECT
- Enumerate all object windows
- Other
- Enumerate all immediate children of the specified window.
Returns
- henumHenum (HENUM) - returns
- Enumeration handle.
- This is used in subsequent calls to the WinGetNextWindow function to return the immediate child-window handles in succession.
- When the application has finished the enumeration, the enumeration handle must be destroyed with the WinEndEnumWindows call.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Remarks
This function remembers the window hierarchy at the time of invocation of the call. Thereafter the information is referenced by use of the henumHenum parameter and does not change during the enumeration by the WinGetNextWindow call. The windows are enumerated in the z-order at the time enumeration is begun, with the topmost child window enumerated first.
Only the immediate children of the specified window are enumerated; child windows of the child windows are excluded.
The enumerated windows are not locked by this function and can thus be destroyed between the time that it is called and the time that the WinGetNextWindow function is used to obtain the handle for the window.
Example Code
This example begins window enumeration of all main windows (i.e. all immediate children of the Desktop), after which WinGetNextWindow is called in a loop to enumerate all the children, until all children are found and the enumeration ends.
#define INCL_WINWINDOWMGR /* Window Manager Functions */ #include <os2.h> HWND hwndParent; /* Handle of the window whose child windows are to be enumerated */ HWND hwndNext; /* current enumeration handle */ HENUM henum; /* enumeration handle */ BOOL fSuccess; /* success indicator */ SHORT sRetLen; /* returned string length */ SHORT sLength = 10; /* string buffer length */ char pchBuffer[10]; /* string buffer */ hwndParent = HWND_DESKTOP; henum = WinBeginEnumWindows(hwndParent); while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE) { . . . } fSuccess = WinEndEnumWindows (henum);
Definition
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwnd; /* Handle of the window whose child windows are to be enumerated. */ HENUM henumHenum; /* Enumeration handle. */ henumHenum = WinBeginEnumWindows(hwnd);
Related Functions
- WinBeginEnumWindows
- WinEndEnumWindows
- WinEnumDlgItem
- WinGetNextWindow
- WinIsChild
- WinMultWindowFromIDs
- WinQueryWindow
- WinSetOwner
- WinSetParent