Jump to content

WinIntersectRect

From EDM2
Revision as of 03:09, 9 April 2025 by Martini (talk | contribs) (Related Functions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function calculates the intersection of the two source rectangles and returns the result in the destination rectangle.

Syntax

WinIntersectRect(hab, pcrlDst, pcrlSrc1, pcrlSrc2)

Parameters

hab (HAB) - Input
Anchor-block handle.
pcrlDst (PRECTL) - Output
Intersection rectangle.
Is the intersection of pcrlSrc1 and pcrlSrc2.
Note
The value of each field in this structure must be in the range -32 768 through 32 767. The data type WRECT can also be used, if supported by the language.
pcrlSrc1 (PRECTL) - Input
First rectangle.
Note
The value of each field in this structure must be in the range -32 768 through 32 767. The data type WRECT can also be used, if supported by the language.
pcrlSrc2 (PRECTL) - Input
Second rectangle.
Note
The value of each field in this structure must be in the range -32 768 through 32 767. The data type WRECT can also be used, if supported by the language.

Returns

rc (BOOL) - returns
Success indicator.
TRUE
Source rectangles intersect
FALSE
Source rectangles do not intersect, or an error occurred.

Remarks

If there is no intersection, an empty rectangle is returned in pcrlDst.

Errors

Possible returns from WinGetLastError: (No specific errors were listed in the provided text.)

Example Code

#define INCL_WINRECTANGLES /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HAB     hab;       /*  Anchor-block handle. */
PRECTL  pcrlDst;   /*  Intersection rectangle. */
PRECTL  pcrlSrc1;  /*  First rectangle. */
PRECTL  pcrlSrc2;  /*  Second rectangle. */
BOOL    rc;        /*  Success indicator. */

rc = WinIntersectRect(hab, pcrlDst, pcrlSrc1, pcrlSrc2);

This example determines the intersection of two rectangles and places the result in a third rectangle structure.

#define INCL_WINRECTANGLES      /* Window Rectangle Functions   */
#include <os2.h>

BOOL   fSuccess;         /* success indicator                    */
HAB    hab;              /* anchor-block handle                  */
PRECTL prclRect1 = {0,0,100,100}; /* rectangle  1                */
PRECTL prclRect2 = {0,0,200,200}; /* rectangle  2                */
PRECTL prclDest;         /* destination rectangle                */

fSuccess = WinIntersectRect(hab, &prclDest, &prclRect1, &prclRect2);

Related Functions