?
Solved

Why CRichEditCtrl cannot show images in a RTF file?

Posted on 2004-04-30
6
Medium Priority
?
737 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

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 …
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…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

764 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