WinWindowFromID
Appearance
This function returns the handle of the child window with the specified identity.
Syntax
WinWindowFromID(hwndParent, id)
Parameters
- hwndParent (HWND) - input
- Parent-window handle.
- id (ULONG) - input
- Identity of the child window.
- It must be greater or equal to 0 and less or equal to 0xFFFF.
Returns
- hwnd (HWND) - returns
- Window handle.
- NULLHANDLE: No child window of the specified identity exists.
- Other: Child-window handle.
Remarks
To obtain the window handle for an item within a dialog box, set hwndParent to the dialog-box window's handle, and set id to the identity of the item in the dialog template.
Errors
Possible returns from WinGetLastError
- PMERR_INVALID_HWND (0x1001)
- An invalid window handle was specified.
Example Code
Declaration:
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HWND hwndParent; /* Parent-window handle. */ ULONG id; /* Identity of the child window. */ HWND hwnd; /* Window handle. */ hwnd = WinWindowFromID(hwndParent, id);
This example calls WinWindowFromID to get the window handle of the system menu and calls WinSendMsg to send a message to disable the Close menu item.
#define INCL_WINFRAMEMGR /* for FID_ definitions. */ #define INCL_WINMENUS /* for MIA_ definitions. */ #define INCL_WINWINDOWMGR #include <OS2.H> HWND hwndSysMenu, hwndDlg; hwndSysMenu = WinWindowFromID(hwndDlg, FID_SYSMENU); WinSendMsg(hwndSysMenu, MM_SETITEMATTR, MPFROM2SHORT(SC_CLOSE, TRUE), MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));