Solved

Why CRichEditCtrl cannot show images in a RTF file?

Posted on 2004-04-30
6
729 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
Comment Utility
0
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
0
 
LVL 8

Author Comment

by:chcw
Comment Utility
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
Comment Utility
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 …
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

10 Experts available now in Live!

Get 1:1 Help Now