矩形和区域 (二)

2014-11-24 11:21:29 · 作者: · 浏览: 2
//FillRect(hdc,&r1,hbrush);

r2.left=150;
r2.top=100;
r2.right=250;
r2.bottom=200;
//FrameRect(hdc,&r2,hbrush);

IntersectRect(&r3,&r1,&r2);//r1,r2矩形取交集,存放在r3
FillRect(hdc,&r3,hbrush);
flag=(int)IsRectEmpty(&r3);//判断矩形是否为空
TextOut(hdc,300,300,szBuffer,wsprintf(szBuffer,TEXT("%d"),flag));

EndPaint(hwnd,&ps);
return 0;

case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
//GetClientRect(hwnd,&rect);

//hrgn=CreateRectRgn(100,100,300,300);
//hbrush=CreateSolidBrush(RGB(255,0,0));
//FillRgn(hdc,hrgn,hbrush);
//InvertRgn(hdc,hrgn);//取反
//FrameRgn(hdc,hrgn,hbrush,0,0);


r1.left=100;
r1.top=100;
r1.right=200;
r1.bottom=200;
hbrush=CreateSolidBrush(RGB(255,0,0));//创建画刷
//FillRect(hdc,&r1,hbrush);

r2.left=150;
r2.top=100;
r2.right=250;
r2.bottom=200;
//FrameRect(hdc,&r2,hbrush);

IntersectRect(&r3,&r1,&r2);//r1,r2矩形取交集,存放在r3
FillRect(hdc,&r3,hbrush);
flag=(int)IsRectEmpty(&r3);//判断矩形是否为空
TextOut(hdc,300,300,szBuffer,wsprintf(szBuffer,TEXT("%d"),flag));

EndPaint(hwnd,&ps);
return 0;

www.2cto.com
[cpp]
hrgn=CreateRectRgn(xleft,ytop,xright,ybottom);
hrgn=CreateRectRgnIndirect(&rect);
hrgn=CreateEllipticRgn(xleft,ytop,xright,ybottom);
hrgn=CreatePolygonRgn(&point,icount,ipolyFillMode);

hrgn=CreateRectRgn(xleft,ytop,xright,ybottom);
hrgn=CreateRectRgnIndirect(&rect);
hrgn=CreateEllipticRgn(xleft,ytop,xright,ybottom);
hrgn=CreatePolygonRgn(&point,icount,ipolyFillMode);



作者:zh634455283