?? sin a.c
字號(hào):
/*
* Sine.c
* An application that draws a sine wave.
* Developed with the swp template.
* Copyright (c) William H. Murray and Chris H. Pappas, 1998
*/
#include <windows.h>
#include <math.h>
#define pi 3.14159265359
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
char szProgName[]="ProgName";
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPreInst,
LPSTR lpszCmdLine,int nCmdShow)
{
HWND hWnd;
MSG lpMsg;
WNDCLASS wcApp;
wcApp.lpszClassName=szProgName;
wcApp.hInstance =hInst;
wcApp.lpfnWndProc =WndProc;
wcApp.hCursor =LoadCursor(NULL,IDC_ARROW);
wcApp.hIcon =NULL;
wcApp.lpszMenuName =NULL;
wcApp.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wcApp.style =CS_HREDRAW|CS_VREDRAW;
wcApp.cbClsExtra =0;
wcApp.cbWndExtra =0;
if (!RegisterClass (&wcApp))
return 0;
hWnd=CreateWindow(szProgName,"A Sine Wave",
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,(HWND)NULL,(HMENU)NULL,
hInst,(LPSTR)NULL);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&lpMsg,0,0,0)) {
TranslateMessage(&lpMsg);
DispatchMessage(&lpMsg);
}
return(lpMsg.wParam);
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,
WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
int i;
switch (message)
{
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
/* draw the x & y coordinate axes */
MoveToEx(hdc,100,50,NULL);
LineTo(hdc,100,350);
MoveToEx(hdc,100,200,NULL);
LineTo(hdc,500,200);
MoveToEx(hdc,100,200,NULL);
/* draw the sine wave */
MoveToEx(hdc,100,200,NULL);
for (i=0;i<400;i++)
{
LineTo(hdc, 100+i, (int)(200+120*sin(pi*i*(360.0/400.0)/180.0)));
Sleep(10);
}
EndPaint(hWnd,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd,message,wParam,lParam));
break;
}
return(0);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -