CompuServe Thread

#no WM_KEYDOWN msgs

3 messages in this thread
#30320From: Phil CoveneyJul 8, 1994 4:29 PM
Hello, I am having difficulty handling WM_KEYDOWN in CMyWindow, my CWnd-derived window. This particular CMyWindow is the child of an MDI client window (a CFormView window). I don't really want it to process keyboard input, and I tried to avoid doing so by handling WM_SETFOCUS in this window by calling SetFocus() for 1) the parent CFormView, 2) the MDI frame (CMDIChild-derived class), and 3) the main frame (CFrameWnd-derived class) (only one at a time, of course.) In all three cases, doing so caused all of Windows to fail to respond to either the mouse or the keyboard (except good ol' Ctrl-Alt-Del). OK, I can't refuse the focus–I'll handle keystrokes. So I used ClassWiz to put in OnKeyDown and OnSysKeyDown message handlers in CMyWindow–but they never get called. I use Spy and verify that the WM_KEYDOWN message is being sent to my CMyWindow, but I don't get a break at the breakpoint I set in the handlers above, nor does any debug trace output get printed–these handlers just ain't getting called. So what's a boy to do? Anybody got any clues as to either of the above? Thanks for any help, Phil C.
#30370From: Ron BassJul 9, 1994 11:15 AM
Phil! >> OK, I can't refuse the focus–I'll handle keystrokes. So I used ClassWiz to put in OnKeyDown and OnSysKeyDown message handlers in CMyWindow–but they never get called. I use Spy and verify that the WM_KEYDOWN message is being sent to my CMyWindow, but I don't get a break at the breakpoint I set in the handlers above, nor does any debug trace output get printed–these handlers just ain't getting called. So what's a boy to do? Anybody got any clues as to either of the above? Add a message handler for WM_CHAR. The framework "pre-translates" keystroke messages when an ASCII character would be generated, and sends this message instead of WM_KEYDOWN. hth — Ron
#30550From: Phil CoveneyJul 11, 1994 3:44 PM
Ron, >>Add a message handler for WM_CHAR. The framework "pre-translates" keystroke messages when an ASCII character would be generated, and sends this message instead of WM_KEYDOWN. Thanks for the help. It sounded like a really likely solution, but I'm sorry to report that neither the CMyWindow::OnChar() handler, nor its CFormView-derived parent's OnChar() handler, is being called. Again, Spy reports that WM_KEYDOWN is being sent to CMyWindow. Is the code that performs the pre-translation process to which you referred available to me (in \MFC\SRC)? Should this translation result in a WM_CHAR message being sent (Spy says none is), or should OnChar() be getting called directly? Is a particular WS_ style required for CMyWindow? (I'm grasping.) Again, thanks for any light. Phil C.