WinWindowFromID: Difference between revisions
Appearance
Created page with "Searches the children of hwndParent to find a window whose identifier matches ulId. ==Syntax== WinWindowFromID (hwndParent, ulId) ;HWND hwndParent ;ULONG ulId It returns t..." |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This function returns the handle of the child window with the specified identity. | |||
==Syntax== | == Syntax == | ||
WinWindowFromID (hwndParent, | WinWindowFromID(hwndParent, id) | ||
;HWND | == Parameters == | ||
;''hwndParent'' ([[HWND]]) - input: Parent-window handle. | |||
It returns the window handle (HWND) | ;''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: | |||
<pre> | |||
#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); | |||
</pre> | |||
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. | |||
<pre> | |||
#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)); | |||
</pre> | |||
== Related Functions == | |||
* [[WinEnableWindow]] | |||
* [[WinIsThreadActive]] | |||
* [[WinIsWindow]] | |||
* [[WinIsWindowEnabled]] | |||
* [[WinQueryDesktopWindow]] | |||
* [[WinQueryObjectWindow]] | |||
* [[WinQueryWindowDC]] | |||
* [[WinQueryWindowProcess]] | |||
* [[WinQueryWindowRect]] | |||
* [[WinWindowFromDC]] | |||
* [[WinWindowFromPoint]] | |||
[[Category:Win]] | [[Category:Win]] |
Latest revision as of 22:09, 15 May 2025
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));