自己用API函数做了一个四叶风车的图形,但是想让它转动起来,求帮助!
#include<windows.h>#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
int nMode;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
char lpszClassName[]="映像模式";
char lpszTitle[]="动态风车";
wndclass.style=0;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName;
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
hwnd=CreateWindow
(
lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lparam)
{
HDC hdc;
PAINTSTRUCT ps;
HBRUSH hB1,hB2,hB3,hB4;
switch(message)
{
case WM_LBUTTONDOWN:
nMode=MM_ISOTROPIC;
InvalidateRect(hwnd,NULL,1);
break;
case WM_RBUTTONDOWN:
nMode=MM_ANISOTROPIC;
InvalidateRect(hwnd,NULL,1);
break;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
SetMapMode(hdc,nMode);
SetWindowExtEx(hdc,150,150,NULL);
SetViewportExtEx(hdc,150,100,NULL);
SetViewportOrgEx(hdc,150,60,NULL);
hB1=CreateSolidBrush(RGB(0,250,0));
hB2=CreateSolidBrush(RGB(250,0,0));
hB3=CreateSolidBrush(RGB(0,0,250));
hB4=CreateSolidBrush(RGB(100,0,100));
SelectObject(hdc,hB1);
Pie(hdc,100,100,300,300,300,200,100,200);
SelectObject(hdc,hB2);
Pie(hdc,200,0,400,200,300,200,300,-100);
SelectObject(hdc,hB3);
Pie(hdc,300,100,500,300,300,200,500,200);
SelectObject(hdc,hB4);
Pie(hdc,200,200,400,400,300,200,300,400);
EndPaint(hwnd,&ps);
DeleteObject(hB1);
DeleteObject(hB2);
DeleteObject(hB3);
DeleteObject(hB4);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lparam);
}
return 0;
}