Link to home
Start Free TrialLog in
Avatar of dutong
dutong

asked on

How to use the CRichEditCtrl

I used the wizard to generate the app frame, and the view is CRichEditView with the CRichEditDoc, but when running, open some file, but nothing display, is there anything I should do to load the file to display in the CRichEditCtrl? I check the Wordpad sample, but does not find answer.

Thanks in advance!
Avatar of mikeblas
mikeblas

What's the format of the file you're trying to open?

.B ekiM
Avatar of dutong

ASKER

RTF and normal text file
ASKER CERTIFIED SOLUTION
Avatar of svel
svel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dutong

ASKER

If I open a file, you mean I should convert it to a string and send it to SetWindowText function? Can you tell me an alternate way?
    If I open a file, you mean I should convert it to a string and send it to SetWindowText
     function?
Yep. I was reading the records from the Database, storing it in a single string and displaying it in a RichEditctrl using SetWindowText() fn.

Can you tell me an alternate way?
You have to store the files into some char string, in that case, that could be the simplest soln. Anyway, I will think about it.
Avatar of dutong

ASKER

Thank you very much, Svel
You know I'm not familar with CRichEditCtrl, but I suspect using string to deal with the large file, because when I select CRichEditCtrl, I not only want to format text, but also deal with file large than 64k
I'm not sure with the string solution, because I have not detail knowledge of memory management of string, I guess it will not efficeint for large data.
Tell me your suggestion
Hi,
Iam reading more than 20,000 lines of code and storing it in a cstring but I don't face any problem. You can allocate the memory using
LPSTR  = CString :: GetBufferSetLength(nNumberOfBytesToAllocate) ;
You can check the allocated memory using
int = CString :: GetAllocLength() const ;
If you are not very sure, probably you can derive a class from CString and try to call
void AllocBuffer(int nLen);, which is a protected member fn of CString.
You can open the header file c:\....\vc\mfc\include\afx.h and see the declaration of CString.
Thank you
Avatar of dutong

ASKER

Thank you svel
I've found something to change CRichEditCtrl behavior
just set m_bRTF to false, than the default Serialize of CRichEditCtrl can make the text to display, but it can not process RTF correctly, I didn't know if I should make the format myself, or set another hided field