Write a Program to Draw Sinewave

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;

switch (message) 
{
case WM_SIZE:
x=LOWORD(lParam);//width
y=HIWORD(lParam);//height
return 0;
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
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/2*(1-sin(TWOPI*i/1000)));
}
Polyline(hdc,pt,1000);
return 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