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. How to capture Enter key in a dialog?

How to capture Enter key in a dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
2 Posts 1 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
    MVH
    wrote on last edited by
    #1

    My problem is a simple one: I have a dialog box. A simple one, just two lines to fill. If I press enter/return, by default dialog closes as if I have pressed ok. I would like to capture the keyboard, and make my dialog move onto next items when enter is pressed. I tried the following, no success: void CEditDlg::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { AfxMessageBox("KEYUP"); CDialog::OnKeyUp(nChar, nRepCnt, nFlags); } void CEditDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { AfxMessageBox("CHAR"); CDialog::OnChar(nChar, nRepCnt, nFlags); } ------------------------------------------ Experience is the name every one gives to their mistakes. - Oscar Wilde Experience is one thing you can't get for nothing. - Oscar Wilde

    M 1 Reply Last reply
    0
    • M MVH

      My problem is a simple one: I have a dialog box. A simple one, just two lines to fill. If I press enter/return, by default dialog closes as if I have pressed ok. I would like to capture the keyboard, and make my dialog move onto next items when enter is pressed. I tried the following, no success: void CEditDlg::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { AfxMessageBox("KEYUP"); CDialog::OnKeyUp(nChar, nRepCnt, nFlags); } void CEditDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { AfxMessageBox("CHAR"); CDialog::OnChar(nChar, nRepCnt, nFlags); } ------------------------------------------ Experience is the name every one gives to their mistakes. - Oscar Wilde Experience is one thing you can't get for nothing. - Oscar Wilde

      M Offline
      M Offline
      MVH
      wrote on last edited by
      #2

      I forgot to check the dialog template in resource editor X| I just changed "Default button" propoerty from OK to "Insert" button. ------------------------------------------ Experience is the name every one gives to their mistakes. -- Oscar Wilde Experience is one thing you can't get for nothing. -- Oscar Wilde

      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