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. How to get KeyPessed event from an editbox

How to get KeyPessed event from an editbox

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 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.
  • G Offline
    G Offline
    gunner_uk2000
    wrote on last edited by
    #1

    Here is my event handling code: LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: Init(); case WM_PAINT: PaintScreen(); break; case WM_CLOSE : DestroyWindow(hwnd); break; case WM_KEYDOWN: if(wParam == 13){ ProcessCommand(); } case WM_COMMAND : if(LOWORD(wParam) == ID_COMMAND) ProcessCommand(); break; case WM_DESTROY : PostQuitMessage(0); break; } return DefWindowProc(hwnd, msg, wParam, lParam); } This only works if the main window has the focus, so how can i check which key was pressed if the editbox (ID_EDITBOX) has the focus. Ie so that if the user presses enter i can run the proccessing needed on it.

    R 1 Reply Last reply
    0
    • G gunner_uk2000

      Here is my event handling code: LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: Init(); case WM_PAINT: PaintScreen(); break; case WM_CLOSE : DestroyWindow(hwnd); break; case WM_KEYDOWN: if(wParam == 13){ ProcessCommand(); } case WM_COMMAND : if(LOWORD(wParam) == ID_COMMAND) ProcessCommand(); break; case WM_DESTROY : PostQuitMessage(0); break; } return DefWindowProc(hwnd, msg, wParam, lParam); } This only works if the main window has the focus, so how can i check which key was pressed if the editbox (ID_EDITBOX) has the focus. Ie so that if the user presses enter i can run the proccessing needed on it.

      R Offline
      R Offline
      Rinu_Raj
      wrote on last edited by
      #2

      Map the EN_CHANGE notification Rinu Raj

      G 1 Reply Last reply
      0
      • R Rinu_Raj

        Map the EN_CHANGE notification Rinu Raj

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

        How would i go about using the EN_CHANGE notifcation? As checking for it in the switch case does not work as the code is not executed when i key is pressed. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: Init(); case WM_PAINT: PaintScreen(); break; case WM_CLOSE : DestroyWindow(hwnd); break; case WM_KEYDOWN: if(wParam == 13){ ProcessCommand(); } break; case EN_CHANGE: if(wParam == 13){ ProcessCommand(); } break; case WM_COMMAND : if(LOWORD(wParam) == ID_COMMAND) ProcessCommand(); break; case WM_DESTROY : PostQuitMessage(0); break; } return DefWindowProc(hwnd, msg, wParam, lParam); }

        R 1 Reply Last reply
        0
        • G gunner_uk2000

          How would i go about using the EN_CHANGE notifcation? As checking for it in the switch case does not work as the code is not executed when i key is pressed. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: Init(); case WM_PAINT: PaintScreen(); break; case WM_CLOSE : DestroyWindow(hwnd); break; case WM_KEYDOWN: if(wParam == 13){ ProcessCommand(); } break; case EN_CHANGE: if(wParam == 13){ ProcessCommand(); } break; case WM_COMMAND : if(LOWORD(wParam) == ID_COMMAND) ProcessCommand(); break; case WM_DESTROY : PostQuitMessage(0); break; } return DefWindowProc(hwnd, msg, wParam, lParam); }

          R Offline
          R Offline
          Rinu_Raj
          wrote on last edited by
          #4

          case WM_COMMAND : if(LOWORD(wParam) == EN_CHANGE) check MSDN for details Rinu Raj

          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