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. Text Updation

Text Updation

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlounge
5 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.
  • A Offline
    A Offline
    Abhijeet Pathak
    wrote on last edited by
    #1

    Hi, I have two CEdit controls in a dialog. In Change() event handler of first control, I'm using first control's value and setting another random value of second control and finally calling UpdateData(FALSE); But the text in first control remains same (old - whatever it was set in InitDialog()) and the caret is repositioned at first character. Why isn't text if first control changing and caret is being positioned at first character again and again? Can anyone help me out? Regards, Abhijeet

    M D A 3 Replies Last reply
    0
    • A Abhijeet Pathak

      Hi, I have two CEdit controls in a dialog. In Change() event handler of first control, I'm using first control's value and setting another random value of second control and finally calling UpdateData(FALSE); But the text in first control remains same (old - whatever it was set in InitDialog()) and the caret is repositioned at first character. Why isn't text if first control changing and caret is being positioned at first character again and again? Can anyone help me out? Regards, Abhijeet

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      a_b_pathak wrote:

      Why isn't text if first control changing

      You stated "I'm using first control's value and setting another random value of second control". Why would that change the first control's text? Can you post the code for your "Change() event handler"? Mark

      Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

      1 Reply Last reply
      0
      • A Abhijeet Pathak

        Hi, I have two CEdit controls in a dialog. In Change() event handler of first control, I'm using first control's value and setting another random value of second control and finally calling UpdateData(FALSE); But the text in first control remains same (old - whatever it was set in InitDialog()) and the caret is repositioned at first character. Why isn't text if first control changing and caret is being positioned at first character again and again? Can anyone help me out? Regards, Abhijeet

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

        a_b_pathak wrote:

        ...and finally calling UpdateData(FALSE);

        Why are you using UpdateData() for this? Just use a CEdit member variable for each edit control, and call the SetWindowText() method. For example:

        void CDlg::OnChangeEdit1( LPNMHDR, LRESULT* )
        {
        CString strEdit1;

        m\_edit1.GetWindowText(strEdit1);
        m\_edit2.SetWindowText("Hello " + strEdit1);
        

        }


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        1 Reply Last reply
        0
        • A Abhijeet Pathak

          Hi, I have two CEdit controls in a dialog. In Change() event handler of first control, I'm using first control's value and setting another random value of second control and finally calling UpdateData(FALSE); But the text in first control remains same (old - whatever it was set in InitDialog()) and the caret is repositioned at first character. Why isn't text if first control changing and caret is being positioned at first character again and again? Can anyone help me out? Regards, Abhijeet

          A Offline
          A Offline
          Abhijeet Pathak
          wrote on last edited by
          #4

          I found it.... I forgot to call UpdateData(TRUE); at the start of function so the text of first control wasn't changing! stupid mistake though... I'm not using Set/GetWindowText because i'm using Control Variable (value).

          M 1 Reply Last reply
          0
          • A Abhijeet Pathak

            I found it.... I forgot to call UpdateData(TRUE); at the start of function so the text of first control wasn't changing! stupid mistake though... I'm not using Set/GetWindowText because i'm using Control Variable (value).

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            a_b_pathak wrote:

            I'm not using Set/GetWindowText because i'm using Control Variable

            Then you can use the CWnd::GetWindowText/CWnd::SetWindowText methods, as DavidCrow stated. FYI - You don't always need to use UpdateData()...see Avoiding UpdateData[^] Mark

            Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the number 3

            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