This demo project is very good.And now i have a problem ussing the RichEdit Control in a dialogbox,how can i insert any registered object into the RichEdit Control placed on a dialog?even more,can i use this control as the CRichEditView?
Thanks a lot!
The code provided by Hani Atassi is not working if we keep Inserting the bitmap miltiple number of times.I first insert the text into rich edit control using the ReplaceSel(..) method and then the bitmap, repeate this step several times ,then the problem occurs i.e;the bitmap doesn'getInserted .I am using the win32 functions LoadImage and CopyImage to get the handle of the bitmap to pass to the InsertBitmap function.
Is this the problem with the code provided in this article or with the CRichEditCtrl.
If anyone has any remedy for it ,please reply that to my mail-id.
I found this to be most useful, and also to the point.
I have another requirement though to allow customization of background color along with custom images.
However I notice if I change the background color the mask on the previously inserted images fail. And you can see the solid rectangle behind the image.
Is there a solution to make multiple calls to SetBackgroundColor and still preserve the transparency of existing images on the rich Edit ?
I have modified CImageDataObject to allow the insertion of CF_ENHMETAFILE instead of CF_BITMAP. The inserted object is placed and visualized correctly in the CRichEditCtrl.
However, there is a problem when I save the CRichEditCtrl
contents to a file. It seems the rtf is saved correctly but, when I open the saved file with Word or WordPad, the metafile object appears in blank. That is, there is a box with the right size but empty.
I checked the rtf file and the code for the metafile is inside but I guess it is not the right code.
The context in which I'm using the CImageDataObject is in a dialog box containing a CRichEditCtrl as a control.
I am using the following code to save the rich edit control.
In my program, I use a RichEditCtrl (m_pRichEdit).
When I insert bitmap in loop
pRichEditOle = m_pRichEdit.GetIRichEditOle();
for ( int i = 0 ; i < 500; i++) // loop 500 times
for (int j=0; j < 100; j++ )
//Insert about 100 bitmaps into m_pRichEdit.
Then Windows shows error :
"Not enough storage is available to the complete this operation"
I think that this program dont release memory (OLE Object) when I clear content of the RichEditCtrl (m_pRichEdit).
Please update the code at function
// Release all unnecessary interfaces
lpLockBytes->Release(); // Please insert this line
Thanks in advance
my mail : firstname.lastname@example.org
p/s : About my comment "How to work in multithread"
One way to solve multithreaded
by sending a user define message that tells it to insert the text.. This method is the easiest method..
Thanks Hani Atassi. ;-)