为什么不能连续画线?
#include <windows.h>#define UP 0
#define DOWN 1
#define LEFT 2
#define RIGHT 3

int x=0;
int y=0;LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
void draw();
int WINAPI WinMain(HINSTANCE hInstance,
   HINSTANCE hPrevInstance,
   LPSTR lpcmdline,
   int nshowcmd
   ){ char name[]="hi";
HWND hwnd;
MSG msg; WNDCLASS wndclass;

wndclass.cbClsExtra =0;
wndclass.cbWndExtra =0;
wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor =LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance =hInstance;
wndclass.lpfnWndProc =WndProc;
wndclass.lpszClassName =name;
wndclass.lpszMenuName =NULL;
wndclass.style =CS_HREDRAW | CS_VREDRAW; if(!RegisterClass(&wndclass))
{
MessageBox(NULL,"NT NOT SUPPORT","Caption",0);
return 0;
} hwnd=CreateWindow(name,
"nihao",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL); ShowWindow(hwnd,nshowcmd);
UpdateWindow(hwnd); while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg); } return msg.wParam ;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps; switch(message)
{
case WM_CREATE: return 0;
case WM_PAINT:

return 0;
case WM_KEYDOWN:
switch (wParam)
{
case VK_UP:
draw(hwnd,&x,&y,UP );
return 0;
    case VK_DOWN:
  draw(hwnd,&x,&y,DOWN);
return 0;
case VK_LEFT:
draw(hwnd,&x,&y,LEFT);
return 0;
case VK_RIGHT:
draw(hwnd,&x,&y,RIGHT);

return 0; } return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
} return DefWindowProc(hwnd,message,wParam,lParam);
}void draw(HWND hwnd,int *x1,int *y1,int d)
{  PAINTSTRUCT ps;
HDC hdc;
hdc=BeginPaint(hwnd,&ps);
switch(d)
{case 0:
MoveToEx(hdc,*x1,*y1,NULL);
LineTo(hdc,0,*y1-100);
*x1+=0;
*y1-=100;
return 0;
case 1: MoveToEx(hdc,*x1,*y1,NULL);
LineTo(hdc,0,*y1+100);
(*x1)+=0;
(*y1)+=100;
return 0;case 2:
MoveToEx(hdc,*x1,*y1,NULL);
LineTo(hdc,*x1-100,0);
(*x1)-=100;
(*y1)+=0;
return 0;

case 3:
MoveToEx(hdc,*x1,*y1,NULL);
LineTo(hdc,*x1+100,0);
(*x1)+=100;
(*y1)+=0;
return 0;
}
EndPaint(hwnd,&ps);
}