Jump to content

GpiAssociate: Difference between revisions

From EDM2
m Martini moved page OS2 API:GPI:GpiAssociate to GpiAssociate
Ak120 (talk | contribs)
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This function associates a graphics presentation space with, or dissociates it from, a device context.
==Syntax==
==Syntax==
This function associates a graphics presentation space with, or dissociates it from, a device context.
  GpiAssociate(hps, hdc)
#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. */
BOOL    rc;  /*  Success indicator. */
  rc = GpiAssociate(hps, hdc);


==Parameters==
==Parameters==
;hps (HPS) - input
;hps (HPS) - input:Presentation-space handle.
:Presentation-space handle.  
;hdc (HDC) - input:Device-context handle.
 
;rc (BOOL) - returns:Success indicator.
;hdc (HDC) - input
:Device-context handle.  
 
;rc (BOOL) - returns
:Success indicator.
TRUE  Successful completion
FALSE Error occurred.


==Returns==
==Returns==
;rc (BOOL) - returns
;rc (BOOL) - returns:Success indicator.
:Success indicator.
*TRUE - Successful completion
TRUE Successful completion
*FALSE - Error occurred.
FALSE Error occurred.


==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError
 
;PMERR_INV_HPS (0x207F):An invalid presentation-space handle was specified.
;PMERR_INV_HPS (0x207F)
;PMERR_PS_BUSY (0x20F4):An attempt was made to access the presentation space from more than one thread simultaneously.
:An invalid presentation-space handle was specified.
;PMERR_PS_IS_ASSOCIATED (0x20F5):An attempt was made to destroy a presentation or associate a presentation space that is still associated with a device context.  
;PMERR_PS_BUSY (0x20F4)
;PMERR_DC_IS_ASSOCIATED (0x2017):An attempt was made to associate a presentation space with a device context that was already associated or to destroy a device context that was associated.
:An attempt was made to access the presentation space from more than one thread simultaneously.
;PMERR_INV_MICROPS_FUNCTION (0x20A1):An attempt was made to issue a function that is invalid in a micro presentation space.
;PMERR_PS_IS_ASSOCIATED (0x20F5)
;PMERR_INV_HDC (0x207C):An invalid device-context handle or (micro presentation space) presentation-space handle was specified.
:An attempt was made to destroy a presentation or associate a presentation space that is still associated with a device context.  
;PMERR_REALIZE_NOT_SUPPORTED (0x20F7):An attempt was made to create a realizable logical color table on a device driver that does not support this function.
;PMERR_DC_IS_ASSOCIATED (0x2017)
;PMERR_PATH_INCOMPLETE (0x20EC):An attempt was made to open or close a segment either directly or during segment drawing, or to issue GpiAssociate while there is an open path bracket.
:An attempt was made to associate a presentation space with a device context that was already associated or to destroy a device context that was associated.
;PMERR_AREA_INCOMPLETE (0x2005):One of the following has occurred:
;PMERR_INV_MICROPS_FUNCTION (0x20A1)
:An attempt was made to issue a function that is invalid in a micro presentation space.
;PMERR_INV_HDC (0x207C)
:An invalid device-context handle or (micro presentation space) presentation-space handle was specified.
;PMERR_REALIZE_NOT_SUPPORTED (0x20F7)
:An attempt was made to create a realizable logical color table on a device driver that does not support this function.  
;PMERR_PATH_INCOMPLETE (0x20EC)
:An attempt was made to open or close a segment either directly or during segment drawing, or to issue GpiAssociate while there is an open path bracket.
;PMERR_AREA_INCOMPLETE (0x2005)
:One of the following has occurred:  
:* A segment has been opened, closed, or drawn.
:* A segment has been opened, closed, or drawn.
:* GpiAssociate was issued while an area bracket was open.
:* GpiAssociate was issued while an area bracket was open.
Line 60: Line 36:
If a null handle is supplied for the device context, the presentation space is dissociated from its currently-associated device context. An associated presentation space cannot be associated with another device context, and an associated device context cannot be associated with another presentation space.
If a null handle is supplied for the device context, the presentation space is dissociated from its currently-associated device context. An associated presentation space cannot be associated with another device context, and an associated device context cannot be associated with another presentation space.


An error occurs if you try to draw to a presentation space associated with a memory device context that has no bit map selected into it (see GpiSetBitmap).
An error occurs if you try to draw to a presentation space associated with a memory device context that has no bit map selected into it (see [[GpiSetBitmap]]).


The processing described for GRES_ATTRS (see GpiResetPS) is performed on the presentation space. Also, bounds data is destroyed, the page viewport is reset to its default value (see GpiCreatePS), and any clip region and path definition are lost. The save/restore presentation-space stack (see GpiSavePS) is purged.
The processing described for GRES_ATTRS (see [[GpiResetPS]]) is performed on the presentation space. Also, bounds data is destroyed, the page viewport is reset to its default value (see [[GpiCreatePS]]), and any clip region and path definition are lost. The save/restore presentation-space stack (see [[GpiSavePS]]) is purged.


Any palette selected into the presentation space remains selected.
Any palette selected into the presentation space remains selected.
Line 71: Line 47:
This example releases the current device context and associates a new device context with the presentation space.
This example releases the current device context and associates a new device context with the presentation space.
<PRE>
<PRE>
#define INCL_GPICONTROL        /* GPI control Functions       */
#define INCL_GPICONTROL        /* GPI control Functions */
#include <os2.h>
#include <os2.h>


HPS hps;                /* presentation space handle           */
HPS hps;                /* presentation space handle     */
HDC hdcPrinter;        /* device context handle               */
HDC hdcPrinter;        /* device context handle         */


/* release the current device context */
/* release the current device context */
Line 83: Line 59:
</PRE>
</PRE>


==Related Functions==
[[Category:Gpi]]
* GpiCreatePS
* GpiDestroyPS
* GpiQueryDevice
* GpiQueryPS
* GpiResetPS
* GpiRestorePS
* GpiSavePS
* GpiSetMarkerSet
* GpiSetPatternSet
* GpiSetPS
 
[[Category:The OS/2 API Project]]

Latest revision as of 19:36, 14 April 2020

This function associates a graphics presentation space with, or dissociates it from, a device context.

Syntax

GpiAssociate(hps, hdc)

Parameters

hps (HPS) - input
Presentation-space handle.
hdc (HDC) - input
Device-context handle.
rc (BOOL) - returns
Success indicator.

Returns

rc (BOOL) - returns
Success indicator.
  • TRUE - Successful completion
  • FALSE - Error occurred.

Errors

Possible returns from WinGetLastError

PMERR_INV_HPS (0x207F)
An invalid presentation-space handle was specified.
PMERR_PS_BUSY (0x20F4)
An attempt was made to access the presentation space from more than one thread simultaneously.
PMERR_PS_IS_ASSOCIATED (0x20F5)
An attempt was made to destroy a presentation or associate a presentation space that is still associated with a device context.
PMERR_DC_IS_ASSOCIATED (0x2017)
An attempt was made to associate a presentation space with a device context that was already associated or to destroy a device context that was associated.
PMERR_INV_MICROPS_FUNCTION (0x20A1)
An attempt was made to issue a function that is invalid in a micro presentation space.
PMERR_INV_HDC (0x207C)
An invalid device-context handle or (micro presentation space) presentation-space handle was specified.
PMERR_REALIZE_NOT_SUPPORTED (0x20F7)
An attempt was made to create a realizable logical color table on a device driver that does not support this function.
PMERR_PATH_INCOMPLETE (0x20EC)
An attempt was made to open or close a segment either directly or during segment drawing, or to issue GpiAssociate while there is an open path bracket.
PMERR_AREA_INCOMPLETE (0x2005)
One of the following has occurred:
  • A segment has been opened, closed, or drawn.
  • GpiAssociate was issued while an area bracket was open.
  • A drawn segment has opened an area bracket and ended without closing it.

Remarks

Any type of device context may be used.

Subsequent drawing functions direct output to the associated device context.

If a null handle is supplied for the device context, the presentation space is dissociated from its currently-associated device context. An associated presentation space cannot be associated with another device context, and an associated device context cannot be associated with another presentation space.

An error occurs if you try to draw to a presentation space associated with a memory device context that has no bit map selected into it (see GpiSetBitmap).

The processing described for GRES_ATTRS (see GpiResetPS) is performed on the presentation space. Also, bounds data is destroyed, the page viewport is reset to its default value (see GpiCreatePS), and any clip region and path definition are lost. The save/restore presentation-space stack (see GpiSavePS) is purged.

Any palette selected into the presentation space remains selected.

Any dynamic segments left drawn on the device are not subsequently removed by GpiRemoveDynamics.

Example Code

This example releases the current device context and associates a new device context with the presentation space.

#define INCL_GPICONTROL         /* GPI control Functions */
#include <os2.h>

HPS hps;                /* presentation space handle     */
HDC hdcPrinter;         /* device context handle         */

/* release the current device context */
GpiAssociate(hps, NULLHANDLE);
/* associate a printer device context */
GpiAssociate(hps, hdcPrinter);