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. Handling of ESCAPE and RETURN

Handling of ESCAPE and RETURN

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

    I want to handle the ESCAPE key in certain situation; I try to catch it in PreTranslateMessage with WM_KEYUP. Pressing ESCAPE leads always to the "cancel" result. If I have a control named IDCANCEL, the OnClicked handler receives the control, whenever ESACPE has been pressed, but I can not differentiate between clicking on that control and the "true ESCAPE". Is there a way I can separate the "escape" key from the CANCEL button and from "exit" ("X" in the system menu)? Actually, I need it in a CEdit control.

    P K 2 Replies Last reply
    0
    • V Vancouver

      I want to handle the ESCAPE key in certain situation; I try to catch it in PreTranslateMessage with WM_KEYUP. Pressing ESCAPE leads always to the "cancel" result. If I have a control named IDCANCEL, the OnClicked handler receives the control, whenever ESACPE has been pressed, but I can not differentiate between clicking on that control and the "true ESCAPE". Is there a way I can separate the "escape" key from the CANCEL button and from "exit" ("X" in the system menu)? Actually, I need it in a CEdit control.

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      Refer this[^]. Similarly, use VK_RETURN for enter key.

      Prasad Notifier using ATL | Operator new[],delete[][^]

      V 1 Reply Last reply
      0
      • V Vancouver

        I want to handle the ESCAPE key in certain situation; I try to catch it in PreTranslateMessage with WM_KEYUP. Pressing ESCAPE leads always to the "cancel" result. If I have a control named IDCANCEL, the OnClicked handler receives the control, whenever ESACPE has been pressed, but I can not differentiate between clicking on that control and the "true ESCAPE". Is there a way I can separate the "escape" key from the CANCEL button and from "exit" ("X" in the system menu)? Actually, I need it in a CEdit control.

        K Offline
        K Offline
        karle
        wrote on last edited by
        #3

        Give the button a different ID and a new handler for this ID, than it should work. To catch up ESCAPE you need to catch the WM_KEYDOWN Event. But it is important where the PreTranslateMessage. Try to catch the WM_KEYDOWN event in your Dialog class.

        1 Reply Last reply
        0
        • P prasad_som

          Refer this[^]. Similarly, use VK_RETURN for enter key.

          Prasad Notifier using ATL | Operator new[],delete[][^]

          V Offline
          V Offline
          Vancouver
          wrote on last edited by
          #4

          Thanks, it works with KEYDOWN

          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