Write a VC++ Program to Draw Following Shapes on Client area when the user presses the :
C-Circle,R-Rectangle,E-Ellipse,L-Line,G-Round Rectangle.


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

static char res;
static int x,y;

switch (message)
{
case WM_CHAR:
hdc=GetDC(hWnd);
x=rand()%500;
y=rand()%500;

sprintf(&res,"%c",wParam);
if(res=='c' || res=='C')
{
Ellipse(hdc,x,y,x+200,y+200);
}
else if(res=='r' || res=='R')
{
Rectangle(hdc,x,y,x+150,y+150);
}
else if(res=='e' || res=='E')
{
Ellipse(hdc,x,y,x+200,y+100);
}
else if(res=='l' || res=='L')
{
MoveToEx(hdc,x,y,0);
LineTo(hdc,x+100,y+100);
}
else
{
RoundRect(hdc,x,y,x+200,y+200,50,50);
}



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