把pos定义
static int pos=0;
把代码修改如下:
case WM_CHAR:
if (wParam!=0)
{
buf[pos]=(unsigned char)(wParam);
pos=pos+1;
}
InvalidateRect(hwnd,NULL,0);