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. send continuos data to an edit control for display

send continuos data to an edit control for display

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestionannouncement
9 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.
  • L Offline
    L Offline
    LCI
    wrote on last edited by
    #1

    I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?

    C D L C 4 Replies Last reply
    0
    • L LCI

      I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Isn't a list control (a list box or a list view ) more appropriate, is it? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      [my articles]

      1 Reply Last reply
      0
      • L LCI

        I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?

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

        LCI wrote:

        I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText"

        How are you doing this?

        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

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

        L 1 Reply Last reply
        0
        • L LCI

          I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          LCI wrote:

          it only displays the first item

          Do you have the textbox set to multiline? Or use a listbox as was mentioned.

          Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns

          L 1 Reply Last reply
          0
          • L LCI

            I have an edit control that takes up the majority of space on my app. I am receiving continuos data from a port and would like to display each message separated by "\r\n". I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText" I also use UpdateData(FALSE) to update the screen How does one use these vars to display the continuos data in an edit control?

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            From MSDN (here[^]): So, set the current selection (SetCell) to the last character and then replace the current selection by the new text (ReplaceSel). This way, you don't erase what was there previously.

            Cédric Moonen Software developer
            Charting control [v1.2]

            modified on Tuesday, January 22, 2008 10:50:29 AM

            1 Reply Last reply
            0
            • L Lost User

              LCI wrote:

              it only displays the first item

              Do you have the textbox set to multiline? Or use a listbox as was mentioned.

              Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns

              L Offline
              L Offline
              LCI
              wrote on last edited by
              #6

              It is set to multi line

              1 Reply Last reply
              0
              • D David Crow

                LCI wrote:

                I tried using the control variable and the value variable for my edit control to display these items. No matter what i try , it only displays the first item and not the rest. I have used the method "SetWindowText"

                How are you doing this?

                "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

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

                L Offline
                L Offline
                LCI
                wrote on last edited by
                #7

                I simply have a control variable for my edit control call it m_Control. I have a string variable for that same edit control. call it m_strValue. I do something like //using the string var for (int lop=1; ;lop<100;lop++) { m_strValue = data[lop]; UpdateData(FALSE); } ///////OR for (int lop=1; ;lop<100;lop++) { m_Control.SetWindowText((LPCSTR)data[lop]); UpdateData(FALSE); }

                D K 2 Replies Last reply
                0
                • L LCI

                  I simply have a control variable for my edit control call it m_Control. I have a string variable for that same edit control. call it m_strValue. I do something like //using the string var for (int lop=1; ;lop<100;lop++) { m_strValue = data[lop]; UpdateData(FALSE); } ///////OR for (int lop=1; ;lop<100;lop++) { m_Control.SetWindowText((LPCSTR)data[lop]); UpdateData(FALSE); }

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

                  Neither of these will preserve what is currently in the edit control.

                  LCI wrote:

                  m_Control.SetWindowText((LPCSTR)data[lop]); UpdateData(FALSE);

                  When using a CEdit control, or any other time for that matter, UpdateData() is not necessary. You can do something like:

                  for (int lop = 1; lop < 100; lop++)
                  {
                  CString str;
                  m_Control.GetWindowText(str);
                  str += data[lop];
                  m_Control.SetWindowText(str);
                  }

                  Or you could just continually add to the end of the edit control as has already been suggested.

                  "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

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

                  1 Reply Last reply
                  0
                  • L LCI

                    I simply have a control variable for my edit control call it m_Control. I have a string variable for that same edit control. call it m_strValue. I do something like //using the string var for (int lop=1; ;lop<100;lop++) { m_strValue = data[lop]; UpdateData(FALSE); } ///////OR for (int lop=1; ;lop<100;lop++) { m_Control.SetWindowText((LPCSTR)data[lop]); UpdateData(FALSE); }

                    K Offline
                    K Offline
                    krmed
                    wrote on last edited by
                    #9

                    Since you are trying to update a window while you are in a tight loop, you need to realize that the window will not process any messages until the loop completes. The UpdateData puts a message in the queue to be processed, but it isn't processed immediately. To overcome this, try

                    for (int lop=1; ;lop<100;lop++)
                    {
                    m_Control.SetWindowText((LPCSTR)data[lop]);
                    UpdateData(FALSE);
                    m_Control.UpdateWindow();
                    }

                    The call to UpdateWindow bypasses the normal message queue and causes the window to repaint immediately. Hope that helps.

                    Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

                    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