?
Solved

Append without SetSel() or SetWindowText()

Posted on 2003-03-10
7
Medium Priority
?
1,301 Views
Last Modified: 2013-11-20
Is there a way to append text to the end of a CEdit/View or CRichEditCtrl/View without using SetSel or SetWindowText? Neither are desirable in my situation.

I'm currently using SetSel, but I am not happy with it. I want to be able to easily select and copy text as some more text continues to be appended quite frequently, and without stoping the appending. That means SetSel() is not good because it changes the selection, making it really difficult to successfully select text, and copy it.

On another side, a lot of text will is appended, and the software can remain on for a long time. I do am planning to implement a dump to file feature later on, but in any case I think the GetWindowTest() and SetWindowText() is not practical due to the frequency of the appending, and the size of the data being transfered each time (even if only a few bytes are appended).

http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20090064.html
In this question's accepted anwser, is a mention to other ways of appending text to an edit box. Anyone would care to get me on the right track?

Sorry, about my lame english, I'm not native. I'm also new to EE, so if this question is worth more points, just tell.

Thanks a lot.
0
Comment
Question by:Djof
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 600 total points
ID: 8110404
If you are using CRichEditCtrl or CRichEditView you can take the advantage of StreamIn function avalibale in the rich edit ctrl. The following links contains good examples of inserting text in a rich edit control.

http://www.codeproject.com/richedit/richeg.asp
http://www.codeguru.com/richedit/rtf_string_streamin.shtml

good Luck
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 8110932
hm ... at least for CEdit(View) I think there's no chance to
add text without SetWindowText() or ReplaceSel().

>That means SetSel() is not good because it changes the
>selection, making it really difficult to successfully select
>text, and copy it.
Well, you could simply store the current selection-range, call
SetSel/ReplaceSel and reset the previous selection afterwards

Maybe you could use a list box instead of a edit control but
with list box you can't select,cut&paste text.

Probably it's possible to implement your own control (derived
from CEdit) which is some kind of 'virtual' edit control (so
you store the complete text in a string but the edit control
only shows the visible part via SetWindowText ... you'd have
to handle scrolling and selection of more than the visible
text ... maybe difficult).

ZOPPO
0
 

Author Comment

by:Djof
ID: 8112598
roshmon,

The problem with StreamIn is that it, as MSDN tells, "Replaces text in this CRichEditCtrl object with text from the specified input stream."

I need to append it. :(
Would anyone know if it's possible to change the StreamIn behavior?

----------------------------------
ZOPPO,

I already use a RichEdit, but I included the CEdit in the question because I could have changed if the CEdit had any features that would have been usefull to me in this case.

Thanks for fast reply to both of you.
0
 

Author Comment

by:Djof
ID: 10295796
Mmm. This has been running long without anything new.

Daniel Lohmann's CEditLog found at codeproject (http://www.codeproject.com/editctrl/editlog.asp, I hope the link is good as codeproject seems to be down right now) comes closest to being the best solution possible. I still uses the select and replace method, but it handles case when the user is currently trying to select text in either directition, and makes sure the screen doesn't move by remembering the first visible line. The only problem with using this solution with a RichEditCtrl is that I have been unable to stop the painting, thus the flashing.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question