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. UpdateData Problem

UpdateData Problem

Scheduled Pinned Locked Moved C / C++ / MFC
help
10 Posts 5 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 2 edit box in my dialog, word and selecting a file .. first i have to enter the word then i have to select the file name in the file name i have used the below code, once i select the file, text which i have entered in the word edit box is getting erased, is there any way that after selecting file text in the word edit box does not get erased .. ----------------------------------------------------- void CSearchDlg::OnOpenIndex() { CString fname; CFileDialog m_ldFile(TRUE); if (m_ldFile.DoModal() == IDOK) { fname = m_ldFile.GetPathName(); m_INDEX_FILE=fname; UpdateData(FALSE); } } --------------------------------------------------- Using the above code we can open all types of files, i want to know how we can open only with file with specfic extenshion. Regards, Vinay Charan.

    L P N 3 Replies Last reply
    0
    • V VinayCool

      Hi, I have 2 edit box in my dialog, word and selecting a file .. first i have to enter the word then i have to select the file name in the file name i have used the below code, once i select the file, text which i have entered in the word edit box is getting erased, is there any way that after selecting file text in the word edit box does not get erased .. ----------------------------------------------------- void CSearchDlg::OnOpenIndex() { CString fname; CFileDialog m_ldFile(TRUE); if (m_ldFile.DoModal() == IDOK) { fname = m_ldFile.GetPathName(); m_INDEX_FILE=fname; UpdateData(FALSE); } } --------------------------------------------------- Using the above code we can open all types of files, i want to know how we can open only with file with specfic extenshion. Regards, Vinay Charan.

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      Do not use UpdateData() http://www.codeproject.com/cpp/avoidupdatedata.asp[^]


      You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

      1 Reply Last reply
      0
      • V VinayCool

        Hi, I have 2 edit box in my dialog, word and selecting a file .. first i have to enter the word then i have to select the file name in the file name i have used the below code, once i select the file, text which i have entered in the word edit box is getting erased, is there any way that after selecting file text in the word edit box does not get erased .. ----------------------------------------------------- void CSearchDlg::OnOpenIndex() { CString fname; CFileDialog m_ldFile(TRUE); if (m_ldFile.DoModal() == IDOK) { fname = m_ldFile.GetPathName(); m_INDEX_FILE=fname; UpdateData(FALSE); } } --------------------------------------------------- Using the above code we can open all types of files, i want to know how we can open only with file with specfic extenshion. Regards, Vinay Charan.

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

        Vinay wrote:

        UpdateData(FALSE);

        Instead of FALSE use TRUE like

        UpdateData(TRUE);

        Knock out 't' from can't, You can if you think you can :cool:

        V 1 Reply Last reply
        0
        • V VinayCool

          Hi, I have 2 edit box in my dialog, word and selecting a file .. first i have to enter the word then i have to select the file name in the file name i have used the below code, once i select the file, text which i have entered in the word edit box is getting erased, is there any way that after selecting file text in the word edit box does not get erased .. ----------------------------------------------------- void CSearchDlg::OnOpenIndex() { CString fname; CFileDialog m_ldFile(TRUE); if (m_ldFile.DoModal() == IDOK) { fname = m_ldFile.GetPathName(); m_INDEX_FILE=fname; UpdateData(FALSE); } } --------------------------------------------------- Using the above code we can open all types of files, i want to know how we can open only with file with specfic extenshion. Regards, Vinay Charan.

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

          try this void CSearchDlg::OnOpenIndex() { UpdateData(); CString fname; CFileDialog m_ldFile(TRUE); if (m_ldFile.DoModal() == IDOK) { fname = m_ldFile.GetPathName(); m_INDEX_FILE=fname; UpdateData(FALSE); } nave

          1 Reply Last reply
          0
          • L Laxman Auti

            Vinay wrote:

            UpdateData(FALSE);

            Instead of FALSE use TRUE like

            UpdateData(TRUE);

            Knock out 't' from can't, You can if you think you can :cool:

            V Offline
            V Offline
            VinayCool
            wrote on last edited by
            #5

            Hi LaXman, if i use the UpdateData(TRUE); the nthe value is not getting displayed....

            N 1 Reply Last reply
            0
            • V VinayCool

              Hi LaXman, if i use the UpdateData(TRUE); the nthe value is not getting displayed....

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

              vinaycool wrote:

              if i use the UpdateData(TRUE); the nthe value is not getting displayed....

              Why don't you use SetWindowText and GetWindowText for such simple manipulations. As PJ said UpdateData should be avoided for complex manipulations. Of course you can use it for one touch updations. Except for that it shouldn't be used. The name UpdateData itself is confusion. I personally get confused as to what's happening. :) I am not sure whether it's updating to the variable or to the control.


              Nibu thomas Software Developer Programming Tips[^]

              V L 2 Replies Last reply
              0
              • N Nibu babu thomas

                vinaycool wrote:

                if i use the UpdateData(TRUE); the nthe value is not getting displayed....

                Why don't you use SetWindowText and GetWindowText for such simple manipulations. As PJ said UpdateData should be avoided for complex manipulations. Of course you can use it for one touch updations. Except for that it shouldn't be used. The name UpdateData itself is confusion. I personally get confused as to what's happening. :) I am not sure whether it's updating to the variable or to the control.


                Nibu thomas Software Developer Programming Tips[^]

                V Offline
                V Offline
                VinayCool
                wrote on last edited by
                #7

                Hi Nibu thomas, I used m_ctrlINDEX_FILE.SetWindowText(fname); this is working fine... Thanks a lot .....:)

                N 1 Reply Last reply
                0
                • V VinayCool

                  Hi Nibu thomas, I used m_ctrlINDEX_FILE.SetWindowText(fname); this is working fine... Thanks a lot .....:)

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

                  vinaycool wrote:

                  Hi Nibu thomas, I used m_ctrlINDEX_FILE.SetWindowText(fname); this is working fine... Thanks a lot

                  You're welcome. :)


                  Nibu thomas Software Developer Programming Tips[^]  My site[^]

                  1 Reply Last reply
                  0
                  • N Nibu babu thomas

                    vinaycool wrote:

                    if i use the UpdateData(TRUE); the nthe value is not getting displayed....

                    Why don't you use SetWindowText and GetWindowText for such simple manipulations. As PJ said UpdateData should be avoided for complex manipulations. Of course you can use it for one touch updations. Except for that it shouldn't be used. The name UpdateData itself is confusion. I personally get confused as to what's happening. :) I am not sure whether it's updating to the variable or to the control.


                    Nibu thomas Software Developer Programming Tips[^]

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

                    Nibu wrote:

                    The name UpdateData itself is confusion. I personally get confused as to what's happening. I am not sure whether it's updating to the variable or to the control.

                    Hey Nibu, don't get confused , let me clear the working of UpdateData()

                    UpdateData(TRUE)

                    Initialises all the control variables by retriving the contents from dialog controls

                    UpdateData(FALSE)

                    Initialises all the dialog controls by retriving the contents from Control variables. Hope you will understand how UpdateData works. :) Knock out 't' from can't, You can if you think you can :cool:

                    N 1 Reply Last reply
                    0
                    • L Laxman Auti

                      Nibu wrote:

                      The name UpdateData itself is confusion. I personally get confused as to what's happening. I am not sure whether it's updating to the variable or to the control.

                      Hey Nibu, don't get confused , let me clear the working of UpdateData()

                      UpdateData(TRUE)

                      Initialises all the control variables by retriving the contents from dialog controls

                      UpdateData(FALSE)

                      Initialises all the dialog controls by retriving the contents from Control variables. Hope you will understand how UpdateData works. :) Knock out 't' from can't, You can if you think you can :cool:

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

                      A_Laxman wrote:

                      Hey Nibu, don't get confused , let me clear the working of UpdateData()

                      :-D Hey I know how UpdateData works. But it's headache when you take a look at the code specially during maintenance (for me). So I tend to go for SetWindowText and GetWindowText.:) But it is not bad if it's sensibly used. I use it if I have to do one touch updation. For eg: when Save button is clicked, it works fine there for me. But I have seen people using UpdateData while writing Animation programs.:sigh: Bugs galore in such programs, because when UpdateData is called all variables bound to it are updated we cannot do selective updation.


                      Nibu thomas A Developer Programming tips[^]  My site[^]

                      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