Rich edit (CRichEditCtrl) & SetWindowText

I've got a rich edit control that I'm trying to set to a CString.  Actually, I've got it to work, except that the string itself can only hold as many characters as initially available.  Here's the code from my view with the CRichEdit:

CFtpDoc* pDoc = (CFtpDoc*)GetDocument();

I can delete & change text, but say if I had 300 characters and deleted 5, I'd be able to add only 5 characters back in the editor.

Can anyone help?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

if I understand you right, you mean to say that the CString or LPCSTR you are assigning the text to will not grow?? If that is the case, perhaps you need to reallocate the memory yourself...
knewton76Author Commented:
It doesn't grow.  How would I reallocate the memory myself?  (I'm a newbie, can you tell?)

Here's how I do the data gathering:

char buffer[MAXBUFFER]

int nread = pFile->Read(buffer, MAXBUFFER);

So, the text comes in from a file to a char buffer, then I do something like this:

in the Document, SetEditData looks like this:

void SetEditData(char*buffer)
  m_strText = buffer;
if you define the buffer like this:

char* buffer = new char(MAXBUFFER);

then you can make the buffer grow by doing something like:

buffer = (char*)realloc(buffer, MAXBUFFER + SOME_INCREMENT);

where SOME_INCREMENT is defined to whatever value you want; you could even use a variable there, or whatever. This way you are not stuck with the buffer limit you previously imposed.

I noticed that you are only reading in MAXBUFFER bytes at a time from your file and setting the control's text to just what is in the buffer. You might want to add code to append to the content of the control if necessary.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.