VC++ Program to display three Sinewaves on client area by clicking mouse left button.



Add
#define TWOPI 2*3.14159

#include"math.h"


LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static int x,y;
POINT pt[1000];
int i;
static int f=0;

switch (message) 
{
case WM_SIZE:
x=LOWORD(lParam);
y=HIWORD(lParam);
return 0;
case WM_LBUTTONDOWN:
hdc=GetDC(hWnd);

if(f==0)
{
MoveToEx(hdc,0,y/4,NULL);
LineTo(hdc,x,y/4);
for(i=0;i<1000;i++)
{
pt[i].x=i*x/1000;
pt[i].y=(int)(y/4*(1-sin(TWOPI*i/1000)));
}
Polyline(hdc,pt,1000);
f=1;
}
else if(f==1)
{
MoveToEx(hdc,0,y/2,NULL);
LineTo(hdc,x,y/2);
for(i=0;i<1000;i++)
{
pt[i].x=i*x/1000;
pt[i].y=(int)(y/4*(2-sin(TWOPI*i/1000)));
}
Polyline(hdc,pt,1000);
f=2;
}
else
{
MoveToEx(hdc,0,(y*3)/4,NULL);
LineTo(hdc,x,(y*3)/4);
for(i=0;i<1000;i++)
{
pt[i].x=(i*x/1000);
pt[i].y=(int)(y/4*(3-sin(TWOPI*i/1000)));
}
Polyline(hdc,pt,1000);
}
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