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. why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2?

why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++debuggingtutorial
11 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.
  • P Offline
    P Offline
    phijophlip
    wrote on last edited by
    #1

    In MFC wizard I have created a dialog form with two EditBoxs(IDC_EDIT1 and IDC_EDIT2). m_var1 and m_var2 are type unsigned integer. The type of the two edit boxes are of unsigned integer data type:). The names of the member variables are m_var1 and m_var2. Their is a Button on the Dialog form Kindly observe the code given void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UINT abc = m_var1; m_var2 = abc; UpdateData(FALSE); } the problem is that when click the button1, the value entered in IDC_EDIT1 is not assigned to the temporary variable abc. When I debug the code, the value assigned to abc is zero. For example if enter a unsigned value 23 , the value is not assinged to the variable abc. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_var2 = m_var1; UpdateData(TRUE); } In the above code, the value enter in IDC_EDIT1 is not transferred to IDC_EDIT2 even though m_var1 and m_var2 are both unsigned integer data type. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { m_var2 = m_var1; } In the above given code, the direct assinged of m_var1 to m_var2 is not possible. When I debug the program , only zero is assinged to m_var2. My question is why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2? Can any one please help me in this matter. :) -- modified at 6:01 Tuesday 14th March, 2006

    N N P H D 5 Replies Last reply
    0
    • P phijophlip

      In MFC wizard I have created a dialog form with two EditBoxs(IDC_EDIT1 and IDC_EDIT2). m_var1 and m_var2 are type unsigned integer. The type of the two edit boxes are of unsigned integer data type:). The names of the member variables are m_var1 and m_var2. Their is a Button on the Dialog form Kindly observe the code given void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UINT abc = m_var1; m_var2 = abc; UpdateData(FALSE); } the problem is that when click the button1, the value entered in IDC_EDIT1 is not assigned to the temporary variable abc. When I debug the code, the value assigned to abc is zero. For example if enter a unsigned value 23 , the value is not assinged to the variable abc. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_var2 = m_var1; UpdateData(TRUE); } In the above code, the value enter in IDC_EDIT1 is not transferred to IDC_EDIT2 even though m_var1 and m_var2 are both unsigned integer data type. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { m_var2 = m_var1; } In the above given code, the direct assinged of m_var1 to m_var2 is not possible. When I debug the program , only zero is assinged to m_var2. My question is why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2? Can any one please help me in this matter. :) -- modified at 6:01 Tuesday 14th March, 2006

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      Actual way is void CMFC_7Dlg::OnButton1() { UpdateData(TRUE); m_var2 = m_var1; UpdateData(FALSE); } nave

      1 Reply Last reply
      0
      • P phijophlip

        In MFC wizard I have created a dialog form with two EditBoxs(IDC_EDIT1 and IDC_EDIT2). m_var1 and m_var2 are type unsigned integer. The type of the two edit boxes are of unsigned integer data type:). The names of the member variables are m_var1 and m_var2. Their is a Button on the Dialog form Kindly observe the code given void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UINT abc = m_var1; m_var2 = abc; UpdateData(FALSE); } the problem is that when click the button1, the value entered in IDC_EDIT1 is not assigned to the temporary variable abc. When I debug the code, the value assigned to abc is zero. For example if enter a unsigned value 23 , the value is not assinged to the variable abc. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_var2 = m_var1; UpdateData(TRUE); } In the above code, the value enter in IDC_EDIT1 is not transferred to IDC_EDIT2 even though m_var1 and m_var2 are both unsigned integer data type. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { m_var2 = m_var1; } In the above given code, the direct assinged of m_var1 to m_var2 is not possible. When I debug the program , only zero is assinged to m_var2. My question is why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2? Can any one please help me in this matter. :) -- modified at 6:01 Tuesday 14th March, 2006

        N Offline
        N Offline
        Nibu babu thomas
        wrote on last edited by
        #3

        phijophlip wrote:

        void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UINT abc = m_var1; m_var2 = abc; UpdateData(FALSE); }

        UpdateData(TRUE);
        UINT abc = m_var1;
        m_var2 = abc;

        phijophlip wrote:

        void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_var2 = m_var1; UpdateData(TRUE); }

        UpdateData(TRUE);
        m_var2 = m_var1;
        UpdateData(FALSE);


        Nibu thomas Software Developer

        1 Reply Last reply
        0
        • P phijophlip

          In MFC wizard I have created a dialog form with two EditBoxs(IDC_EDIT1 and IDC_EDIT2). m_var1 and m_var2 are type unsigned integer. The type of the two edit boxes are of unsigned integer data type:). The names of the member variables are m_var1 and m_var2. Their is a Button on the Dialog form Kindly observe the code given void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UINT abc = m_var1; m_var2 = abc; UpdateData(FALSE); } the problem is that when click the button1, the value entered in IDC_EDIT1 is not assigned to the temporary variable abc. When I debug the code, the value assigned to abc is zero. For example if enter a unsigned value 23 , the value is not assinged to the variable abc. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_var2 = m_var1; UpdateData(TRUE); } In the above code, the value enter in IDC_EDIT1 is not transferred to IDC_EDIT2 even though m_var1 and m_var2 are both unsigned integer data type. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { m_var2 = m_var1; } In the above given code, the direct assinged of m_var1 to m_var2 is not possible. When I debug the program , only zero is assinged to m_var2. My question is why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2? Can any one please help me in this matter. :) -- modified at 6:01 Tuesday 14th March, 2006

          P Offline
          P Offline
          Phil Benson
          wrote on last edited by
          #4

          If I understand you correctly, you would like the value contained in the EDIT_1 to be shown in the EDIT_2 control, on pressing BUTTON_1 ? try the following... void CMFC_7Dlg::OnButton1(){ // Force DDX- DDV to do it´s stuff // Save and Validate (TRUE) parameter // ********************************** UpdateData(TRUE); // Set the values as required // ************************** m_var2 = m_var1; // Force DDX - DDV to do it´s stuff // Read values from member variables, // and display them (FALSE) parameter // ********************************** UpdateData(FALSE); } alternativly you could do the following void CMFC_7Dlg::OnButton1(){ // Force DDX- DDV to do it´s stuff // Save and Validate (TRUE) parameter // ********************************** UpdateData(TRUE); // Set the values as required // ************************** m_var2 = m_var1; // Update the UI to show the change // ******************************** SetDlgItemInt(IDC_EDIT_2, m_var2, FALSE); } regards Phil bum... and I thought I´d got rid of all the bugs :(

          Who the F*** is general failure and why is he reading my hard drive?

          1 Reply Last reply
          0
          • P phijophlip

            In MFC wizard I have created a dialog form with two EditBoxs(IDC_EDIT1 and IDC_EDIT2). m_var1 and m_var2 are type unsigned integer. The type of the two edit boxes are of unsigned integer data type:). The names of the member variables are m_var1 and m_var2. Their is a Button on the Dialog form Kindly observe the code given void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UINT abc = m_var1; m_var2 = abc; UpdateData(FALSE); } the problem is that when click the button1, the value entered in IDC_EDIT1 is not assigned to the temporary variable abc. When I debug the code, the value assigned to abc is zero. For example if enter a unsigned value 23 , the value is not assinged to the variable abc. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_var2 = m_var1; UpdateData(TRUE); } In the above code, the value enter in IDC_EDIT1 is not transferred to IDC_EDIT2 even though m_var1 and m_var2 are both unsigned integer data type. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { m_var2 = m_var1; } In the above given code, the direct assinged of m_var1 to m_var2 is not possible. When I debug the program , only zero is assinged to m_var2. My question is why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2? Can any one please help me in this matter. :) -- modified at 6:01 Tuesday 14th March, 2006

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

            If I understand you correctly you need to eneter Edit1 value to Edit2 value void CAnswerView::OnBnClickedButton2() { CString str; m_Edit.GetWindowText(str); m_Edit2.SetWindowText(str); //int Index=atoi(str); } I tesed this code and work Now this code is good or bad?

            J 1 Reply Last reply
            0
            • H Hamid Taebi

              If I understand you correctly you need to eneter Edit1 value to Edit2 value void CAnswerView::OnBnClickedButton2() { CString str; m_Edit.GetWindowText(str); m_Edit2.SetWindowText(str); //int Index=atoi(str); } I tesed this code and work Now this code is good or bad?

              J Offline
              J Offline
              jhwurmbach
              wrote on last edited by
              #6

              WhiteSky wrote:

              I tesed this code and work Now this code is good or bad?

              It is the only way that will not end in blood, sweat and tears, IMHO. NEVER EVER call UpdateData() yourself, but use control-variables and Get/SetWindowText. The value-variables are for shielding the inner workings of a dialog from the outside. INSIDE a dialog they only spread confusion. So far my personal, very dogmatic views.


              "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D. -- modified at 9:42 Tuesday 14th March, 2006 UpdateWindow -> UpdateData

              D 1 Reply Last reply
              0
              • P phijophlip

                In MFC wizard I have created a dialog form with two EditBoxs(IDC_EDIT1 and IDC_EDIT2). m_var1 and m_var2 are type unsigned integer. The type of the two edit boxes are of unsigned integer data type:). The names of the member variables are m_var1 and m_var2. Their is a Button on the Dialog form Kindly observe the code given void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UINT abc = m_var1; m_var2 = abc; UpdateData(FALSE); } the problem is that when click the button1, the value entered in IDC_EDIT1 is not assigned to the temporary variable abc. When I debug the code, the value assigned to abc is zero. For example if enter a unsigned value 23 , the value is not assinged to the variable abc. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(TRUE); m_var2 = m_var1; UpdateData(TRUE); } In the above code, the value enter in IDC_EDIT1 is not transferred to IDC_EDIT2 even though m_var1 and m_var2 are both unsigned integer data type. Kindly observe the code which is given below void CMFC_7Dlg::OnButton1() { m_var2 = m_var1; } In the above given code, the direct assinged of m_var1 to m_var2 is not possible. When I debug the program , only zero is assinged to m_var2. My question is why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2? Can any one please help me in this matter. :) -- modified at 6:01 Tuesday 14th March, 2006

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

                Yet another example of why UpdateData() should be avoided. It's just too easy to mess up. You'd be better off using GetWindowText() instead.


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

                P 1 Reply Last reply
                0
                • J jhwurmbach

                  WhiteSky wrote:

                  I tesed this code and work Now this code is good or bad?

                  It is the only way that will not end in blood, sweat and tears, IMHO. NEVER EVER call UpdateData() yourself, but use control-variables and Get/SetWindowText. The value-variables are for shielding the inner workings of a dialog from the outside. INSIDE a dialog they only spread confusion. So far my personal, very dogmatic views.


                  "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D. -- modified at 9:42 Tuesday 14th March, 2006 UpdateWindow -> UpdateData

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

                  jhwurmbach wrote:

                  NEVER EVER call UpdateWindow()...

                  Perhaps you meant UpdateData().


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "There is no death, only a change of worlds." - Native American Proverb

                  1 Reply Last reply
                  0
                  • D David Crow

                    Yet another example of why UpdateData() should be avoided. It's just too easy to mess up. You'd be better off using GetWindowText() instead.


                    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                    "There is no death, only a change of worlds." - Native American Proverb

                    P Offline
                    P Offline
                    Phil Benson
                    wrote on last edited by
                    #9

                    I do not think that UpdateData(x) should be avoided. If used correctly, it is a lot eaiser then GetWindowText/SetWindowText. From the code snippet provided, It is not really clear what the purpose of two variables si, for one value to be retrieved... just my tuppence.. Phil bum... and I thought I´d got rid of all the bugs :(

                    Who the F*** is general failure and why is he reading my hard drive?

                    D 1 Reply Last reply
                    0
                    • P Phil Benson

                      I do not think that UpdateData(x) should be avoided. If used correctly, it is a lot eaiser then GetWindowText/SetWindowText. From the code snippet provided, It is not really clear what the purpose of two variables si, for one value to be retrieved... just my tuppence.. Phil bum... and I thought I´d got rid of all the bugs :(

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

                      Phil.Benson wrote:

                      If used correctly...

                      That's a mighty big if there. The problem is that most beginners do not use it correctly and end up butchering their code just to get around its caveats. I find it best to avoid altogether. GetWindowText() and SetWindowText are a lot cleaner and you can tell exactly what is going to happen. Using UpdateData() is an all-or-nothing operation. Consider the situation where you set some member variables, call a dialog's DoModal() method, call UpdateData(), then click the Cancel button. Now the member variables are potentially not in the same state they were prior to calling DoModal(). You should be able to assume that member variables retain their same value before and after if the Cancel button has been clicked. Use of UpdateData() makes this a bad assumption.


                      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                      "There is no death, only a change of worlds." - Native American Proverb

                      P 1 Reply Last reply
                      0
                      • D David Crow

                        Phil.Benson wrote:

                        If used correctly...

                        That's a mighty big if there. The problem is that most beginners do not use it correctly and end up butchering their code just to get around its caveats. I find it best to avoid altogether. GetWindowText() and SetWindowText are a lot cleaner and you can tell exactly what is going to happen. Using UpdateData() is an all-or-nothing operation. Consider the situation where you set some member variables, call a dialog's DoModal() method, call UpdateData(), then click the Cancel button. Now the member variables are potentially not in the same state they were prior to calling DoModal(). You should be able to assume that member variables retain their same value before and after if the Cancel button has been clicked. Use of UpdateData() makes this a bad assumption.


                        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                        "There is no death, only a change of worlds." - Native American Proverb

                        P Offline
                        P Offline
                        Phil Benson
                        wrote on last edited by
                        #11

                        David wrote "That's a mighty big if there. The problem is that most beginners do not use it correctly..." Nobody said programming is easy. If it was, we would not get paid as much :-D As for choosing Cancel, do you manipulate application data directly within the dialog? Or do you wait for the result (IDOK or IDCANCEL) before making any changes resulting from the data being changed within the dialog? again, just my tuppence Phil bum... and I thought I´d got rid of all the bugs :( -- modified at 9:43 Tuesday 14th March, 2006 Here on code project, If I can remember correctly it was PJ Ahrens, has written an interesting article about DDX-DDV in the MFC

                        Who the F*** is general failure and why is he reading my hard drive?

                        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