1

How Can I insert an image to a RichEdit? I am using the Msftedit.dll and Richedit.h. I google it but cannot find a good way to solve it. Can you help me ?

pan.mingzhi
  • 83
  • 1
  • 1
  • 5

2 Answers2

1

Check out ITextRange2::InsertImage (http://msdn.microsoft.com/en-us/library/windows/desktop/Hh768649(v=vs.85).aspx). It's also written up in http://blogs.msdn.com/b/murrays/archive/2012/05/25/richedit-8-0-image-support.aspx

murrays
  • 11
  • 1
  • 1
    Note that this is only valid for Windows 8 onwards, while msftedit.dll has been available since Windows XP Service Pack 1. – DavidK Mar 22 '13 at 13:12
0

This involves jumping through a few COM-related hoops: you need to create an IOleObject COM object to represent the picture, which has to be backed by an IStorage COM object representing the actual picture data, which can then be inserted into the RichEdit object.

This is all covered in a lot of detail in Microsoft Knowledge Base article #220844. There is also an example of this technique in a larger system I've been involved in writing here: start with the function GameText::Draw().

DavidK
  • 3,929
  • 1
  • 19
  • 26