Jump to content

WinQueryWindowDC: Difference between revisions

From EDM2
Created page with " This function returns the device context for a given window. ==Syntax== WinQueryWindowDC(hwnd) ==Parameters== ;hwnd (HWND) - input :Window handle. ==Returns== ;hdc (HDC..."
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This function returns the device context for a given window.


This function returns the device context for a given window.
==Syntax==
==Syntax==
  WinQueryWindowDC(hwnd)
  WinQueryWindowDC(hwnd)
==Parameters==
==Parameters==
;hwnd (HWND) - input
;hwnd (HWND) - input:Window handle.
:Window handle.  
 


==Returns==
==Returns==
;hdc (HDC) - returns
;hdc (HDC) - returns:Device-context handle.
:Device-context handle.
::NULLHANDLE - Either WinOpenWindowDC has not been called for this window, or an error has occurred.
:;NULLHANDLE
::Other - Device context handle.
::Either WinOpenWindowDC has not been called for this window, or an error has occurred.  
:;Other
::Device context handle.


==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError
;PMERR_INVALID_HWND (0x1001)
::PMERR_INVALID_HWND (0x1001) :An invalid window handle was specified.
:An invalid window handle was specified.
 
==Remarks==
==Remarks==
A handle is returned only if a device context has been opened for the window with WinOpenWindowDC.  
A handle is returned only if a device context has been opened for the window with [[WinOpenWindowDC]].
 
==Example Code==
==Example Code==
This example shows how to check if WinOpenWindowDC has been called for this window.
This example shows how to check if WinOpenWindowDC has been called for this window.
<pre>
<pre>
#define INCL_WINWINDOWMGR
#define INCL_WINWINDOWMGR
#include <OS2.H>
#include <os2.h>


HWND  hwndClient;          /* window handle. */
HWND  hwndClient;          /* window handle. */
Line 35: Line 31:
     /*  ...    */
     /*  ...    */
}
}
</pre>
Definition
<pre>
#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>
HWND    hwnd;  /*  Window handle. */
HDC    hdc;  /*  Device-context handle. */
hdc = WinQueryWindowDC(hwnd);
</pre>
</pre>


==Related Functions==
==Related Functions==
* WinEnableWindow
* [[WinEnableWindow]]
* WinIsThreadActive
* [[WinIsThreadActive]]
* WinIsWindow
* [[WinIsWindow]]
* WinIsWindowEnabled
* [[WinIsWindowEnabled]]
* WinQueryDesktopWindow
* [[WinQueryDesktopWindow]]
* WinQueryObjectWindow
* [[WinQueryObjectWindow]]
* WinQueryWindowProcess
* [[WinQueryWindowProcess]]
* WinQueryWindowRect
* [[WinQueryWindowRect]]
* WinWindowFromDC
* [[WinWindowFromDC]]
* WinWindowFromID
* [[WinWindowFromID]]
* WinWindowFromPoint  
* [[WinWindowFromPoint]]


[[Category:Win]]
[[Category:Win]]

Latest revision as of 18:39, 14 May 2025

This function returns the device context for a given window.

Syntax

WinQueryWindowDC(hwnd)

Parameters

hwnd (HWND) - input
Window handle.

Returns

hdc (HDC) - returns
Device-context handle.
NULLHANDLE - Either WinOpenWindowDC has not been called for this window, or an error has occurred.
Other - Device context handle.

Errors

Possible returns from WinGetLastError

PMERR_INVALID_HWND (0x1001) :An invalid window handle was specified.

Remarks

A handle is returned only if a device context has been opened for the window with WinOpenWindowDC.

Example Code

This example shows how to check if WinOpenWindowDC has been called for this window.

#define INCL_WINWINDOWMGR
#include <os2.h>

HWND  hwndClient;           /* window handle. */

if(WinQueryWindowDC(hwndClient))
{
     /*  ...    */
}

Related Functions