16,548
社区成员




CRect operator&(
const RECT& rect2
) const throw( );
Remarks
The intersection is the largest rectangle that is contained in both rectangles.
Both of the rectangles must be normalized or this function may fail. You can call NormalizeRect to normalize the rectangles before calling this function.
HRGN hRgn1 = CreateRectRgn(rc1.left, rc1.top, rc1.right, rc1.bottom);
HRGN hRgn2 = CreateRectRgn(rc2.left, rc2.top, rc2.right, rc2.bottom);
//用RGN_AND标志表示你要合并两个区域并得到交集
HRGN hRgnSum = NULL;
int nRet = CombineRgn(hRgnSum, hRgn1, hRgn2, RGN_AND);
if (nRet == SIMPLEREGION)
{ //有交集
//得到交集矩形
RECT rc3;
GetRgnBox(hRgnSum, &rc3);
}
else if (nRet == NULLREGION)
//没有交集
DeleteObject(hRgnSum);
DeleteObject(hRgn2);
DeleteObject(hRgn1);