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 identify Enter Key pressed by user ?

How to identify Enter Key pressed by user ?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
6 Posts 6 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.
  • A Offline
    A Offline
    Atul23
    wrote on last edited by
    #1

    Hi All, In my project I want to check Whether user press Enter key or not after type a text in text box. In which event I have to check it and how can i check it. Thanks in Advance Atul

    M C S H D 5 Replies Last reply
    0
    • A Atul23

      Hi All, In my project I want to check Whether user press Enter key or not after type a text in text box. In which event I have to check it and how can i check it. Thanks in Advance Atul

      C Offline
      C Offline
      chandu004
      wrote on last edited by
      #2

      try using the pretranslatemessage handler. but here, you have to implement your own logic. any mmore clarification required, get back.

      1 Reply Last reply
      0
      • A Atul23

        Hi All, In my project I want to check Whether user press Enter key or not after type a text in text box. In which event I have to check it and how can i check it. Thanks in Advance Atul

        M Offline
        M Offline
        Maxwell Chen
        wrote on last edited by
        #3

        What type is the project?


        Maxwell Chen

        1 Reply Last reply
        0
        • A Atul23

          Hi All, In my project I want to check Whether user press Enter key or not after type a text in text box. In which event I have to check it and how can i check it. Thanks in Advance Atul

          S Offline
          S Offline
          sps itsec46
          wrote on last edited by
          #4

          This should help: http://www.codeproject.com/dialog/pretransdialog01.asp[^]

          cheers! mykel OMM: "Let us be thankful we have an occupation to fill. Work hard, increase production, prevent accidents and be happy."

          1 Reply Last reply
          0
          • A Atul23

            Hi All, In my project I want to check Whether user press Enter key or not after type a text in text box. In which event I have to check it and how can i check it. Thanks in Advance Atul

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

            Did you use of PreTranslateMessage .

            1 Reply Last reply
            0
            • A Atul23

              Hi All, In my project I want to check Whether user press Enter key or not after type a text in text box. In which event I have to check it and how can i check it. Thanks in Advance Atul

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

              The use of PreTranslateMessage() *might* work, but most implementations are incorrect. The other downside is that it permanently ties the child control to the parent. A better solution is to derive a class from CEdit. Override the OnGetDlgCode() method and return DLGC_WANTALLKEYS. Then override the OnChar() method like:

              void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags )
              {
              switch (nChar)
              {
              case VK_RETURN:
              GetParent()->SendMessage(some_custom_msg, GetDlgCtrlID(), (LPARAM) this);
              return;
              }

              CEdit::OnChar( nChar, nRepCnt, nFlags );
              

              }

              When the edit control "sees" the Enter key, it posts a message to the parent indicating such. The parent can then respond accordingly, if at all.


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              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