Jump to content

GpiQueryDevice: Difference between revisions

From EDM2
Created page with "This function returns the handle of the currently associated device context. ==Syntax== hdc = GpiQueryDevice(HPS ''hps'') ==Parameters== ; ''hps'' (HPS) - input : Presenta..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
This function returns the handle of the currently associated device context.  
This function returns the handle of the currently associated device context.
 
==Syntax==
==Syntax==
  hdc = GpiQueryDevice(HPS ''hps'')
  hdc = GpiQueryDevice(HPS ''hps'')


==Parameters==  
==Parameters==
; ''hps'' (HPS) - input
;''hps'' (HPS) - input: Presentation-space handle.
: Presentation-space handle.


==Returns==
==Returns==
; ''hdc'' (HDC) - returns
; ''hdc'' (HDC) - returns:Device-context handle.
:Device-context handle.
::HDC_ERROR - Error
:;HDC_ERROR
::NULLHANDLE - No device context is currently associated
::Error
::Otherwise - Device context handle.
:;NULLHANDLE
::No device context is currently associated  
:;Otherwise
::Device context 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==
Definition:
This example uses the GpiQueryDevice function to retrieve a device-context handle for the presentation space of the desktop window. The handle is used in the [[DevQueryCaps]] function to determine the width and height of the Presentation Manager screen.
<pre>
#define INCL_GPICONTROL /* Or use INCL_GPI, INCL_PM, Also in COMMON section */
#include <os2.h>
 
HPS    hps;  /*  Presentation-space handle. */
HDC    hdc;  /*  Device-context handle. */
 
hdc = GpiQueryDevice(hps);
</pre>
This example uses the GpiQueryDevice function to retrieve a device-context handle for the presentation space of the desktop window. The handle is used in the DevQueryCaps function to determine the width and height of the Presentation Manager screen.  
<pre>
<pre>
#define INCL_GPICONTROL        /* GPI control Functions        */
#define INCL_GPICONTROL        /* GPI control Functions        */
Line 51: Line 35:
DevQueryCaps(hdc, CAPS_HEIGHT, 1L, &lHeight);
DevQueryCaps(hdc, CAPS_HEIGHT, 1L, &lHeight);
</pre>
</pre>


[[Category:Gpi]]
[[Category:Gpi]]

Latest revision as of 04:09, 26 November 2023

This function returns the handle of the currently associated device context.

Syntax

hdc = GpiQueryDevice(HPS hps)

Parameters

hps (HPS) - input
Presentation-space handle.

Returns

hdc (HDC) - returns
Device-context handle.
HDC_ERROR - Error
NULLHANDLE - No device context is currently associated
Otherwise - Device context 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

This example uses the GpiQueryDevice function to retrieve a device-context handle for the presentation space of the desktop window. The handle is used in the DevQueryCaps function to determine the width and height of the Presentation Manager screen.

#define INCL_GPICONTROL         /* GPI control Functions        */
#define INCL_WINWINDOWMGR       /* Window Manager Functions     */
#define INCL_DEV                /* Device Function definitions  */
#include <os2.h>

HPS hps;                /* presentation space handle            */
HDC hdc;                /* device context handle                */
LONG lWidth, lHeight;

hps = WinGetScreenPS(HWND_DESKTOP);
hdc = GpiQueryDevice(hps);
DevQueryCaps(hdc, CAPS_WIDTH, 1L, &lWidth);
DevQueryCaps(hdc, CAPS_HEIGHT, 1L, &lHeight);