Solved

Why CRichEditCtrl cannot show images in a RTF file?

Posted on 2004-04-30
6
734 Views
Last Modified: 2013-11-20
I create a dialogbox and add a CRichEditCtrl on it. Then I use the following codes to read a RTF file into the CRichEditCtrl, as follows(this is the sample from MSDN):

// My callback procedure that writes the rich edit control contents
// to a file.
static DWORD CALLBACK
MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile* pFile = (CFile*) dwCookie;

*pcb = pFile->Read(pbBuff, cb);

return 0;
}

// The example code.
// The pointer to my rich edit control.
extern CRichEditCtrl* pmyRichEditCtrl;
// The file from which to load the contents of the rich edit control.
CFile cFile(TEXT("myfile.rtf"), CFile::modeRead);
EDITSTREAM es;

es.dwCookie = (DWORD) &cFile;
es.pfnCallback = MyStreamInCallback;
pmyRichEditCtrl->StreamIn(SF_RTF, es);

However, when the codes are executed, only the texts in RTF can be displayed in CRichEditCtrl, the images cannot be displayed. Why?
0
Comment
Question by:chcw
  • 2
6 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 10957680
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 10957771
0
 
LVL 8

Author Comment

by:chcw
ID: 10969542
Thanks to roshmon, but what you mentioned is just insert an image into the RichEdit control. If using this example in my case, I must do as follows:

1. parse the RTF tags in MyStreamInCallback function
2. retrieve the image data from the RTF tags
3. convert it into a binary data
4. determine the insert point for the image, and thinking of possible text around the image.
5. then use the sample you provided to insert the image into RTF.

This procedure is very inconvenient. At least I need to spend time to study the RTF format. Are there any better solution to this problem?
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12049895
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

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 92
Adapt this command to show who installed 29 111
isEverywhere  challenge 19 82
post4 challenge 28 104
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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