Jump to content


Help with WM_KEYDOWN, SC_KEYMENU & F10 key press


3 replies to this topic

#1 marek-knows.com

    Valued Member

  • Members
  • PipPipPip
  • 189 posts
  • LocationOntario, Canada

Posted 03 November 2007 - 11:17 PM

I'm using the WM_KEYDOWN message send to WinProc to do some work in my program, but I have noticed that when I press F10, focus is lost to my window. My program never gets a WM_KEYDOWN message. Instead it gives me a WM_SYSCOMMAND with wParam = SC_KEYMENU.

Is there anyway to disable this behaviour so that when I press F10, I instead get a WM_KEYDOWN message with VK_F10 being passed in as the wParam?

I also get strange behaviour when I press F12 on the keyboard. .... basically my program crashes.... not sure why yet. All other F keys work fine.

Another thing; anyone know why I'm getting wParam = VK_RETURN when I press the enter key on the number pad? I was thinking I should get VK_SEPARATOR.

The "Print Screen" button doesn't seem to work either .... I tried VK_SNAPSHOT and VK_PRINT but neither work.

Oh, and what is the deal with the left/right shift, ctrl and alt buttons. When I press them, I can't seem to differentiate between the left ones and the right ones.
3D OpenGL, C++ Game Development Video Tutorials @
www.marek-knows.com

#2 Nils Pipenbrinck

    Senior Member

  • Members
  • PipPipPipPip
  • 597 posts

Posted 03 November 2007 - 11:36 PM

Hi mmakrzem.

F10 is the shortcut to activate the menu-bar. Maybe you get the keycodes if you create your window without a menu. That might work.

F12 does not crash your program. It invokes the debugger and break into the running program. That only happends if you run the program from within visual studio. Start it outside and F12 will do what it ought to.
My music: http://myspace.com/planetarchh <-- my music

My stuff: torus.untergrund.net <-- some diy electronic stuff and more.

#3 marek-knows.com

    Valued Member

  • Members
  • PipPipPip
  • 189 posts
  • LocationOntario, Canada

Posted 03 November 2007 - 11:42 PM

Ahh, okay, that explains F12. My program doesn't have a menu but SC_KEYMENU is still being sent to me. Maybe I can send a message back to my WinProc anytime I receive SC_KEYMENU forcing a WM_KEYDOWN to be called.... hmmm, but then how do I handle the F10 Key up event?
3D OpenGL, C++ Game Development Video Tutorials @
www.marek-knows.com

#4 .oisyn

    DevMaster Staff

  • Moderators
  • 1822 posts

Posted 04 November 2007 - 02:37 PM

F10 causes a WM_SYSKEYDOWN and WM_SYSKEYUP rather than a regular WM_KEYDOWN and WM_KEYUP. If you pass that to the DefWindowProc, that will result in the WM_SYSCOMMAND being sent, but you can prevent that by monitoring the wm_syskey* notifications and process it as a wm_key* notification if it's the F10 key being pressed or released :)
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users