GpiQueryDevice
Appearance
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
Definition:
#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);
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);