Jump to content

WinGetNextWindow: Difference between revisions

From EDM2
Created page with "This function gets the window handle of the next window in a specified enumeration list. ==Syntax== WinGetNextWindow(henum) ==Parameters== ;henum (HENUM) - input : Enumeration handle. :Returned by previous call to the WinBeginEnumWindows call. ==Returns== ; hwndNext (HWND) - returns :Next window handle in enumeration list. :;NULLHANDLE ::Error occurred, henum was invalid, or all the windows have been enumerated. :;Other ::Next window handle. ==Errors== Possible retu..."
 
Line 59: Line 59:
==Related Functions==
==Related Functions==
* [[WinBeginEnumWindows]]
* [[WinBeginEnumWindows]]
* [[WinEndEnumWindows]]
* WinEndEnumWindows
* [[WinEnumDlgItem]]
* WinEnumDlgItem
* [[WinIsChild]]
* WinIsChild
* [[WinMultWindowFromIDs]]
* WinMultWindowFromIDs
* [[WinQueryWindow]]
* WinQueryWindow
* [[WinSetOwner]]
* WinSetOwner
* [[WinSetParent]]
* WinSetParent




[[Category:Win]]
[[Category:Win]]

Revision as of 04:15, 6 April 2025

This function gets the window handle of the next window in a specified enumeration list.

Syntax

WinGetNextWindow(henum)

Parameters

henum (HENUM) - input
Enumeration handle.
Returned by previous call to the WinBeginEnumWindows call.

Returns

hwndNext (HWND) - returns
Next window handle in enumeration list.
NULLHANDLE
Error occurred, henum was invalid, or all the windows have been enumerated.
Other
Next window handle.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_HENUM (0x101C)
An invalid enumeration handle was specified.

Remarks

Enumeration starts with the topmost child window and then proceeds downward through the enumeration list, in z-order at the time the WinBeginEnumWindows was issued, until all the windows have been enumerated. At this point, the call returns NULLHANDLE. The enumeration then wraps and the handle of the topmost child window is returned on the next call. This function does not lock windows.

Example Code

#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HENUM    henum;     /*  Enumeration handle. */
HWND     hwndNext;  /*  Next window handle in enumeration list. */

hwndNext = WinGetNextWindow(henum);

This example moves through all the child windows in a enumeration list, using an enumeration handle provided by WinBeginEnumWindows; for each child window, the class name is queried and placed in a buffer.


#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)
   sRetLen = WinQueryClassName(hwndNext, sLength, pchBuffer);

fSuccess = WinEndEnumWindows (henum);

Related Functions

  • WinBeginEnumWindows
  • WinEndEnumWindows
  • WinEnumDlgItem
  • WinIsChild
  • WinMultWindowFromIDs
  • WinQueryWindow
  • WinSetOwner
  • WinSetParent