Solved

How to use the CRichEditCtrl

Posted on 1998-05-01
8
227 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
  • 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
Independent Software Vendors: 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 112
method notes when mouse over in eclipse 5 90
Use of condition with 'serial' in ansible 2 84
noX challenge 17 134
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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