Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OnKeyDown() ignored?

OnKeyDown() ignored?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aquawicket
    wrote on last edited by
    #1

    I'm incerting the OnKeyDown function to catch keyboard events.. Problem is it never makes it to the function.. void MyDlg::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) { AfxMessageBox(L"Got a key stroke"); <-- never pops up CDialog::OnKeyDown( nChar, nRepCnt, nFlags ); return; } I've got an OnMouseWheel funtion in that works perfectly.. So I have OnKeyDown set in the same way.. Any Ideas?

    M 1 Reply Last reply
    0
    • A aquawicket

      I'm incerting the OnKeyDown function to catch keyboard events.. Problem is it never makes it to the function.. void MyDlg::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) { AfxMessageBox(L"Got a key stroke"); <-- never pops up CDialog::OnKeyDown( nChar, nRepCnt, nFlags ); return; } I've got an OnMouseWheel funtion in that works perfectly.. So I have OnKeyDown set in the same way.. Any Ideas?

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Do you have a WM_KEYDOWN entry in the window class' message map? The WM_KEYDOWN will go to the window with keyboard focus. In a dialog this may be one of the controls in the dialog. Mark

      "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

      A 1 Reply Last reply
      0
      • M Mark Salsbery

        Do you have a WM_KEYDOWN entry in the window class' message map? The WM_KEYDOWN will go to the window with keyboard focus. In a dialog this may be one of the controls in the dialog. Mark

        "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

        A Offline
        A Offline
        aquawicket
        wrote on last edited by
        #3

        yes I have ON_WM_KEYDOWN() in the message map.. hmmmm.. the function is just not hitting..

        M 1 Reply Last reply
        0
        • A aquawicket

          yes I have ON_WM_KEYDOWN() in the message map.. hmmmm.. the function is just not hitting..

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Then the window whos class your catching it in doesn't have keyboard focus. Try using SetFocus() to set the keyboard focus to the dialog and see if it starts to work. Mark

          "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

          A 2 Replies Last reply
          0
          • M Mark Salsbery

            Then the window whos class your catching it in doesn't have keyboard focus. Try using SetFocus() to set the keyboard focus to the dialog and see if it starts to work. Mark

            "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

            A Offline
            A Offline
            aquawicket
            wrote on last edited by
            #5

            I must be overiding the keyboard somewhere because I've used SetFocus(), and my OnMouseWheel works to proove it focus.. Looks like I'll have to hunt for the block.. :) Thanks Mark..

            1 Reply Last reply
            0
            • M Mark Salsbery

              Then the window whos class your catching it in doesn't have keyboard focus. Try using SetFocus() to set the keyboard focus to the dialog and see if it starts to work. Mark

              "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

              A Offline
              A Offline
              aquawicket
              wrote on last edited by
              #6

              I must be overiding the keyboard somewhere because I've used SetFocus(), and my OnMouseWheel works to proove it's focus.. Looks like I'll have to hunt for the block.. :) Thanks Mark..

              A 1 Reply Last reply
              0
              • A aquawicket

                I must be overiding the keyboard somewhere because I've used SetFocus(), and my OnMouseWheel works to proove it's focus.. Looks like I'll have to hunt for the block.. :) Thanks Mark..

                A Offline
                A Offline
                aquawicket
                wrote on last edited by
                #7

                Hmm.. still having trouble with this one... I've started a whole new dialog that I can open child dialogs within.. OnKeyDown() works until I add an object to the parent dialog or open a child dialog.. I've tried SetFocus() every which way possible.. It's just not happening.. There must be a way...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups