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?
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 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?
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.
Last edited by dilettante; Apr 24th, 2012 at 11:15 PM.
Reason: reposted attachment
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.
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?
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 !!!
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).
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...
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.
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.