Solved

How to use the CRichEditCtrl

Posted on 1998-05-01
8
219 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now