为什么不会动(VC++ GDI)
#include<windows.h>#include<string.h>#include<stdlib.h>#include<stdio.h>#include<math...
#include<windows.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include <math.h>
#define PI 3.1415926
int n=0,nM=8;
.............................
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
//HBRUSH hB;
//HPEN hP;
//HFONT hF;
TEXTMETRIC tm;
char *ar={"今日少年明日老 "};
char a[2]="c";
int nX=0,nY=0;
double A;
short x;
switch(message)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
A=2*PI/nM*n;
nX=400+(int)(50*cos(A));
nY=100+(int)(50*sin(A));
SetTextColor(hdc,RGB(250,0,0));
for(x=0;x<7;x++)
{nX=nX+50*cos(A+2*PI/8*x);nY=nY+50*sin(A+2*PI/8*x);
TextOut(hdc,nX,nY,ar+2*x,2);}
EndPaint(hwnd,&ps);
Sleep(500);
n++;
return 0;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
} 展开
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include <math.h>
#define PI 3.1415926
int n=0,nM=8;
.............................
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
//HBRUSH hB;
//HPEN hP;
//HFONT hF;
TEXTMETRIC tm;
char *ar={"今日少年明日老 "};
char a[2]="c";
int nX=0,nY=0;
double A;
short x;
switch(message)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
A=2*PI/nM*n;
nX=400+(int)(50*cos(A));
nY=100+(int)(50*sin(A));
SetTextColor(hdc,RGB(250,0,0));
for(x=0;x<7;x++)
{nX=nX+50*cos(A+2*PI/8*x);nY=nY+50*sin(A+2*PI/8*x);
TextOut(hdc,nX,nY,ar+2*x,2);}
EndPaint(hwnd,&ps);
Sleep(500);
n++;
return 0;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询