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. Application will be closing when Pressed "Enter" or "Escape"

Application will be closing when Pressed "Enter" or "Escape"

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
4 Posts 4 Posters 3 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.
  • Y Offline
    Y Offline
    YSRao
    wrote on last edited by
    #1

    The Applications which I have written in vc++ are terminating when I press "Enter" Button or pressing "Escape" button.How can I prevent this type of termination.

    P R B 3 Replies Last reply
    0
    • Y YSRao

      The Applications which I have written in vc++ are terminating when I press "Enter" Button or pressing "Escape" button.How can I prevent this type of termination.

      P Offline
      P Offline
      Pavel Klocek
      wrote on last edited by
      #2

      YSRao wrote: The Applications which I have written in vc++ are terminating when I press "Enter" Button or pressing "Escape" button. I suppose they are dialog based. If it's so, then override OnOK and OnCancel handlers. Pavel Sonork 100.15206

      1 Reply Last reply
      0
      • Y YSRao

        The Applications which I have written in vc++ are terminating when I press "Enter" Button or pressing "Escape" button.How can I prevent this type of termination.

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        I assume you've written a dialog based app. Override the OnOK() and OnCancel() handlers to simply return; without calling the base class methods. Then, add a button (eg: IDC_BUTTON_EXIT) to your dialog and call CDialog::OnOK() in its handler. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

        1 Reply Last reply
        0
        • Y YSRao

          The Applications which I have written in vc++ are terminating when I press "Enter" Button or pressing "Escape" button.How can I prevent this type of termination.

          B Offline
          B Offline
          Bartosz Bien
          wrote on last edited by
          #4

          I guess this is a dialog-based app, so you need to override CYourDlg::PreTranslateMessage to catch WM_KEYDOWN messages with (wParam == VK_RETURN || wParam == VK_ESCAPE). You may simply return TRUE from this function (with no base implementation call) to get rid of the behavior you mentioned. Regards, BB

          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