GpiCreatePS

From EDM2
Jump to: navigation, search

It is used to create a presentation space (PS). A presentation space is a logical container that is used to hold and manage graphical objects, such as lines, curves, text, and images.

Syntax

GpiCreatePS( hab, hdc, psizlSize, flOptions)

or

HPS GpiCreatePS(HAB hab, HDC hdc, PSIZEL psizl, ULONG flOptions)

Parameters

hab (HAB) - input
A handle to an anchor block (AB) that identifies the process that is creating the PS.
hdc (HDC) - input
A handle to a device context (DC) that specifies the device that the PS will be associated with.
psizlSize (PSIZEL) - input
A PSIZEL structure that specifies the size and resolution of the PS.
flOptions (ULONG)
A set of flags that specify options for creating the PS.

Returns

rc (HPS)

The function returns a handle to the created PS, or NULL if an error occurs.

Errors

ERROR_INVALID_HANDLE
The handle to the anchor block (hab) or the device context (hdc) is invalid.
ERROR_INVALID_PARAMETER
The psizl parameter is invalid or NULL.
ERROR_NOT_ENOUGH_MEMORY
There is not enough memory available to create the PS.
ERROR_INVALID_FLAGS
The flOptions parameter specifies an invalid combination of flags.

Sample

HAB hab;
HDC hdc;
PSIZEL psizl;
HPS hps;

hab = WinQueryAnchorBlock(HWND_DESKTOP);
hdc = WinOpenWindowDC(HWND_DESKTOP);
psizl.cx = 640;
psizl.cy = 480;

hps = GpiCreatePS(hab, hdc, &psizl, PU_PELS | GPIF_DEFAULT);
if (hps == NULL) {
   // An error occurred, handle it here
}