資源簡介
這是一個(gè)風(fēng)車程序,使用MFC編寫,是我當(dāng)年的作業(yè)啊~~

代碼片段和文件信息
//#include?
#include
//#include
//#include
#include
#include
#include
#define?PI?3.1415926
long?WINAPI?WndProc(HWND?hWnd//窗口句柄
UINT?Message
UINT?wParam
LONG?Lparam);
long?lCenterX=0lCenterY=0;
double?jsd;//角速度
int?zsd?=?0;//轉(zhuǎn)速
int?n=35;//控制風(fēng)車大小
int?xjd;
long?x?=-5y=0;
int?i;
HDC?hDC;
HBRUSH?hBrush;
HPEN?hPen;
//畫葉片的函數(shù)
void?yepian(double?dint?iint?jint?k)
{
hBrush=CreateSolidBrush(RGB(ijk));
????????Selectobject(hDChBrush);
????????lCenterX=(int)(n*cos(jsd+d));
????????lCenterY=(int)(n*sin(jsd+d));
????????Pie(hDC
lCenterX-nlCenterY-n
lCenterX+nlCenterY+n
2*lCenterX2*lCenterY//葉片弧線起點(diǎn)坐標(biāo)
(int)(lCenterX+n*cos(jsd+PI+d))(int)(lCenterY+n*sin(jsd+PI+d)));//葉片弧線終點(diǎn)坐標(biāo)
Deleteobject(hBrush);
}
int?WINAPI?WinMain(HINSTANCE?hInstance
???HINSTANCE?hPrevInstance
???LPSTR?lpCmdLine
???int?nCmdShow)
{
MSG?Message;
HWND?hWnd;
WNDCLASS?WndClass;
WndClass.cbClsExtra=0;//類無擴(kuò)展
WndClass.cbWndExtra=0;//實(shí)例無擴(kuò)展
WndClass.hbrBackground=(HBRUSH)(GetStockobject(WHITE_BRUSH));
WndClass.hCursor=LoadCursor(NULLIDC_ARROW);//光標(biāo)
WndClass.hIcon=LoadIcon(NULLIDI_APPLICATION);//圖標(biāo)
WndClass.hInstance=hInstance;//當(dāng)前實(shí)例句柄
WndClass.lpfnWndProc=WndProc;//窗口處理函數(shù)
WndClass.lpszClassName=“Feng“;//窗口類名
WndClass.lpszMenuName=NULL;
WndClass.style=0;//窗口風(fēng)格
if(!RegisterClass(&WndClass))
{
MessageBeep(0);
return?FALSE;
}
hWnd=CreateWindow(“Feng“
“風(fēng)車“
WS_OVERLAPPEDWINDOW//風(fēng)格
CW_USEDEFAULT//坐標(biāo)
0
CW_USEDEFAULT
0//坐標(biāo)
NULL//無父窗口
NULL//無主菜單
hInstance//創(chuàng)建此窗口的應(yīng)用程序的當(dāng)前句柄
NULL);//不使用該值
ShowWindow(hWndnCmdShow);//顯示窗口
UpdateWindow(hWnd);//繪制用戶區(qū)
while(GetMessage(&Message000))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return?Message.wParam;
}
long?WINAPI?WndProc(HWND?hWnd
UINT?iMessage
UINT?wParam
LONG?lParam)
{
PAINTSTRUCT?PtStr;
switch(iMessage)
{
case?WM_PAINT://處理繪圖消息
//獲得設(shè)備環(huán)境指針
hDC=BeginPaint(hWnd&PtStr);
SetWindowOrgEx(hDC-200-200NULL);
//開始繪制
//風(fēng)車邊的顏色
hPen=CreatePen(PS_SOLID1RGB(255105180));
Selectobject(hDChPen);
//繪制風(fēng)車柄
hBrush=CreateSolidBrush(RGB(155245155));
????????Selectobject(hDChBrush);
Rectangle(hDC-505400);
Deleteobject(hBrush);
//用循環(huán)使風(fēng)車達(dá)到層疊的效果
for(i?=?0;?i?100;?i++){
//繪制葉片
jsd=(2*PI*zsd)/60;//角速度
yepian(025520147);//調(diào)用函數(shù)繪制第一個(gè)頁片
yepian(2*PI/31480211);//調(diào)用函數(shù)繪制第二個(gè)頁片
yepian(4*PI/32552550);//調(diào)用函數(shù)繪制第三個(gè)頁片
//繪制中心
hBrush=CreateSolidBrush(RGB(155245155));
Selectobject(hDChBrush);
Ellipse(hDC-8-888);
Deleteobject(hBrush);
zsd++;
if((n?<=?60)?&&?(n?>=?35)?){ //改變風(fēng)車葉片尺寸
n++;
}else?if(n?>60){
n=35;
}
}
????????Sleep(50);
????????InvalidateRect(hWndNULL1);
????????EndPaint(hWnd&PtStr);
????????return?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????3343??2009-11-11?23:18??2406070102--劉靜--風(fēng)車\fengche.cpp
?????文件???????3897??2009-11-11?23:17??2406070102--劉靜--風(fēng)車\風(fēng)車.dsp
?????文件????????516??2009-11-11?23:17??2406070102--劉靜--風(fēng)車\風(fēng)車.dsw
?????文件??????41984??2009-11-11?23:19??2406070102--劉靜--風(fēng)車\風(fēng)車.ncb
?????文件??????53760??2009-11-11?23:19??2406070102--劉靜--風(fēng)車\風(fēng)車.opt
?????文件????????739??2009-11-11?23:19??2406070102--劉靜--風(fēng)車\風(fēng)車.plg
?????目錄??????????0??2009-11-11?23:19??2406070102--劉靜--風(fēng)車
-----------?---------??----------?-----??----
???????????????104239????????????????????7
評(píng)論
共有 條評(píng)論