Write a VC++ Program to display following shapes in successive mouse clicks;
Line,Rectangle,Circle,ellipse,Erase.


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

RECT r;
static int count=0,i;
static int x,y,x1,y1;

switch (message)
{
case WM_LBUTTONDOWN:
count++;
hdc=GetDC(hWnd);
x=LOWORD(lParam);
y=HIWORD(lParam);
x1=x+100;
y1=y+100;
GetClientRect(hWnd,&r);
if(count==1)
{
MoveToEx(hdc,x,y,0);
LineTo(hdc,x1,y1);
}
else if(count==2)
{
Rectangle(hdc,x,y,x1,y1);
}
else if(count==3)
{
Ellipse(hdc,x,y,x1,y1);
}
else if(count==4)
{
Ellipse(hdc,x,y,x1+100,y1);
}
else if(count==5)
{
InvalidateRect(hWnd,&r,true);
count=0;
}



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