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. Diable enter key

Diable enter key

Scheduled Pinned Locked Moved C / C++ / MFC
5 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.
  • N Offline
    N Offline
    NewHSKid
    wrote on last edited by
    #1

    I would like to know if there is a way to disable the enter key from being used in my app. It seems that every time the enter key is pressed, it closes a dialog in my app. Thank you. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

    RaviBeeR V 2 Replies Last reply
    0
    • N NewHSKid

      I would like to know if there is a way to disable the enter key from being used in my app. It seems that every time the enter key is pressed, it closes a dialog in my app. Thank you. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      There are basically 2 ways to handle this.

      • Write a handler for OnOK() that doesn't do anything (i.e. just returns) and create another "OK" button (eg. with id IDC_REAL_OK_BUTTON) and write a handler for that, which simply calls CDialog::OnOK().
      • Override PreTranslateMessage() and filter out the appropriate message - I think it's WM_CHAR but I could be wrong. This will force your user to click the OK button to end the dialog.

      /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

      N 1 Reply Last reply
      0
      • RaviBeeR RaviBee

        There are basically 2 ways to handle this.

        • Write a handler for OnOK() that doesn't do anything (i.e. just returns) and create another "OK" button (eg. with id IDC_REAL_OK_BUTTON) and write a handler for that, which simply calls CDialog::OnOK().
        • Override PreTranslateMessage() and filter out the appropriate message - I think it's WM_CHAR but I could be wrong. This will force your user to click the OK button to end the dialog.

        /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

        N Offline
        N Offline
        NewHSKid
        wrote on last edited by
        #3

        Thanks Ravi, I am still new to Programming, and what you said makes sense but is still foreign to me. Can you tell me where I would find the PreTranslateMessage() function? Perhaps you would be kind enough to point me to some example code or some steps to which i can get this accomplished. Thanks you. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

        RaviBeeR 1 Reply Last reply
        0
        • N NewHSKid

          I would like to know if there is a way to disable the enter key from being used in my app. It seems that every time the enter key is pressed, it closes a dialog in my app. Thank you. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

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

          Furthermore, override OnClose(). Kuphryn

          1 Reply Last reply
          0
          • N NewHSKid

            Thanks Ravi, I am still new to Programming, and what you said makes sense but is still foreign to me. Can you tell me where I would find the PreTranslateMessage() function? Perhaps you would be kind enough to point me to some example code or some steps to which i can get this accomplished. Thanks you. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

            RaviBeeR Offline
            RaviBeeR Offline
            RaviBee
            wrote on last edited by
            #5

            Search for the text "PreTranslateMessage" on this page: http://www.widgetware.com/faqsub.htm[^] and use the VK_ENTER code. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

            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