Problem with WM_KEYDOWN messages.

I'm using MFC and I have a main window with a splitter and two views, and inside one of the views I have a Tab Control. Inside the tab control, I dynamically create several dialogs as child windows of the tab. Inside one of the dialogs, I have created a grid window (custom built) and I'm trying to receive WM_KEYDOWN messages in the grid window. The grid window recieves WM_KEYUP messages fine, but when I try to handle the WM_KEYDOWN messages in the grid window, everything gets kind of screwed up. When I press any alpha-numeric keys, I get receive the WM_KEYDOWN message, but it beeps. When I press space, control, shift, caps lock, F1 - F12 and most other keys, there is no beep and the WM_KEYDOWN message is sent. When I press the arrow keys, nothing happens, except when I release the key, I get a WM_KEYUP message. Has anyone run into this before? It's almost like another window is grabbing the input before the grid window, which has the focus, gets a chance to proccess the message. I'm totally stuck here. Help please?!

Comments

  • Is your grid window a self created dialog box? Knowing this would be helpful.

  • : Is your grid window a self created dialog box? Knowing this would be helpful.
    :

    No. The grid window is not a dialog box. It is a window derived directly from CWnd, but it is created by/in a CDialog that is under a CTabCtrl that is under a CView that is under the CFrameWnd. It all sounds very complicated. :)

  • : : Is your grid window a self created dialog box? Knowing this would be helpful.
    : :
    :
    : No. The grid window is not a dialog box. It is a window derived directly from CWnd, but it is created by/in a CDialog that is under a CTabCtrl that is under a CView that is under the CFrameWnd. It all sounds very complicated. :)
    :

    Okay ... I've figured out a little bit more about why the problem is happening. Since the parent of my grid window is a dialog, the dialog is processing keydown messages before my grid window gets a chance to process the message. More specifically, it's processing tab, up, down, right, and left keys, four of which I need to use. So, is there any way to get the messages before the dialog? Is there some virtual function that I can override? Thanks.

  • : : : Is your grid window a self created dialog box? Knowing this would be helpful.
    : : :
    : :
    : : No. The grid window is not a dialog box. It is a window derived directly from CWnd, but it is created by/in a CDialog that is under a CTabCtrl that is under a CView that is under the CFrameWnd. It all sounds very complicated. :)
    : :
    :
    : Okay ... I've figured out a little bit more about why the problem is happening. Since the parent of my grid window is a dialog, the dialog is processing keydown messages before my grid window gets a chance to process the message. More specifically, it's processing tab, up, down, right, and left keys, four of which I need to use. So, is there any way to get the messages before the dialog? Is there some virtual function that I can override? Thanks.
    :

    Nevermind ... I figured it out. Excessive posting I guess ... it's faster to just work on it. For anyone else who has run into this problem and not figure out how to get around it, check out handling the WM_GETDLGCODE message.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories