请问一下为什么我这段程序,在我按下键盘后没有输出的
#include<windows.h>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
WNDCLASS wndclass;
HWND hwnd;
MSG msg;
static TCHAR tName[]=TEXT("Title");
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(hInstance,IDC_ARROW);
wndclass.hIcon=LoadIcon(hInstance,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName=tName;
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,NULL,tName,MB_YESNO);
return 0;
}
hwnd=CreateWindow(tName,TEXT("WindowName"),
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT nmsg,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
static TCHAR Shift[]=TEXT("You've hitted the shift key");
static TCHAR Ctrl[]=TEXT("You've hitted the ctrl key");
static TCHAR Up[]=TEXT("You've hitted the up key");
static TCHAR ShiftB[]=TEXT("You've hitted the shift and B");
static TCHAR CtrlA[]=TEXT("You've hitted the ctrl and A");
bool fUp=false;
bool fCtrl=false;
bool fShift=false;
bool fCtrlA=false;
bool fShiftB=false;
switch(nmsg)
{
case WM_KEYDOWN:
{
switch(wParam)
case VK_UP:
fUp=true;
break;
case VK_CONTROL:
fCtrl=true;
break;
case VK_SHIFT:
fShift=true;
break;
default:
break;
}
break;
case WM_KEYUP:
InvalidateRect(hwnd,NULL,true);
break;
case WM_CHAR:
if(wParam==97||wParam==65)
{
if(fCtrl)
{
fCtrlA=true;
fCtrl=false;
}
}
else
{
if(wParam==98||wParam==66)
{
if(fShift)
{
fShiftB=true;
fShift=false;
}
}
}
break;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
SetTextColor(hdc,RGB(255,0,0));
if(fShift)
{
TextOut(hdc,1,1,Shift,lstrlen(Shift));
}
else
if(fUp)
{
TextOut(hdc,1,1,Up,lstrlen(Up));
}
else
if(fCtrl)
{
TextOut(hdc,1,1,Ctrl,lstrlen(Ctrl));
}
else
if(fCtrlA)
{
TextOut(hdc,1,1,CtrlA,lstrlen(CtrlA));
}
else
if(fShiftB)
{
TextOut(hdc,1,1,ShiftB,lstrlen(ShiftB));
}
EndPaint(hwnd,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd,nmsg,wParam,lParam);
}