Jump to content

GpiPaintRegion

From EDM2

This function paints a region into a presentation space, using the current pattern attributes.

Syntax

GpiPaintRegion(hps, hrgn)

Parameters

hps (HPS) - input
Presentation-space handle.
hrgn (HRGN) - input
Region handle.

Return Value

lHits (LONG) - returns
Correlation and error indicators.
GPI_OK
Successful
GPI_HITS
Correlate hits
GPI_ERROR
Error.

Remarks

The current GPI area foreground and background colors are used. Mixing is controlled by the area foreground mix only. It is invalid if the specified region is currently selected as the clip region (by GpiSetClipRegion). The region is assumed to be defined in device coordinates. Note: This function must not be used when creating SAA-conforming metafiles; see "MetaFile Resolutions" in the Presentation Manager Programming Reference for more information.

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_REGION_IS_CLIP_REGION (0x20F8)
An attempt was made to perform a region operation on a region that is selected as a clip region.
PMERR_INV_HRGN (0x2080)
An invalid region handle was specified.
PMERR_HRGN_BUSY (0x2034)
An internal region busy error was detected. The region was locked by one thread during an attempt to access it from another thread.

Example Code

#define INCL_GPIREGIONS /* Or use INCL_GPI, INCL_PM, */
#include <os2.h>

HPS     hps;    /* Presentation-space handle. */
HRGN    hrgn;   /* Region handle. */
LONG    lHits;  /* Correlation and error indicators. */

lHits = GpiPaintRegion(hps, hrgn);

This example uses the GpiPaintRegion function to fill a complex region consisting of three, intersecting rectangles. The region is filled with a red, diagonal pattern.

#define INCL_GPIREGIONS /* Region functions */
#include <os2.h>

HPS hps; /* presentation space handle */
HRGN hrgn; /* handle for region */
RECTL arcl[3] = { 100, 100, 200, 200, /* 1st rectangle */
                  150, 150, 250, 250, /* 2nd rectangle */
                  200, 200, 300, 300 }; /* 3rd rectangle */

hrgn = GpiCreateRegion(hps, 3L, arcl);
GpiSetColor(hps, CLR_RED);
GpiSetPattern(hps, PATSYM_DIAG1);
GpiPaintRegion(hps, hrgn);

Related Functions