Using huge CString and CEdit: limit 64K ?

Hi there !

I have a small dlg-based app that connects to an internet server, gets some txt-output from there and displays it in a CEdit control. By clicking a button, i use this code fragment to receive and display the data (i got this code from some experts-exchange post):

HCURSOR hCursOld = SetCursor(LoadCursor(NULL, IDC_WAIT));

CInternetSession* pInternetSession;
pInternetSession = new CInternetSession();
m_sDataEdit.Empty();  // this is a CString, attached to a CEdit control of my dlg


if ( pFile )
 char buf[256];
 while( int iRead = pFile->Read( buf, 255 ) )
   buf[iRead] = '\0';
   m_sDataEdit += CString(buf);
 delete pFile;

delete pInternetSession;



This totally works with W2K, and I receive some huge data (ab 70k) and show it. But, with W98, the program crashes or just shows nothing.
As far as I checked, the data is received, but as I extend 64k of data (chars), the CString ("m_sDataEdit") has some "overrun" or whatever and gets lost.

Can u help me ?
Why is there a difference between W2K and W98 on this issue ? I understand that CEdit control has some memory limit (4k ? 32k?), anyway. Do i need a totally different approach for showing "huge" text within a dialog app ?

THX a lot
Who is Participating?
DanRollinsConnect With a Mentor Commented:
The EDIT control managed by the CEdit class is not able to handle or display text greater than 64K.

There are two basic choices:
1) truncate the text.
2) Use CRichEdit class rather than CEdit.

If you use #2, then be sure to execute this fn sometime before you open the dialog box:


In a dilaog-based app, this is commonly placed into the CMyApp.InitInstance() fn, just before that call to dlg.DoModal().

Do you need help in changing your existing CEdit control into a CRichEdit control?

-- Dan
Roshan DavisCommented:
Try this link...

this may help u...

MiKo93Author Commented:
Thank you both for your comments.

Dan, I used #2 and rebuilt with a CRichEdit, and it worked ! Therefore, I'll accept your comment as answer.

Yours, MiKo
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.