Archived

This topic is now archived and is closed to further replies.

Anthracks

Scrolling text in MFC

Recommended Posts

Anthracks    122
I am currently trying to code a text adventure using MFC (just to learn some basics of MFC pretty much), and I have one Edit Control (CEdit) that the user types commands into, and another box (CRichEditCtrl) that the results of this command are printed in. Now, when new messages are printed to this box, I want them to be appended to the end of what is already there, so if it said "You are in room 12." and then the user typed "look", it would then say "You are in room 12" twice. The way I currently implement this is to copy the entire contents of the RichEdit box (via GetWindowText), append the user input and any other necessary text to it, and then write it all in again with SetWindowText. I imagine that when there is a lot of text to be written, however, this will be VERY slow, or even impossible on low-memory systems. Is there an easy way to append text to an Edit box? I''ve been scouring MSDN for a long time and not come up with squat. Any help would be appreciated! Anthracks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
here''s a real simple way to do it

CString text;
m_edit2.GetWindowText(text);
m_edit1.SetSel(m_edit1.GetWindowTextLength(), m_edit1.GetWindowTextLength());
m_edit1.ReplaceSel(text);

Share this post


Link to post
Share on other sites