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. Editbox identification problem

Editbox identification problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabase
10 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.
  • G Offline
    G Offline
    gajendrakashyap
    wrote on last edited by
    #1

    Hi All, I've created a dialog based application with the dialog having multiple editboxes. What I want to achieve is to call a specific function when I press "Enter" key. Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed. Please help. Thanks, Gajendra

    T 1 Reply Last reply
    0
    • G gajendrakashyap

      Hi All, I've created a dialog based application with the dialog having multiple editboxes. What I want to achieve is to call a specific function when I press "Enter" key. Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed. Please help. Thanks, Gajendra

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      gajendrakashyap wrote:

      Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed.

      You GetFocus api  to get currently focussed Edit box!

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

      G 2 Replies Last reply
      0
      • T ThatsAlok

        gajendrakashyap wrote:

        Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed.

        You GetFocus api  to get currently focussed Edit box!

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

        G Offline
        G Offline
        gajendrakashyap
        wrote on last edited by
        #3

        Using this I can get a pointer to the ebox. If I could get the ID number of the ebox in context, it would help me more than having a pointer as my application logic depends on that. Can you suggest something on obtaining focussed ebox control id number? Thanks, Gajendra

        1 Reply Last reply
        0
        • T ThatsAlok

          gajendrakashyap wrote:

          Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed.

          You GetFocus api  to get currently focussed Edit box!

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

          G Offline
          G Offline
          gajendrakashyap
          wrote on last edited by
          #4

          Using this I can get a pointer to the ebox. If I could get the ID number of the ebox in context, it would help me more than having a pointer as my application logic depends on that. Can you suggest something on obtaining focussed ebox control id number?

          S T 2 Replies Last reply
          0
          • G gajendrakashyap

            Using this I can get a pointer to the ebox. If I could get the ID number of the ebox in context, it would help me more than having a pointer as my application logic depends on that. Can you suggest something on obtaining focussed ebox control id number?

            S Offline
            S Offline
            stanlymt
            wrote on last edited by
            #5

            You can override default PreTranslateMessage function of the dialog/window class. BOOL CBAMBuildToolDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { if(pMsg->wParam == VK_RETURN) { if (pMsg->hwnd == ::GetDlgItem(*this, IDC_EDITBOXID) //Replace with proper ID { //Handling of the return key for this edit box return TRUE; } } } return CDialog::PreTranslateMessage(pMsg); } I hope the above code snippet will help you. Regards, Stanly

            T 1 Reply Last reply
            0
            • G gajendrakashyap

              Using this I can get a pointer to the ebox. If I could get the ID number of the ebox in context, it would help me more than having a pointer as my application logic depends on that. Can you suggest something on obtaining focussed ebox control id number?

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              gajendrakashyap wrote:

              Can you suggest something on obtaining focussed ebox control id number?

              when you got pointer to Window you can easily call function GetDlgCtrlID to retrieve it control id

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

              G 1 Reply Last reply
              0
              • S stanlymt

                You can override default PreTranslateMessage function of the dialog/window class. BOOL CBAMBuildToolDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { if(pMsg->wParam == VK_RETURN) { if (pMsg->hwnd == ::GetDlgItem(*this, IDC_EDITBOXID) //Replace with proper ID { //Handling of the return key for this edit box return TRUE; } } } return CDialog::PreTranslateMessage(pMsg); } I hope the above code snippet will help you. Regards, Stanly

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                stanlymt wrote:

                IDC_EDITBOXID)

                from where this ID will come.. and are you going to check like this, for every Control present on Dilaog box.. this really going to make you PreTranslateMessage Bulky..

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

                S 1 Reply Last reply
                0
                • T ThatsAlok

                  stanlymt wrote:

                  IDC_EDITBOXID)

                  from where this ID will come.. and are you going to check like this, for every Control present on Dilaog box.. this really going to make you PreTranslateMessage Bulky..

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                  cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

                  S Offline
                  S Offline
                  stanlymt
                  wrote on last edited by
                  #8

                  ID is the Editbox ID in the resource file. If you need to handle differently for each edit box in the dialog, you have to handle it seperately. Otherwise, you can use one button as 'default' button and handle the event there.

                  T 1 Reply Last reply
                  0
                  • T ThatsAlok

                    gajendrakashyap wrote:

                    Can you suggest something on obtaining focussed ebox control id number?

                    when you got pointer to Window you can easily call function GetDlgCtrlID to retrieve it control id

                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                    cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

                    G Offline
                    G Offline
                    gajendrakashyap
                    wrote on last edited by
                    #9

                    Thanks Alok. Actually i tried that, but misspelt the name of function :( I could work from your first clue itself. Thanks for the help !! :) Thanks & regards, Gajendra

                    1 Reply Last reply
                    0
                    • S stanlymt

                      ID is the Editbox ID in the resource file. If you need to handle differently for each edit box in the dialog, you have to handle it seperately. Otherwise, you can use one button as 'default' button and handle the event there.

                      T Offline
                      T Offline
                      ThatsAlok
                      wrote on last edited by
                      #10

                      stanlymt wrote:

                      you can use one button as 'default' button and handle the event there.

                      then I believe his question wrong.. actually that person want currently focused EditBox at the Time of press of enter key

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You

                      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