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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. termination of the dialog

termination of the dialog

Scheduled Pinned Locked Moved C / C++ / MFC
help
10 Posts 8 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.
  • M Offline
    M Offline
    mosali satish
    wrote on last edited by
    #1

    hai, iam getting a small problem with dialogs.when ever a dialog is displayed and when ENTER or ESC key is pressed then the dialog is terminating.so plz help me to sort out this problem. sathish

    R L N R H 7 Replies Last reply
    0
    • M mosali satish

      hai, iam getting a small problem with dialogs.when ever a dialog is displayed and when ENTER or ESC key is pressed then the dialog is terminating.so plz help me to sort out this problem. sathish

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #2

      By default the enter key means IDOK and esc key means IDCANCEL commands. So avoid this you have to override the followings functions as... void OnOK() { /* nothing to do */ } void OnCancel() { /* nothing to do */ } Try it... - NS -

      1 Reply Last reply
      0
      • M mosali satish

        hai, iam getting a small problem with dialogs.when ever a dialog is displayed and when ENTER or ESC key is pressed then the dialog is terminating.so plz help me to sort out this problem. sathish

        R Offline
        R Offline
        Rage
        wrote on last edited by
        #3

        http://www.codeproject.com/cpp/cppforumfaq.asp#mfc_dlgclosekeys[^] ~RaGE();

        1 Reply Last reply
        0
        • M mosali satish

          hai, iam getting a small problem with dialogs.when ever a dialog is displayed and when ENTER or ESC key is pressed then the dialog is terminating.so plz help me to sort out this problem. sathish

          L Offline
          L Offline
          Le Thanh Cong
          wrote on last edited by
          #4

          You can override 2 function OnOK() (for ENTER) and OnCancel (for ESC). In override function, you don't call base function from class CDialog Example: void CMyDialog::OnOK() { //CDialog::OnOK(); } ----------------- conglt

          1 Reply Last reply
          0
          • M mosali satish

            hai, iam getting a small problem with dialogs.when ever a dialog is displayed and when ENTER or ESC key is pressed then the dialog is terminating.so plz help me to sort out this problem. sathish

            R Offline
            R Offline
            RChin
            wrote on last edited by
            #5

            The Esc key is automatically mapped to the IDCANCEL command. So you can get over that by overriding the handler to create an empty function. Your Enter key is probably calling the OnOK handler because your OK button has the default focus. Again you could override the IDOK handler and bypass the default action, but you should provide an alternative means of exiting yoru dialog (calling the CDialog::OnOk(), or EndDialog() functions), else your program will have no means of quitting.


            I Dream of Absolute Zero

            1 Reply Last reply
            0
            • M mosali satish

              hai, iam getting a small problem with dialogs.when ever a dialog is displayed and when ENTER or ESC key is pressed then the dialog is terminating.so plz help me to sort out this problem. sathish

              N Offline
              N Offline
              Nishad S
              wrote on last edited by
              #6

              Yes, I forgot that... You have to map WM_CLOSE and call EndDialog( 0 ) from there (OnClose fn) inorder to process the dialog close. - NS -

              1 Reply Last reply
              0
              • M mosali satish

                hai, iam getting a small problem with dialogs.when ever a dialog is displayed and when ENTER or ESC key is pressed then the dialog is terminating.so plz help me to sort out this problem. sathish

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                Hi mosali satish, maybe it is some helpful to you http://bobmoore.mvps.org/Win32/w32tip41.htm[^]

                B 1 Reply Last reply
                0
                • H Hamid Taebi

                  Hi mosali satish, maybe it is some helpful to you http://bobmoore.mvps.org/Win32/w32tip41.htm[^]

                  B Offline
                  B Offline
                  bamboodidi
                  wrote on last edited by
                  #8

                  deal with the message "WM_KEYDOWN" in the function "PreTranslateMessage" like this: BOOL CYourDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message == WM_KEYDOWN) { int nVitKey = (int)pMsg->wParam; if(nVitKey == VK_RETURN) return TRUE; else if(nVitKey == VK_ESCAPE) return TRUE; } return CDialog::PreTranslateMessage(pMsg); } than when you press the "enter"and"ESC" the dialog will not terminate. bambooshan

                  H 1 Reply Last reply
                  0
                  • M mosali satish

                    hai, iam getting a small problem with dialogs.when ever a dialog is displayed and when ENTER or ESC key is pressed then the dialog is terminating.so plz help me to sort out this problem. sathish

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    See here.


                    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                    "There is no death, only a change of worlds." - Native American Proverb

                    1 Reply Last reply
                    0
                    • B bamboodidi

                      deal with the message "WM_KEYDOWN" in the function "PreTranslateMessage" like this: BOOL CYourDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message == WM_KEYDOWN) { int nVitKey = (int)pMsg->wParam; if(nVitKey == VK_RETURN) return TRUE; else if(nVitKey == VK_ESCAPE) return TRUE; } return CDialog::PreTranslateMessage(pMsg); } than when you press the "enter"and"ESC" the dialog will not terminate. bambooshan

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #10

                      Hi bambooshan, Is this my answer?or mosali satish

                      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