WinWindowFromDC: Difference between revisions
Appearance
Created page with "This function returns the handle of the window corresponding to a particular device context. ==Syntax== WinWindowFromDC(hdc) ==Parameters== ;hdc (HDC) - input :Device-contex..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This function returns the handle of the window corresponding to a particular device context. | This function returns the handle of the window corresponding to a particular device context. | ||
==Syntax== | ==Syntax== | ||
WinWindowFromDC(hdc) | WinWindowFromDC(hdc) | ||
==Parameters== | ==Parameters== | ||
;hdc (HDC) - input | ;hdc (HDC) - input:Device-context handle. | ||
: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== | ||
;hwnd (HWND) - returns | ;hwnd (HWND) - returns:Window handle. | ||
:Window handle. | ::NULLHANDLE - Error occurred. For example, the device context has not been opened by the WinOpenWindowDC function. | ||
::Other - Window handle. | |||
: | |||
: | |||
==Errors== | ==Errors== | ||
Possible returns from WinGetLastError | Possible returns from WinGetLastError | ||
;PMERR_INV_HPS (0x207F) | ;PMERR_INV_HPS (0x207F):An invalid presentation-space handle was specified. | ||
: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. | ||
;PMERR_INV_HDC (0x207C) | |||
:An invalid device-context handle or (micro presentation space) presentation-space handle was specified. | |||
==Example Code== | ==Example Code== | ||
If a device context handle is specified, this example determines which window is associated with that device context. | If a device context handle is specified, this example determines which window is associated with that device context. | ||
Line 37: | Line 32: | ||
/* This function is called in some other window: */ | /* This function is called in some other window: */ | ||
/* hdc = WinOpenWindowDC(hwnd); */ | /* hdc = WinOpenWindowDC(hwnd); */ | ||
hwnd = WinWindowFromDC(hdc); | hwnd = WinWindowFromDC(hdc); | ||
</pre> | </pre> | ||
Revision as of 03:10, 4 October 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