Solved

How to use the CRichEditCtrl

Posted on 1998-05-01
8
222 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 78
Importing Special Characters in Dynamics GP Through Integration Manager 3 69
has77  challenge 9 72
pre4 challenge 19 94
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

25 Experts available now in Live!

Get 1:1 Help Now