Solved

Using huge CString and CEdit: limit 64K ?

Posted on 2002-03-31
3
585 Views
Last Modified: 2013-11-20
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));
m_cStartButton.EnableWindow(FALSE);

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

CHttpFile* pFile = (CHttpFile*)pInternetSession->OpenURL("http://www.somewhere.com/returntxt.php",1,INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD,NULL,0);

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

pInternetSession->Close();
delete pInternetSession;

m_cStartButton.EnableWindow(TRUE);
UpdateData(FALSE);

SetCursor(hCursOld);
----------

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
0
Comment
Question by:MiKo93
[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
3 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 6909703
Try this link...

http://codeproject.com/editctrl/crysedit.asp

this may help u...

GOOD LUCK
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 6910918
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:

   AfxInitRichEdit();

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
0
 

Author Comment

by:MiKo93
ID: 6912818
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
haveThree challenge 22 128
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 201
Thin secure Windows 10 5 116
Way to decrease size of apk file 9 133
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

710 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