Jump to content

WinWindowFromDC

From EDM2
Revision as of 03:10, 4 October 2023 by Ak120 (talk | contribs)

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