1 Attachment(s)
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?
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.
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...
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?
1 Attachment(s)
Re: Naked RichEdit Won't Display Images
Here's a version hacked a bit to use streamin. No dice! :confused:
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.
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
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)
Re: Naked RichEdit Won't Display Images
Quote:
Originally Posted by
dilettante
Here's a version hacked a bit to use streamin. No dice! :confused:
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.
1 Attachment(s)
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.
Re: Naked RichEdit Won't Display Images
Quote:
Originally Posted by
Jonney
Please refer to Eduardo A. Morcillo's RichEdit control. But the codes were a bit complicated.
Indeed.
Re: Naked RichEdit Won't Display Images
Quote:
Originally Posted by
dilettante
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?
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.
1 Attachment(s)
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.
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.
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 !!! :D
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).
Re: Naked RichEdit Won't Display Images
Quote:
Originally Posted by
dilettante
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...
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.
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.
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.
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.
Re: Naked RichEdit Won't Display Images
Quote:
Originally Posted by
Doogle
I was going to say the same! But it looks like you guys are way down further in the weeds than this...