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. Dialog Disappear on pressing Escape key

Dialog Disappear on pressing Escape key

Scheduled Pinned Locked Moved C / C++ / MFC
8 Posts 5 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.
  • Z Offline
    Z Offline
    Zeeshan Bilal
    wrote on last edited by
    #1

    HI, On pressing Escape Key , my application dialog disappears .... Some one asked me to Override OnOk() and OnCancel() ...but there is no result ... Plz tell me a good one . thanx

    J A A 3 Replies Last reply
    0
    • Z Zeeshan Bilal

      HI, On pressing Escape Key , my application dialog disappears .... Some one asked me to Override OnOk() and OnCancel() ...but there is no result ... Plz tell me a good one . thanx

      J Offline
      J Offline
      Johan Rosengren
      wrote on last edited by
      #2

      Did you remove the call to the CDialog implementation in OnCancel?

      Z 2 Replies Last reply
      0
      • Z Zeeshan Bilal

        HI, On pressing Escape Key , my application dialog disappears .... Some one asked me to Override OnOk() and OnCancel() ...but there is no result ... Plz tell me a good one . thanx

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Please check out the reply in your previous thread.. It has a sample implementation. It might help you... if not, do not know where the prob is..

        1 Reply Last reply
        0
        • J Johan Rosengren

          Did you remove the call to the CDialog implementation in OnCancel?

          Z Offline
          Z Offline
          Zeeshan Bilal
          wrote on last edited by
          #4

          i got it,, thanx ,, but wts a relation between Escape key and OnCancel() can u tell me littlte detail thanx

          1 Reply Last reply
          0
          • J Johan Rosengren

            Did you remove the call to the CDialog implementation in OnCancel?

            Z Offline
            Z Offline
            Zeeshan Bilal
            wrote on last edited by
            #5

            Removing Oncancel .... escape key ok But Clsoe Button in System menu near maximize not works to close application another problm now any help abut it

            J PJ ArendsP 2 Replies Last reply
            0
            • Z Zeeshan Bilal

              HI, On pressing Escape Key , my application dialog disappears .... Some one asked me to Override OnOk() and OnCancel() ...but there is no result ... Plz tell me a good one . thanx

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

              I normally use PreTranslateMessage to prevent unwanted key presses

              BOOL CDialogClass::PreTranslateMessage(MSG* pMsg)
              {
                // Have we pressed a key
                if (pMsg->message == WM_KEYDOWN)
                {
                  // We only want to ignore the ESC
                  if (pMsg->wParam == VK_ESCAPE)
                  {
                    return TRUE;
                  }
                }

              return CDialog::PreTranslateMessage(pMsg);
              }

              Ant. I'm hard, yet soft.
              I'm coloured, yet clear.
              I'm fruity and sweet.
              I'm jelly, what am I? Muse on it further, I shall return!
              - David Williams (Little Britain)

              1 Reply Last reply
              0
              • Z Zeeshan Bilal

                Removing Oncancel .... escape key ok But Clsoe Button in System menu near maximize not works to close application another problm now any help abut it

                J Offline
                J Offline
                Johan Rosengren
                wrote on last edited by
                #7

                If you only want to filter the physical keyboard key, look at Anthonys answer below.

                1 Reply Last reply
                0
                • Z Zeeshan Bilal

                  Removing Oncancel .... escape key ok But Clsoe Button in System menu near maximize not works to close application another problm now any help abut it

                  PJ ArendsP Offline
                  PJ ArendsP Offline
                  PJ Arends
                  wrote on last edited by
                  #8

                  button work when you override OnCancel() you have to override OnClose(). In the override call CDialog::OnCancel(). The default behaviour of OnClose() is to call your overridden OnCancel() which you have told to do nothing. Do not override PreTranslateMessage(). That is just the lazyman's way of hacking things together.


                  [

                  ](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!

                  Within you lies the power for good; Use it!

                  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