Naked RichEdit Won't Display Images-VBForums
Results 1 to 22 of 22

Thread: Naked RichEdit Won't Display Images

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Naked RichEdit Won't Display Images

    I have one of those cases where a program is tiny and the user needs it to be runnable as a simple EXE with no associated OCXs... but wants a simple Help dialog with fonts, colors, and a few tiny images.

    To avoid the RichTextBox OCX it is fairly easy to create and use a "naked" read-only ("locked") RichEdit control, but the way I'm loading the contents seems to lose any embedded images.

    The document displays fine in WordPad or loaded into a RichTextBox, so I'm missing something... but what?


    I've attached the "non working" demo program which loads from a Resource as well as the .RTF file itself. Perhaps somebody knows what I have forgotten to do here?
    Attached Files Attached Files

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Naked RichEdit Won't Display Images

    I've had a play with your code and can't get it to work either. I wonder if you're going to have to use EM_STREAMIN Message with SF_RTF (it looks like the equivalent of rtf.LoadFile with the 'complications' of having to use a CallBack)

    I'll have a play later.

  3. #3
    Hyperactive Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    362

    Re: Naked RichEdit Won't Display Images

    I thought it might be EM_STREAMIN as well - but I've tried it and so far I can't get it to work either Still experimenting...

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    Thanks for taking a look.

    I wondered whether the problem might be solved by streaming the data too, but EM_SETTEXTEX being trivial by comparison streaming's not the first path I tried. Perhaps I'll have to.

    I don't see any Style bits that appear to influence this. I wonder of it has something to do with setting up OLE for the control, since it probably needs to instantiate the embedded image as an object of an image type?

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    Here's a version hacked a bit to use streamin. No dice!

    I'll have to dig around. I was sure I had this working once.


    Fixed the attachment, which had a dumb mistake that should by rights have led to an infinite loop (got lucky here). Of course the fix doesn't address the matter at hand - same results.
    Attached Files Attached Files
    Last edited by dilettante; Apr 24th, 2012 at 11:15 PM. Reason: reposted attachment

  6. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Naked RichEdit Won't Display Images

    I wonder if this thread will help at all. (you may have forgotten) http://tek-tips.com/viewthread.cfm?qid=1588186

  7. #7
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,409

    Re: Naked RichEdit Won't Display Images

    The following is VC++ but if you understand the code you could attempt a translation to VB6:

    The article A Rich Edit Control That Displays Bitmaps and Other OLE Objects (The Code Project), is based on this other article Insert any HBITMAP (Bitmap) in your RichEdit Control (CodeGuru)

  8. #8
    Hyperactive Member
    Join Date
    Jan 2010
    Posts
    363

    Re: Naked RichEdit Won't Display Images

    Quote Originally Posted by dilettante View Post
    Here's a version hacked a bit to use streamin. No dice!

    I'll have to dig around. I was sure I had this working once.
    Nice.
    Please refer to Eduardo A. Morcillo's RichEdit control. But the codes were a bit complicated.

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    Well it looks like a lot of work that I haven't been authorized to proceed with. We'll probably either drop the embedded images or use Richtx32.ocx as I was doing in the first place, depending on what the customer really wants.

    If anyone wants to go forward with this I'm including a richole.idl example I found that is LGPL code. Microsoft does not supply one. I know I hate it when a search turns up a forum thread that dead-ends, but I hate it worse when the thread doesn't even leave useful breadcrumbs.

    I believe you'd need to compile this IDL into a TLB, then implement the IRichEditOleCallback interface in a custom Class. That's probably the missing link in my attempts above.
    Attached Files Attached Files

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    Quote Originally Posted by Jonney View Post
    Please refer to Eduardo A. Morcillo's RichEdit control. But the codes were a bit complicated.
    Indeed.

  11. #11
    Hyperactive Member
    Join Date
    Jan 2010
    Posts
    363

    Re: Naked RichEdit Won't Display Images

    Quote Originally Posted by dilettante View Post
    Well it looks like a lot of work that I haven't been authorized to proceed with. We'll probably either drop the embedded images or use Richtx32.ocx as I was doing in the first place, depending on what the customer really wants.

    If anyone wants to go forward with this I'm including a richole.idl example I found that is LGPL code. Microsoft does not supply one. I know I hate it when a search turns up a forum thread that dead-ends, but I hate it worse when the thread doesn't even leave useful breadcrumbs.

    I believe you'd need to compile this IDL into a TLB, then implement the IRichEditOleCallback interface in a custom Class. That's probably the missing link in my attempts above.
    Could you please post the tlb and give the whole solution as your per case?

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    I haven't built the TLB or a program that uses it. I decided to cut my losses there and just provide the IDL file for somebody more ambitious.

    So everything I have has already been posted.

  13. #13
    Hyperactive Member
    Join Date
    Jan 2010
    Posts
    363

    Re: Naked RichEdit Won't Display Images

    I tried to build the tlb,but failed.

    I used C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\midl.exe to build tlb.

    Refer to attachment.
    Attached Files Attached Files

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    Yeah, when I saw all of the nested includes I worried a bit. That IDL file might not be formed correctly for standard IDL/ODL compilers either.

    Sort of why I let the issue go.

  15. #15
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Naked RichEdit Won't Display Images

    Well, I've spent hours on this and it's really bugging me. I'm sure that there's a 'simple' solution but I haven't got the brains to work it out ! I'm really amazed that there's nothing on the Web, I was sure that someone must have wanted to do something like this before but apart from Custom Controls etc. I can't find anything.

    Just as well I've got a week off from work and it's pouring with rain so I can't get out in the Garden !!!

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    Sorry to throw out a question that's giving us so much trouble!

    I don't think it's about "brains" as much as it is about there normally being no need for VB programmers to be conversant with the background knowledge required. In post #7 jcis put us onto the answer with his first (Code Project) link I believe. Clearly a C++ programmer lives closer to the issues involved.

    There may be a more "VB friendly" answer if we took the TOM (Text Object Model) route too. Look for this in the IDE's References dialog as "tom" (RICHED20.DLL).

  17. #17
    Hyperactive Member
    Join Date
    Jan 2010
    Posts
    363

    Re: Naked RichEdit Won't Display Images

    Quote Originally Posted by dilettante View Post
    Sorry to throw out a question that's giving us so much trouble!

    I don't think it's about "brains" as much as it is about there normally being no need for VB programmers to be conversant with the background knowledge required. In post #7 jcis put us onto the answer with his first (Code Project) link I believe. Clearly a C++ programmer lives closer to the issues involved.

    There may be a more "VB friendly" answer if we took the TOM (Text Object Model) route too. Look for this in the IDE's References dialog as "tom" (RICHED20.DLL).
    In my programming experience, I feel VB6 doesn't have good/advanced Richedit and Grid/Cell control. But they are beyond my capabilities...

  18. #18
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Naked RichEdit Won't Display Images

    I've been playing with the TOM wirh no success. It all works fine if the target is an rtb control, but the 'naked' variety just will not play ball.

    Think it's time to take a lateral approach to the original requirement perhaps, and do away with rtb altogether.

    Just about to have some warm Hops mixed with water and yeast to inspire the grey cell.

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    I appreciate the effort!

    In this case I was able to get the client to live with some Wingdings symbols in place of the small iconic images originally desired. I had lobbied hard for a RichTextBox approach using reg-free COM, but since this was the only dependency I lost the vote.

    Alternatives would be harder to come by. The help text needs to be embedded and uses two fonts, several sizes, bullets and hanging indents, and three colors.

  20. #20
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Naked RichEdit Won't Display Images

    I was thinking about letting the RichTextBox do all the formatting etc. of the text but rendering the Image(s) in different Window(s). In the simplest case, something along the lines of 1 parent window, within that, 2 (borderless) child windows, one with the 'help' image and the other with the rtb. Some code to extract the (rtf) Picture information from the 'Text' byte array, format appropriately and display it. The extraction might be a bit tricky but the rtf tags are reasonably well documented.
    Last edited by Doogle; Apr 28th, 2012 at 04:33 AM.

  21. #21

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,363

    Re: Naked RichEdit Won't Display Images

    Well actually there were several small images inline with text and they needed to scoll along with the text, flow with Form resizing, etc.

    You know, like a normal RTF document.

  22. #22
    Junior Member
    Join Date
    Dec 2011
    Location
    Tullahoma, TN
    Posts
    20

    Re: Naked RichEdit Won't Display Images

    Quote Originally Posted by Doogle View Post
    I wonder if this thread will help at all. (you may have forgotten) http://tek-tips.com/viewthread.cfm?qid=1588186
    I was going to say the same! But it looks like you guys are way down further in the weeds than this...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.