Solved

Why CRichEditCtrl cannot show images in a RTF file?

Posted on 2004-04-30
6
736 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
[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
  • 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

Industry Leaders: 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!

Question has a verified solution.

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

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 …
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…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

687 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