Jump to content

WinEnumDlgItem

From EDM2

This function returns the window handle of a dialog item within a dialog window.

Syntax

WinEnumDlgItem(hwndDlg, hwnd, code)

Parameters

hwndDlg (HWND) - Input
Dialog-window handle.
hwnd (HWND) - Input
Child-window handle.
This may be an immediate child of the dialog window or a window lower in the window hierarchy, such as a child of a child window.
NULLHANDLE can be specified if code is EDI_FIRSTTABITEM or EDI_LASTTABITEM.
If an invalid handle is passed, the first child window of the dialog is returned.
code (ULONG) - Input
Item-type code.
Determines the type of dialog item to return. This parameter can have one of the following values:
EDI_FIRSTGROUPITEM
First item in the same group.
EDI_FIRSTTABITEM
First item in dialog with style WS_TABSTOP. hwnd is ignored.
EDI_LASTGROUPITEM
Last item in the same group.
EDI_LASTTABITEM
Last item in dialog with style WS_TABSTOP. hwnd is ignored.
EDI_NEXTGROUPITEM
Next item in the same group. Wraps around to beginning of group when the end of the group is reached.
EDI_NEXTTABITEM
Next item with style WS_TABSTOP. Wraps around to beginning of dialog item list when end is reached.
EDI_PREVGROUPITEM
Previous item in the same group. Wraps around to end of group when the start of the group is reached. For information on the WS_GROUP style,
EDI_PREVTABITEM
Previous item with style WS_TABSTOP. Wraps around to end of dialog item list when beginning is reached.

Returns

hwndItem (HWND) - Returns
Item-window handle.
As dictated by code.
The window is always an immediate child of hwndDlg, even if hwnd is not an immediate child window.

Remarks

The window is always an immediate child of hwndDlg, even if hwnd is not an immediate child window.

Errors

Possible returns from WinGetLastError:

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.

Example Code

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

HWND     hwndDlg;   /*  Dialog-window handle. */
HWND     hwnd;      /*  Child-window handle. */
ULONG    code;      /*  Item-type code. */
HWND     hwndItem;  /*  Item-window handle. */

hwndItem = WinEnumDlgItem(hwndDlg, hwnd, code);

This example uses WinEnumDlgItem to query the first dialog item for each immediate child of the specified dialog window. The immediate children are enumerated using a WinBeginEnumWindows - WinGetNextWindow - WinEndEnumWindows loop.

#define INCL_WINDIALOGS      /* Window Dialog Mgr functions        */
#define INCL_WINWINDOWMGR    /* Window Manager functions           */
#include <os2.h>

HWND  hwndDlg;               /* Handle of the parent dialog window */
HWND  hwndChild;             /* Current dialog child               */
HWND  hwndItem;              /* First dialog item                  */
HENUM  henum;                /* Enumeration handle                 */
BOOL  fSuccess;              /* Success indicator                  */

henum = WinBeginEnumWindows(hwndDlg);
while ((hwndChild = WinGetNextWindow(henum)) != NULL)
      hwndItem = WinEnumDlgItem(hwndDlg, hwndChild, EDI_FIRSTTABITEM);
fSuccess = WinEndEnumWindows (henum);

Related Functions