Jump to content

GpiQueryDevice

From EDM2
Revision as of 04:09, 26 November 2023 by Ak120 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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);