Jump to content

GpiRectInRegion

From EDM2

This function checks whether any part of a rectangle lies within the specified region.

Syntax

GpiRectInRegion(hps, hrgn, prclRect)

Parameters

hps (HPS) - input
Presentation-space handle.
The region must be owned by the device identified by the currently associated device context.
hrgn (HRGN) - input
Region handle.
prclRect (PRECTL) - input
Test rectangle.
The rectangle is specified in device coordinates.

Return Value

lInside (LONG) - returns
Inside and error indicators.
RRGN_OUTSIDE - Not in region
RRGN_PARTIAL - Some in region
RRGN_INSIDE - All in region
RRGN_ERROR - Error.

Remarks

It is invalid if the specified region is currently selected as the clip region (by GpiSetClipRegion).

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_INV_HRGN (0x2080)
An invalid region handle was specified.
PMERR_INV_COORDINATE (0x205B)
An invalid coordinate value was specified.
PMERR_INV_RECT (0x20BD)
An invalid rectangle parameter was specified.
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_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

In this example we check to see if a a rectangle is inside a region before we destroy the region.

#define INCL_GPIREGIONS
#include <OS2.H>

HPS hps; /* presentation-space handle. */
HRGN hrgn; /* region handle. */
PRECTL prclRect; /* test rectangle. */
LONG lInside; /* result. */

lInside = GpiRectInRegion(hps, hrgn, prclRect);

if (lInside == RRGN_OUTSIDE)
{
  GpiDestroyRegion(hps, hrgn);
}

Related Functions