Write VC++ a Program to Draw Rectangle Intersected with Another Rectangle.the Intersected Part Should have Diffrent Color,also show the Union of Rectangle With Diffrent Color.

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

RECT Rect1,Rect2,iRect,uRect;
HBRUSH Rect1Hbr,Rect2Hbr,iHbr,uHbr;

switch (message)
{
case WM_CREATE:
return 0;
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
Rect1Hbr=CreateSolidBrush(RGB(0,0,255));
Rect2Hbr=CreateSolidBrush(RGB(255,255,0));

iHbr=CreateSolidBrush(RGB(0,255,0));
uHbr=CreateSolidBrush(RGB(255,0,0));

SetRect(&Rect1,50,50,250,250);
SetRect(&Rect2,150,150,350,350);

UnionRect(&uRect,&Rect1,&Rect2);
FillRect(hdc,&uRect,uHbr);
FillRect(hdc,&Rect1,Rect1Hbr);
FillRect(hdc,&Rect2,Rect2Hbr);

IntersectRect(&iRect,&Rect1,&Rect2);
FillRect(hdc,&iRect,iHbr);

break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

Comments

Popular posts from this blog

Uploading Image to Sql Server Image Datatype in asp.net using fileupload Control

Get Running Sum of Query SQL Query