LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow){
WNDCLASSEX wc;
HWND hWnd;
MSG msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW|CS_VREDRAW;
wc.hInstance = hInstance;
wc.lpszClassName = "DX21";
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW +1);
wc.lpszMenuName =NULL;
wc.cbClsExtra =0;
wc.cbWndExtra =0;
if(!RegisterClassEx(&wc)){
MessageBox(NULL,"エラー","bb",MB_OK);
}
hWnd = CreateWindow(wc.lpszClassName,
"DX21 Sample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
480,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
PeekMessage(&msg,NULL,0,0,PM_REMOVE);
while(msg.message!=WM_QUIT)
{
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message){
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CREATE:
MessageBox(NULL,"Hello","DX21",MB_OK);
break;
case WM_LBUTTONDOWN:
MessageBox(NULL,"左","DX21",MB_OK);
break;
case WM_RBUTTONDOWN:
MessageBox(NULL,"右","DX21",MB_OK);
break;
case WM_KEYDOWN:
MessageBox(NULL,"a","DX21",MB_OK);
break;
default:
return DefWindowProc (hWnd,message,wParam,lParam);
}
return 0;
}
我的问题是 怎么能控制 WM_KEYDOWN的键盘响应
比如按下a 会弹出按下的是a的消息盒子
按下b 会弹出按下的是b的消息盒子
请大大们能否根据上面的代码给改下 谢谢