Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Using Presentation Spaces and Device Contexts (1.2)
◄About Section► ◄Function Group► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
Using Presentation Spaces and Device Contexts
You can use presentation-space and device-context functions to perform the
following tasks:
♦ Create a normal, micro, or cached-micro presentation space.
♦ Delete, save, or restore a presentation space.
♦ Create a standard or cached device context.
♦ Associate a presentation space or device context.
♦ Destroy a device context.
♦ Retrieve information about a device's capabilities.
Creating a Normal Presentation Space
The following code fragment shows how to create a presentation space with
page units of 0.01 inches and associate it with a printer device context:
HAB hab; /* anchor-block handle */
HPS hpsNormal; /* presentation-space handle */
HDC hdcPrinter; /* device-context handle */
SIZEL sizlPage; /* page structure */
.
.
.
hpsNormal = GpiCreatePS(hab, hdcPrinter, &sizlPage,
PU_LOENGLISH | GPIA_ASSOC);
Creating a Standard Device Context for a Printer
The following code fragment shows how to create a printer device context:
HDC hdcPrinter; /* handle of printer device context */
HAB hab; /* anchor-block handle */
DEVOPENSTRUC dop; /* device information */
dop.pszLogAddress = "lpt1"; /* logical-device address */
dop.pszDriverName = "PSCRIPT"; /* device-driver name */
dop.pdriv = NULL; /* pointer to driver data */
dop.pszDataType = "PM_Q_STD"; /* standard queued data */
hdcPrinter = DevOpenDC(hab,
OD_DIRECT, /* direct device type */
"*", /* no data in os2.ini */
4L,
(PDEVOPENDATA) &dop,
(HDC) NULL);
Creating a Standard Device Context for a Metafile
The following code fragment shows how to create a standard device context:
HDC hdcMeta, hdcWin; /* handles of metafile and window DC */
HAB hab; /* anchor-block handle */
DEVOPENSTRUC dop; /* device information */
dop.pszLogAddress = NULL; /* logical-device address */
dop.pszDriverName = "DISPLAY"; /* device-driver name */
dop.pdriv = NULL; /* pointer to driver data */
dop.pszDataType = NULL; /* no queued data */
hdcMeta = DevOpenDC(hab,
OD_METAFILE, /* metafile DC */
"*", /* ignores os2.ini */
4L, /* uses first 4 fields in dop */
(PDEVOPENDATA) &dop, /* structure for system info */
NULL); /* compatible with screen */
Reassociating a Normal Presentation Space
The following code fragment shows how to break the link between a normal
presentation space and a device context and reassociate the presentation
space with a metafile device context:
if (!GpiAssociate(hps, NULL)) /* breaks link between PS and DC */
ReportError(...);
if (!GpiAssociate(hps, hdcMeta)) /* reassociates PS and metafile DC */
ReportError(...);
Associating a Device Context with a Presentation Space
The following code fragment shows how to open a cached device context and
associate it with a normal presentation space:
HDC hdcWin; /* cached-device-context handle */
HPS hpsWin; /* normal-presentation-space handle */
HWND hwndClient; /* client-window handle */
HAB hab; /* anchor-block handle */
SIZEL sizlPage; /* presentation page */
hdcWin = WinOpenWindowDC(hwndClient);
hpsWin = GpiCreatePS(hab, hdcWin, &sizlPage,
PU_LOENGLISH | GPIA_ASSOC);
♦