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. Extracting the user input from Edit Box

Extracting the user input from Edit Box

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
9 Posts 7 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.
  • V Offline
    V Offline
    VinayCool
    wrote on last edited by
    #1

    Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.

    N L T D H 6 Replies Last reply
    0
    • V VinayCool

      Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.

      N Offline
      N Offline
      NiceNaidu fo
      wrote on last edited by
      #2

      Use UpdateData(TRUE) before line = m_WORD Appu.. "If you judge people, you have no time to love them."

      1 Reply Last reply
      0
      • V VinayCool

        Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.

        L Offline
        L Offline
        Laxman Auti
        wrote on last edited by
        #3

        vinaycool wrote:

        CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line;

        char * str=new char[MAX]; UpdateData(); lstrcpy(str,m_test.GetBuffer(m_test.GetLength())); The code copies the data from the edit box into the str variable. Knock out 't' from can't, You can if you think you can :cool:

        T 1 Reply Last reply
        0
        • V VinayCool

          Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.

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

          vinaycool wrote:

          I have created a variable m_WORD of CString type ,

          Have you called GetWindowText in that Function or UpdateData(FALSE) !

          "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

          1 Reply Last reply
          0
          • L Laxman Auti

            vinaycool wrote:

            CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line;

            char * str=new char[MAX]; UpdateData(); lstrcpy(str,m_test.GetBuffer(m_test.GetLength())); The code copies the data from the edit box into the str variable. Knock out 't' from can't, You can if you think you can :cool:

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

            A_Laxman wrote:

            vinaycool wrote: CString line;line = m_WORD;char * w =(char *) (LPCTSTR) line;

            nope this code will also work well, have a try!

            "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

            L 1 Reply Last reply
            0
            • T ThatsAlok

              A_Laxman wrote:

              vinaycool wrote: CString line;line = m_WORD;char * w =(char *) (LPCTSTR) line;

              nope this code will also work well, have a try!

              "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

              L Offline
              L Offline
              Laxman Auti
              wrote on last edited by
              #6

              ThatsAlok wrote:

              nope this code will also work well, have a try!

              Yes buddy, I have tried the code and works fine. as well tried another to do same and posted in my previous post.;P Knock out 't' from can't, You can if you think you can :cool:

              1 Reply Last reply
              0
              • V VinayCool

                Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.

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

                Use:

                GetDlgItem(IDC_WORD)->GetWindowText(m_WORD);


                "The largest fire starts but with the smallest spark." - David Crow

                1 Reply Last reply
                0
                • V VinayCool

                  Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.

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

                  use UpDateData then m_youret.GetWindowText( m_WORD);_**


                  **_

                  whitesky


                  1 Reply Last reply
                  0
                  • V VinayCool

                    Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.

                    R Offline
                    R Offline
                    rbid
                    wrote on last edited by
                    #9

                    There is another way to do it :)

                    • Assign a "Control" variable to your edit box (CEdit m_textEdit).
                    • Use the method GetWindowText() for retrieving the results

                    void CDemo::OnBnClickedSearchButton()
                    {
                    ...
                    CString userResponseText;
                    m_textEdit.GetWindowText(userResponseText);

                    // userResponseText now contains user response..
                    ...
                    

                    }

                    Here you don't need to worry about UpdateData that usually has side effects. Just wanted to give you another way to do it. -- **Ricky Marek** (_AKA: rbid_) -- "Things are only impossible until they are not" --- Jean-Luc Picard My articles

                    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