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. Exit When Enter Key is Pressed

Exit When Enter Key is Pressed

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionlearning
5 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    i'm a beginner in visual c++,i would like to know how can i prevent my application from Exiting when Enter Key is pressed at start-up.:confused:

    D M 2 Replies Last reply
    0
    • L Lost User

      i'm a beginner in visual c++,i would like to know how can i prevent my application from Exiting when Enter Key is pressed at start-up.:confused:

      D Offline
      D Offline
      Derek Lakin
      wrote on last edited by
      #2

      Assuming your application is a dialog-based application, then pressing the enter key has the effect of pressing the default button, whichi by default is the OK button, which will cause your button to exit. If you don't want it to exit, either don't press enter, or change which button is the default one. If I'm way off then let us know a bit more about the nature of your application and I'm sure we can help :) Derek Lakin. Salamander Software Ltd.

      L 1 Reply Last reply
      0
      • L Lost User

        i'm a beginner in visual c++,i would like to know how can i prevent my application from Exiting when Enter Key is pressed at start-up.:confused:

        M Offline
        M Offline
        mProject
        wrote on last edited by
        #3

        There is one another solution. You can override OnOK function. Simply add function: void CYourDialog::OnOK() { } And your problem disappearing...:-O :-O :rose: :rose: -------------------------------------------------- Say Whatever You Know. Helping other people is good for health. ========= Manish ========= ---------------------------------------------------

        C 1 Reply Last reply
        0
        • M mProject

          There is one another solution. You can override OnOK function. Simply add function: void CYourDialog::OnOK() { } And your problem disappearing...:-O :-O :rose: :rose: -------------------------------------------------- Say Whatever You Know. Helping other people is good for health. ========= Manish ========= ---------------------------------------------------

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Why on earth would you leave the button there if you're not going to have it do anything ? You might check in OnOK if return has been pressed, so it works only by pressing the button, but it's just as easy not to make it the default button. Christian As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet. Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.

          1 Reply Last reply
          0
          • D Derek Lakin

            Assuming your application is a dialog-based application, then pressing the enter key has the effect of pressing the default button, whichi by default is the OK button, which will cause your button to exit. If you don't want it to exit, either don't press enter, or change which button is the default one. If I'm way off then let us know a bit more about the nature of your application and I'm sure we can help :) Derek Lakin. Salamander Software Ltd.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            derek, its a dialog-based application,i removed the OK button and placed the Exit function inside the Menu.:)

            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