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. Disabling the OnOK in CDialog

Disabling the OnOK in CDialog

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 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.
  • P Offline
    P Offline
    pie
    wrote on last edited by
    #1

    Hello. Is it somehow possible to disable the linking between VK_RETURN and CDialog::OnOK? Whenever I press ENTER in my dialog, it calls the OnOK, and I would like to avoid this.. Is it possible?

    D V 2 Replies Last reply
    0
    • P pie

      Hello. Is it somehow possible to disable the linking between VK_RETURN and CDialog::OnOK? Whenever I press ENTER in my dialog, it calls the OnOK, and I would like to avoid this.. Is it possible?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2
      1. Give the OK button another ID besides IDOK. 2) In the OnOK() handler, don't call the base class CDialog::OnOK(). http://www.codeproject.com/cpp/cppforumfaq.asp#mfc\_dlgclosekeys

      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

      P 1 Reply Last reply
      0
      • P pie

        Hello. Is it somehow possible to disable the linking between VK_RETURN and CDialog::OnOK? Whenever I press ENTER in my dialog, it calls the OnOK, and I would like to avoid this.. Is it possible?

        V Offline
        V Offline
        vladfein
        wrote on last edited by
        #3

        VK_RETURN actually invokes a default button in your dialog, which happens to be your OK button. You could unchek "default button" property for it in the resource editor, or at a run time.

        1 Reply Last reply
        0
        • D David Crow
          1. Give the OK button another ID besides IDOK. 2) In the OnOK() handler, don't call the base class CDialog::OnOK(). http://www.codeproject.com/cpp/cppforumfaq.asp#mfc\_dlgclosekeys

          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          P Offline
          P Offline
          pie
          wrote on last edited by
          #4

          I tried to override OnOK, and yes, the dialog doesn't close, but if I then add an OnKeyDown-handler to my dialog, it never receives any VK_RETURN-notifications.. Is this beacuse MFC "grabs" the VK_RETURN, and sends it to OnOK, or just beacuse I'm doing something wrong?

          D 1 Reply Last reply
          0
          • P pie

            I tried to override OnOK, and yes, the dialog doesn't close, but if I then add an OnKeyDown-handler to my dialog, it never receives any VK_RETURN-notifications.. Is this beacuse MFC "grabs" the VK_RETURN, and sends it to OnOK, or just beacuse I'm doing something wrong?

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

            Depending on which control has focus, the dialog may not even "see" the key presses. Tell us more of what you are trying to do.


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            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