This example calls DevOpenDC to create a memory device context with screen compatibility and then associates that context with a newly created presentation space.
#define INCL_DEV /* Device Function definitions */
#define INCL_GPICONTROL /* GPI control Functions */
#include <os2.h>
HDC hdc; /* Device-context handle */
HAB hab; /* Anchor-block handle */
/* context data structure */
DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
HPS hps; /* presentation-space handle */
SIZEL sizl={0, 0}; /* use same page size as device */
/* create memory device context */
hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
/* create a presentation space associated with the context */
hps = GpiCreatePS(hab, hdc, &sizl, GPIA_ASSOC | PU_PELS);