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. How to automatically add lines and scroll in CEdit?

How to automatically add lines and scroll in CEdit?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
6 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.
  • R Offline
    R Offline
    Rostfrei
    wrote on last edited by
    #1

    Hello! I want to implement some kind of history log with CEdit controll. But here is the problem; CEdit only have SetWindowText method. Is there a way to add just one line of text? Now I do multiple lines with text in string buffer separated by "\r\n". To add some line, I add text to this buffer and separate it with "\r\n" and after it I call SetWindowText on CEdit control. Here I have a problem how many srolls to do when I get ower the edit control visible lines limit. Is there any better way? Just to add line of text and if out of visible lines srcoll just one line? Best regards, Rostfrei

    S C O D 4 Replies Last reply
    0
    • R Rostfrei

      Hello! I want to implement some kind of history log with CEdit controll. But here is the problem; CEdit only have SetWindowText method. Is there a way to add just one line of text? Now I do multiple lines with text in string buffer separated by "\r\n". To add some line, I add text to this buffer and separate it with "\r\n" and after it I call SetWindowText on CEdit control. Here I have a problem how many srolls to do when I get ower the edit control visible lines limit. Is there any better way? Just to add line of text and if out of visible lines srcoll just one line? Best regards, Rostfrei

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      I can think of two ways to add a line: - Call GetWindowText, tack on the new line then call SetWindowText. This is somewhat inefficient. - Use EM_SETSEL and EM_REPLACESEL messages which are wrapped by CEdit::SetSel and CEdit::ReplaceSel respectively. Steve

      1 Reply Last reply
      0
      • R Rostfrei

        Hello! I want to implement some kind of history log with CEdit controll. But here is the problem; CEdit only have SetWindowText method. Is there a way to add just one line of text? Now I do multiple lines with text in string buffer separated by "\r\n". To add some line, I add text to this buffer and separate it with "\r\n" and after it I call SetWindowText on CEdit control. Here I have a problem how many srolls to do when I get ower the edit control visible lines limit. Is there any better way? Just to add line of text and if out of visible lines srcoll just one line? Best regards, Rostfrei

        C Offline
        C Offline
        Calc20
        wrote on last edited by
        #3

        I use this code: m_EditRcvdMsg.SetSel(-1, 0); //select no text m_EditRcvdMsg.ReplaceSel(pMsg); m_EditRcvdMsg.SetSel(-1, 0); //select no text m_EditRcvdMsg.ReplaceSel(_T("\r\n")); //scroll into position m_EditRcvdMsg.LineScroll(1);

        R 1 Reply Last reply
        0
        • R Rostfrei

          Hello! I want to implement some kind of history log with CEdit controll. But here is the problem; CEdit only have SetWindowText method. Is there a way to add just one line of text? Now I do multiple lines with text in string buffer separated by "\r\n". To add some line, I add text to this buffer and separate it with "\r\n" and after it I call SetWindowText on CEdit control. Here I have a problem how many srolls to do when I get ower the edit control visible lines limit. Is there any better way? Just to add line of text and if out of visible lines srcoll just one line? Best regards, Rostfrei

          O Offline
          O Offline
          Owner drawn
          wrote on last edited by
          #4

          Set this style on for the edit control ES_MULTILINE. And for scrollbars WS_HSCROLL and WS_VSCROLL.

          Jesus Loves:rose:

          --Owner Drawn:rose: --Defeat is temporary but surrender is permanent --Jesus is Lord:rose:

          1 Reply Last reply
          0
          • C Calc20

            I use this code: m_EditRcvdMsg.SetSel(-1, 0); //select no text m_EditRcvdMsg.ReplaceSel(pMsg); m_EditRcvdMsg.SetSel(-1, 0); //select no text m_EditRcvdMsg.ReplaceSel(_T("\r\n")); //scroll into position m_EditRcvdMsg.LineScroll(1);

            R Offline
            R Offline
            Rostfrei
            wrote on last edited by
            #5

            Thank you! It works like a charm! Thank you everybody for all your responses! Regards, Rostfrei

            1 Reply Last reply
            0
            • R Rostfrei

              Hello! I want to implement some kind of history log with CEdit controll. But here is the problem; CEdit only have SetWindowText method. Is there a way to add just one line of text? Now I do multiple lines with text in string buffer separated by "\r\n". To add some line, I add text to this buffer and separate it with "\r\n" and after it I call SetWindowText on CEdit control. Here I have a problem how many srolls to do when I get ower the edit control visible lines limit. Is there any better way? Just to add line of text and if out of visible lines srcoll just one line? Best regards, Rostfrei

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

              Rostfrei wrote:

              I want to implement some kind of history log with CEdit controll.

              See here.


              "The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli

              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