GpiPtInRegion
Appearance
This function checks whether a point lies within a region.
Syntax
GpiPtInRegion(hps, hrgn, pptlPoint)
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.
- pptlPoint (PPOINTL) - input
- Point to be checked.
- The point is in device coordinates.
Return Value
- lInside (LONG) - returns
- Inside and error indicators.
- PRGN_OUTSIDE
- Not in region
- PRGN_INSIDE
- In region
- PRGN_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_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
#define INCL_GPIREGIONS /* Or use INCL_GPI, INCL_PM, */ #include <os2.h> HPS hps; /* Presentation-space handle. */ HRGN hrgn; /* Region handle. */ PPOINTL pptlPoint; /* Point to be checked. */ LONG lInside; /* Inside and error indicators. */ lInside = GpiPtInRegion(hps, hrgn, pptlPoint);
This example uses GpiPtInRegion to determine if the point (150,150) lies within a region.
#define INCL_GPIREGIONS /* Region functions */ #include <os2.h> LONG lInside; /* inside/error indicator */ HPS hps; /* Presentation-space handle */ HRGN hrgn; /* handle for region */ POINTL pptlPoint = {150L,150L};/* point to be checked */ RECTL arcl[3] = { 100, 100, 200, 200, /* 1st rectangle */ 150, 150, 250, 250, /* 2nd rectangle */ 200, 200, 300, 300 }; /* 3rd rectangle */ /* create a region comprising three rectangles */ hrgn = GpiCreateRegion(hps, 3L, arcl); lInside = GpiPtInRegion(hps, hrgn, &pptlPoint);