SubtractRect

3.1

  BOOL SubtractRect(lprcDest, lprcSource1, lprcSource2)    
  RECT FAR* lprcDest; /* pointer to destination rectangle */
  const RECT FAR* lprcSource1; /* pointer to rect. to subtract from */
  const RECT FAR* lprcSource2; /* pointer to rect. to subtract */

The SubtractRect function retrieves the coordinates of a rectangle by subtracting one rectangle from another.

Parameters

lprcDest

Points to the RECT structure to receive the dimensions of the new rectangle. The RECT structure has the following form:

typedef struct tagRECT {    /* rc */
   int left;
   int top;
   int right;
   int bottom;
} RECT;

For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.

lprcSource1

Points to the RECT structure from which a rectangle is to be subtracted.

lprcSource2

Points to the RECT structure that is to be subtracted from the rectangle pointed to by the lprcSource1 parameter.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

The rectangle specified by the lprcSource2 parameter is subtracted from the rectangle specified by lprcSource1 only when the rectangles intersect completely in either the x- or y-direction. For example, if lprcSource1 were (10,10, 100,100) and lprcSource2 were (50,50, 150,150), the rectangle pointed to by lprcDest would contain the same coordinates as lprcSource1 when the function returned. If lprcSource1 were (10,10, 100,100) and lprcSource2 were (50,10, 150,150), however, the rectangle pointed to by lprcDest would contain the coordinates (10,10, 50,100) when the function returned.

See Also

IntersectRect, UnionRect