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. Suppress return and escape in a dlg

Suppress return and escape in a dlg

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

    I am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening?? Øivind

    R M A 3 Replies Last reply
    0
    • D dolph_loe

      I am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening?? Øivind

      R Offline
      R Offline
      Rob Manderson
      wrote on last edited by
      #2

      Add OnOK() and OnCancel() handlers and don't call the base class handlers. Ie,

      void CMyDialog::OnOK()
      {
      CDialog::OnOK(); // Wizard generated code
      }

      just comment out the Wizard generated call to CDialog::OnOK() and all will work as you expect. Rob Manderson Colin Davies wrote: I'm sure Americans could use more of it, and thus reduce the world supply faster. This of course would be good, because the faster we run out globally, the less chance of pollution there will be. (Talking about the price of petrol) The Soapbox, March 5 2004

      1 Reply Last reply
      0
      • D dolph_loe

        I am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening?? Øivind

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        See the FAQ 7.4 How do I prevent a dialog from closing when the user presses Enter or Esc?[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- I even hear the Windows "OMG I booted up fine" sound.   -- Paul Watson diagnosing hardware problems.

        1 Reply Last reply
        0
        • D dolph_loe

          I am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening?? Øivind

          A Offline
          A Offline
          Antony M Kancidrowski
          wrote on last edited by
          #4

          Alternatively you can override PreTranslateMessage

          BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
          {
          // Check for a keypress
          if (pMsg->message == WM_KEYDOWN)
          {
          // Check for CR and ESC
          if ((pMsg->wParam == 13) || (pMsg->wParam == 27))
          {
          // Soak them up, no further processing
          return TRUE;
          }
          }

          return CDialog::PreTranslateMessage(pMsg);
          

          }

          Sorry cant remember the VK defns (its too late!) Ant.

          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