I am making a smallish app to diplay a picture and play a *.wav when the user(my son) presses a key i.e. a is for apple and so on. I want to catch all the key events and proccess them allowing only a-z and 1-9 to get through I don't want any windows or system keys to work until the program is closed.
What is the best way to catch the key down or up, I think up because I only want it to fire a pic and wav once per key and he might hold them down. Is this true?
Also how can I get the WM_SYSKEY* to work in the msdn documetation it says if an application wants to use these keys to but i have this in my proc and they all still fire perfectly.
the wndProc
Code:
LRESULT CALLBACK wndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
switch(uMsg){
case WM_KEYDOWN: // A Key has been pressed down
return 0;
case WM_KEYUP: // a key has been released
return 0;
case WM_SYSKEYDOWN: // system key hs been pressed down
return 0;
case WM_SYSKEYUP: // system key has been released
return 0;
case WM_RBUTTONDBLCLK:
return DestroyWindow(hwnd);
case WM_LBUTTONDBLCLK:
return DestroyWindow(hwnd);
case WM_MBUTTONDBLCLK:
return DestroyWindow(hwnd);
case WM_DESTROY:
ShowCursor(true);
PostQuitMessage(0);
default: // If I don't use it let windows handle it
return DefWindowProc(hwnd,uMsg,wParam,lParam);
break;
}
}
I am pretty sure i can handle LoadImage,bitblt and sndPlaySound
so the rest of this app is hop[efully going to be nothing more than timing when to accept a key press and when not to...
my son is 13 months and loves the pc. he gets on and goes crazy with the keyboard restarts the computer and everything else that can be done for key press