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. doubt in textbox controls used in MFC

doubt in textbox controls used in MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
17 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.
  • H Hamid Taebi

    You have a editbox CEdit m_EDit; and it has values "12345" now you want to show these values use of m_Edit1.GetWindowText();


    WhiteSky


    H Offline
    H Offline
    harshadha
    wrote on last edited by
    #3

    hai, i cant understand .. Iam passing values to the editbox in run time ,then if i click a command button iam displaying a messagebox,where i want these value to be shown... Harshadha

    N H 2 Replies Last reply
    0
    • H harshadha

      hai, i cant understand .. Iam passing values to the editbox in run time ,then if i click a command button iam displaying a messagebox,where i want these value to be shown... Harshadha

      N Offline
      N Offline
      Newbie00
      wrote on last edited by
      #4

      Use the text got by m_Edit1.GetWindowText(); with the MessageBox method...

      1 Reply Last reply
      0
      • H harshadha

        Hai, Good Evening.... I was working with the controls of textbox i have a doubt in that can anyone clear it.... I created a form in MFC by having various controls. 1.In that i have a textbox in which iam entering some values. 2.I want that value to be printed in the message box... Can anyone please tell me how to do.... Thanks Harshadha

        P Offline
        P Offline
        Paresh Chitte
        wrote on last edited by
        #5

        Use WM_KILLFOCUS for your text box and get the text using GetWindowText. I hope this is you want.

        H 1 Reply Last reply
        0
        • H harshadha

          hai, i cant understand .. Iam passing values to the editbox in run time ,then if i click a command button iam displaying a messagebox,where i want these value to be shown... Harshadha

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

          When click button use of

          CEdit m_Edit;
          CString str;
          m_Edit.GetWindowText(str);
          MessageBox(str);

          And if you want to set a value dynamicly for editbox use of SetWindowText


          WhiteSky


          1 Reply Last reply
          0
          • P Paresh Chitte

            Use WM_KILLFOCUS for your text box and get the text using GetWindowText. I hope this is you want.

            H Offline
            H Offline
            harshadha
            wrote on last edited by
            #7

            Hai,, I cant really understand i brief my question.. Iam entering the values in edit box during runtime and displaying it... CEdit m_ce; m_ce.GetWindowText(); TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce); MessageBox(szMsg,NULL,MB_OK); error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters Thanks For Spending Your Precious Time Harshadha

            P H D 3 Replies Last reply
            0
            • H harshadha

              Hai,, I cant really understand i brief my question.. Iam entering the values in edit box during runtime and displaying it... CEdit m_ce; m_ce.GetWindowText(); TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce); MessageBox(szMsg,NULL,MB_OK); error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters Thanks For Spending Your Precious Time Harshadha

              P Offline
              P Offline
              Paresh Chitte
              wrote on last edited by
              #8

              int GetWindowText( LPTSTR lpszStringBuf, int nMaxCount ) const; void GetWindowText( CString& rString ) const; Use as below CEdit m_ce; CString str; m_ce.GetWindowText(str); TCHAR szMsg[256]; long lValue = _ttol((LPCTSTR)str); wsprintf(szMsg,_T("hEIGHT: %ld "),lValue); MessageBox(szMsg,NULL,MB_OK); -- modified at 6:26 Thursday 8th March, 2007

              H 1 Reply Last reply
              0
              • H harshadha

                Hai,, I cant really understand i brief my question.. Iam entering the values in edit box during runtime and displaying it... CEdit m_ce; m_ce.GetWindowText(); TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce); MessageBox(szMsg,NULL,MB_OK); error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters Thanks For Spending Your Precious Time Harshadha

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

                I wrote for you an exmaple and also GetWindowText needs to a parameter for hold values


                WhiteSky


                1 Reply Last reply
                0
                • P Paresh Chitte

                  int GetWindowText( LPTSTR lpszStringBuf, int nMaxCount ) const; void GetWindowText( CString& rString ) const; Use as below CEdit m_ce; CString str; m_ce.GetWindowText(str); TCHAR szMsg[256]; long lValue = _ttol((LPCTSTR)str); wsprintf(szMsg,_T("hEIGHT: %ld "),lValue); MessageBox(szMsg,NULL,MB_OK); -- modified at 6:26 Thursday 8th March, 2007

                  H Offline
                  H Offline
                  harshadha
                  wrote on last edited by
                  #10

                  Hai, Iam sorry for troubling you again but iam getting memory error like asking whether to retry or abort... If i click ignore its displaying msgbox with 0 in it.. Thanks Harshadha

                  P P 2 Replies Last reply
                  0
                  • H harshadha

                    Hai, Iam sorry for troubling you again but iam getting memory error like asking whether to retry or abort... If i click ignore its displaying msgbox with 0 in it.. Thanks Harshadha

                    P Offline
                    P Offline
                    Paresh Chitte
                    wrote on last edited by
                    #11

                    have you done validation on the text box like the input is only numeric value and not alphabet nor alphanumeric...

                    H 1 Reply Last reply
                    0
                    • P Paresh Chitte

                      have you done validation on the text box like the input is only numeric value and not alphabet nor alphanumeric...

                      H Offline
                      H Offline
                      harshadha
                      wrote on last edited by
                      #12

                      NO

                      1 Reply Last reply
                      0
                      • H harshadha

                        Hai, Iam sorry for troubling you again but iam getting memory error like asking whether to retry or abort... If i click ignore its displaying msgbox with 0 in it.. Thanks Harshadha

                        P Offline
                        P Offline
                        PS Codeproj
                        wrote on last edited by
                        #13

                        Hi, I think u havent created a member variable for the editbox. Simply you would have written like CEdit m_ce; It ll not work out. First you need to create a member variable for the edit box using class wizard with the control type as Edit. say, the member variable is m_editChar. then, CString str; m_editChar.GetWindowText(str); MessageBox(str); now, the str ll give u the value entered by the user in the edit box. Hope this ll solve your problem.

                        Thanks & Rgds, Sri..

                        H 1 Reply Last reply
                        0
                        • H harshadha

                          Hai, Good Evening.... I was working with the controls of textbox i have a doubt in that can anyone clear it.... I created a form in MFC by having various controls. 1.In that i have a textbox in which iam entering some values. 2.I want that value to be printed in the message box... Can anyone please tell me how to do.... Thanks Harshadha

                          H Offline
                          H Offline
                          harshadha
                          wrote on last edited by
                          #14

                          Hai, Thanks a lot to all... i got the output.... Harshadha

                          H 1 Reply Last reply
                          0
                          • P PS Codeproj

                            Hi, I think u havent created a member variable for the editbox. Simply you would have written like CEdit m_ce; It ll not work out. First you need to create a member variable for the edit box using class wizard with the control type as Edit. say, the member variable is m_editChar. then, CString str; m_editChar.GetWindowText(str); MessageBox(str); now, the str ll give u the value entered by the user in the edit box. Hope this ll solve your problem.

                            Thanks & Rgds, Sri..

                            H Offline
                            H Offline
                            harshadha
                            wrote on last edited by
                            #15

                            Thanks i got it..

                            1 Reply Last reply
                            0
                            • H harshadha

                              Hai,, I cant really understand i brief my question.. Iam entering the values in edit box during runtime and displaying it... CEdit m_ce; m_ce.GetWindowText(); TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce); MessageBox(szMsg,NULL,MB_OK); error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters Thanks For Spending Your Precious Time Harshadha

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

                              harshadha wrote:

                              TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce);

                              So then why are not using CString with your MFC application?

                              harshadha wrote:

                              MessageBox(szMsg,NULL,MB_OK);

                              Consider using AfxMessageBox().


                              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                              "Judge not by the eye but by the heart." - Native American Proverb

                              1 Reply Last reply
                              0
                              • H harshadha

                                Hai, Thanks a lot to all... i got the output.... Harshadha

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

                                I hope you got your answer with best way ;)


                                WhiteSky


                                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