Solved

How to use the CRichEditCtrl

Posted on 1998-05-01
8
228 Views
Last Modified: 2013-11-19
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!
0
Comment
Question by:dutong
[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
  • 4
  • 3
8 Comments
 
LVL 11

Expert Comment

by:mikeblas
ID: 1305672
What's the format of the file you're trying to open?

.B ekiM
0
 

Author Comment

by:dutong
ID: 1305673
RTF and normal text file
0
 

Accepted Solution

by:
svel earned 100 total points
ID: 1305674
Inside CRichView::OnInitialUpdate() fn,
Call
GetRichEditCtrl().SetWindowText(csSource) ;  //csSource is a string contains file, RTF....
0
Technology Partners: 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!

 

Author Comment

by:dutong
ID: 1305675
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?
0
 

Expert Comment

by:svel
ID: 1305676
    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.
0
 

Author Comment

by:dutong
ID: 1305677
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
0
 

Expert Comment

by:svel
ID: 1305678
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
0
 

Author Comment

by:dutong
ID: 1305679
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

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