WinWindowFromDC: Difference between revisions
Appearance
mNo edit summary |
|||
Line 6: | Line 6: | ||
==Parameters== | ==Parameters== | ||
;hdc (HDC) - input:Device-context handle. | ;hdc (HDC) - input:Device-context handle. | ||
:The device context must first be opened by the WinOpenWindowDC function. | :The device context must first be opened by the [[WinOpenWindowDC]] function. | ||
==Returns== | ==Returns== |
Revision as of 20:18, 21 November 2023
This function returns the handle of the window corresponding to a particular device context.
Syntax
WinWindowFromDC(hdc)
Parameters
- hdc (HDC) - input
- Device-context handle.
- The device context must first be opened by the WinOpenWindowDC function.
Returns
- hwnd (HWND) - returns
- Window handle.
- NULLHANDLE - Error occurred. For example, the device context has not been opened by the WinOpenWindowDC function.
- Other - Window handle.
Errors
Possible returns from WinGetLastError
- PMERR_INV_HPS (0x207F)
- An invalid presentation-space handle was specified.
- PMERR_INV_HDC (0x207C)
- An invalid device-context handle or (micro presentation space) presentation-space handle was specified.
Example Code
If a device context handle is specified, this example determines which window is associated with that device context.
#define INCL_WINWINDOWMGR #include <OS2.H> HWND hwnd; HDC hdc; /* Assume the device context for a window has been opened in */ /* some other window procedure. We would like to get */ /* a handle to that window. */ /* This function is called in some other window: */ /* hdc = WinOpenWindowDC(hwnd); */ hwnd = WinWindowFromDC(hdc);
Definition
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */ #include <os2.h> HDC hdc; /* Device-context handle. */ HWND hwnd; /* Window handle. */ hwnd = WinWindowFromDC(hdc);
Related Functions
- WinEnableWindow
- WinIsThreadActive
- WinIsWindow
- WinIsWindowEnabled
- WinQueryDesktopWindow
- WinQueryObjectWindow
- WinQueryWindowDC
- WinQueryWindowProcess
- WinQueryWindowRect
- WinWindowFromID
- WinWindowFromPoint