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. Dialog

Dialog

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

    Hi, Is there a way to prevent dialog from closing when pressing on "enter" keyboard button? Thanks Everything's beautiful if you look at it long enough...

    D A RaviBeeR J 4 Replies Last reply
    0
    • M MemLeak

      Hi, Is there a way to prevent dialog from closing when pressing on "enter" keyboard button? Thanks Everything's beautiful if you look at it long enough...

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

      If you are using MFC, see this FAQ: http://www.codeproject.com/cpp/cppforumfaq.asp#mfc\_dlgclosekeys

      A 1 Reply Last reply
      0
      • M MemLeak

        Hi, Is there a way to prevent dialog from closing when pressing on "enter" keyboard button? Thanks Everything's beautiful if you look at it long enough...

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

        You could always override CDialog::OnOK() but that would also stop the OK button from making your dialog disappear. Adam. My world tour What I do now.. "I spent a lot of my money on booze, birds and fast cars. The rest I just squandered" George Best.

        1 Reply Last reply
        0
        • D David Crow

          If you are using MFC, see this FAQ: http://www.codeproject.com/cpp/cppforumfaq.asp#mfc\_dlgclosekeys

          A Offline
          A Offline
          adamUK
          wrote on last edited by
          #4

          http://www.codeproject.com/cpp/cppforumfaq.asp#mfc_dlgclosekeys[^] My world tour What I do now.. "I spent a lot of my money on booze, birds and fast cars. The rest I just squandered" George Best.

          1 Reply Last reply
          0
          • M MemLeak

            Hi, Is there a way to prevent dialog from closing when pressing on "enter" keyboard button? Thanks Everything's beautiful if you look at it long enough...

            RaviBeeR Offline
            RaviBeeR Offline
            RaviBee
            wrote on last edited by
            #5

            Also, don't forget to override OnCancel() if you don't want the dialog to disappear when the user presses Esc. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

            A 1 Reply Last reply
            0
            • RaviBeeR RaviBee

              Also, don't forget to override OnCancel() if you don't want the dialog to disappear when the user presses Esc. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

              A Offline
              A Offline
              adamUK
              wrote on last edited by
              #6

              Hmm..kinda wondering how to stop the enter button but still enable the Ok button (okay, I guess I could hide the default OK button, create a new one that does all the stuff but I think it is cheating....) any thoughts? My world tour What I do now.. "I spent a lot of my money on booze, birds and fast cars. The rest I just squandered" George Best.

              RaviBeeR 1 Reply Last reply
              0
              • A adamUK

                Hmm..kinda wondering how to stop the enter button but still enable the Ok button (okay, I guess I could hide the default OK button, create a new one that does all the stuff but I think it is cheating....) any thoughts? My world tour What I do now.. "I spent a lot of my money on booze, birds and fast cars. The rest I just squandered" George Best.

                RaviBeeR Offline
                RaviBeeR Offline
                RaviBee
                wrote on last edited by
                #7

                I just delete the default (not hide) OK button and create a new one. Alternatively, you could override PreTranslateMsg() and catch the Enter keystroke there. I prefer the former way. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

                A 1 Reply Last reply
                0
                • RaviBeeR RaviBee

                  I just delete the default (not hide) OK button and create a new one. Alternatively, you could override PreTranslateMsg() and catch the Enter keystroke there. I prefer the former way. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

                  A Offline
                  A Offline
                  adamUK
                  wrote on last edited by
                  #8

                  I was fiddling around with PreTranslateMessage to see if I could get it to work but I agree with you. The first way you mentioned is the way I have always done it and it still seems the simplest! thanks! Adam. My world tour What I do now.. "I spent a lot of my money on booze, birds and fast cars. The rest I just squandered" George Best.

                  1 Reply Last reply
                  0
                  • M MemLeak

                    Hi, Is there a way to prevent dialog from closing when pressing on "enter" keyboard button? Thanks Everything's beautiful if you look at it long enough...

                    J Offline
                    J Offline
                    jia_wei
                    wrote on last edited by
                    #9

                    one method is to rename the ID of button "OK",don't use IDOK. another method is to define a function for press button "OK",in the function, delete the line"CDialog::OnOk().

                    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