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. Keyboard Input - MFC

Keyboard Input - MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugging
3 Posts 3 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.
  • S Offline
    S Offline
    sweep123
    wrote on last edited by
    #1

    On a dialog application I would like to capture keyboard input when I press a button and then stop when the button is pressed again. I have included the WM_CHAR and WM_KEYDOWN messages on the dialog, but they are not activated. I can type into an Edit box on just press keys when over the dialog, but breakpoint in void CKeyBoard_CDNUDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)is never reached. Is there something else I need to do in order to get the keyboard characters pressed.

    A 1 Reply Last reply
    0
    • S sweep123

      On a dialog application I would like to capture keyboard input when I press a button and then stop when the button is pressed again. I have included the WM_CHAR and WM_KEYDOWN messages on the dialog, but they are not activated. I can type into an Edit box on just press keys when over the dialog, but breakpoint in void CKeyBoard_CDNUDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)is never reached. Is there something else I need to do in order to get the keyboard characters pressed.

      A Offline
      A Offline
      Abin
      wrote on last edited by
      #2

      You need to do it in PreTranslateMessage. BOOL CMyDialog::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if (pMsg->message == WM_KEYDOWN) { if (pMsg->wParam == some_key_code) { Do_SomeThing(); } } return CDialog::PreTranslateMessage(pMsg); }

      G 1 Reply Last reply
      0
      • A Abin

        You need to do it in PreTranslateMessage. BOOL CMyDialog::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if (pMsg->message == WM_KEYDOWN) { if (pMsg->wParam == some_key_code) { Do_SomeThing(); } } return CDialog::PreTranslateMessage(pMsg); }

        G Offline
        G Offline
        Grahamfff
        wrote on last edited by
        #3

        Thanks now doing it in PreTranslateMessage, but all the normal keys I process seem to be upper case, even when I change the Caps Lock. ARe they a flag that controls the case? sweep123

        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