上面代码错了#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define PI 3.1415926 LRESULT CALLBACK WindowProc(
HWND HWND, // HANDLE TO WINDOW
UINT UMSG, // MESSAGE IDENTIFIER
WPARAM WPARAM, // FIRST MESSAGE PARAMETER
LPARAM LPARAM // SECOND MESSAGE PARAMETER
);int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
//wcex.hbrBackground = CreateSolidBrush(RGB(255,0,0));
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); //背景采用白/黑色
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WindowProc;
wndclass.lpszClassName="abc";
wndclass.lpszMenuName=NULL;
wndclass.style=0; //RegisterClass(&wndclass);
if (!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
hwnd=CreateWindow("abc","绘图",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,600,450,NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd); while(GetMessage(&Msg,hwnd,NULL,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
//return 0;
return Msg.wParam;
}LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
HDC hdc;
HBRUSH hBrush;
HPEN hpen;
PAINTSTRUCT ps;
int nCenterX,nCenterY;
switch(uMsg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,400,300,NULL);
SetViewportExtEx(hdc,600,450,NULL);
SetViewportOrgEx(hdc,300,200,NULL); //绘图开始
// 绘制圆
hpen=CreatePen(PS_SOLID,1,RGB(80,53,192)); //好看的(255,0,255)()()()()()
SelectObject(hdc,hpen);
{ //由于是在case 语句中for外面要加{}
for (int i=0;i<120;i++)
{
int j,k;
// Ellipse(hdc,-10-i,-10-i,10+i,10+i);
//Sleep(300);
Ellipse(hdc,-10-i,-10-i,10+i,10+i);
Sleep(10);
while(i%5==0)
{
for (j=i;j<120;j++)
{
Ellipse(hdc,-10-j,-10-j,10+j,10+j);
Sleep(10);
}
}
}
}
//Sleep(100);
InvalidateRect(hwnd,NULL,1);
EndPaint(hwnd,&ps); return 0;
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define PI 3.1415926 LRESULT CALLBACK WindowProc(
HWND HWND, // HANDLE TO WINDOW
UINT UMSG, // MESSAGE IDENTIFIER
WPARAM WPARAM, // FIRST MESSAGE PARAMETER
LPARAM LPARAM // SECOND MESSAGE PARAMETER
);int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
//wcex.hbrBackground = CreateSolidBrush(RGB(255,0,0));
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); //背景采用白/黑色
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WindowProc;
wndclass.lpszClassName="abc";
wndclass.lpszMenuName=NULL;
wndclass.style=0; //RegisterClass(&wndclass);
if (!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
hwnd=CreateWindow("abc","绘图",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,600,450,NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd); while(GetMessage(&Msg,hwnd,NULL,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
//return 0;
return Msg.wParam;
}LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
HDC hdc;
HBRUSH hBrush;
HPEN hpen;
PAINTSTRUCT ps;
int nCenterX,nCenterY;
switch(uMsg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
SetMapMode(hdc,MM_ANISOTROPIC);
SetWindowExtEx(hdc,400,300,NULL);
SetViewportExtEx(hdc,600,450,NULL);
SetViewportOrgEx(hdc,300,200,NULL); //绘图开始
// 绘制圆
hpen=CreatePen(PS_SOLID,1,RGB(80,53,192)); //好看的(255,0,255)()()()()()
SelectObject(hdc,hpen);
{ //由于是在case 语句中for外面要加{}
for (int i=0;i<120;i++)
{
int j,k;
// Ellipse(hdc,-10-i,-10-i,10+i,10+i);
//Sleep(300);
Ellipse(hdc,-10-i,-10-i,10+i,10+i);
Sleep(10);
while(i%5==0)
{
for (j=i;j<120;j++)
{
Ellipse(hdc,-10-j,-10-j,10+j,10+j);
Sleep(10);
}
}
}
}
//Sleep(100);
InvalidateRect(hwnd,NULL,1);
EndPaint(hwnd,&ps); return 0;
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货