• Welcome to Valhalla Legends Archive.
 

[VB6] RichTextBox Prevent OLE Arbitrary Resizing?

Started by Chriso, December 05, 2007, 10:19 PM

Previous topic - Next topic

Chriso

Hi everyone,

In the program I am writing I am attempting to implement a 'smiley' feature where someone says a particular phrase and a picture representation is shown instead of the text. For example ; ) (without space) == ;)

So far the images are showing up fine, but when you click the image it allows you to resize the BMP to arbitrary dimensions.

Is there a way to gain access to the properties of these images at run time to disable this behaviour? Or is there any way to redirect/ignore the click event on these images?

I've successfully tried both the 'clipboard - paste' and 'OLEObjects.Add' method to print on the RichTextBox but both behave the same way when you click an image. Locking the text box has no effect either.

Any clues would be greatly appreciated.

Cheers,
- Chriso

Barabajagal

There's absolutely no way to prevent it whatsoever. I've tried everything, including attempting to subclass the resizing, and it does nothing.

Chriso

Well that's a pain, I'm assuming the RTF format didn't support it in the period during which the RichTextBox 6.0 control was created by Microsoft? Which is version RTF 1.5 (or lower) I think...

Hell-Lord


Chriso

It works, but it also takes a while to process.  Since it has to convert a picture to its byte representation, create a temp file, write the data, close the file, open the file, read the data, close the file, delete the file, then replace TextRTF with a new modified one EVERY time.  Therefore the more data that is in the RTB and the more smileys that are used, the longer this function will take to process.

Barabajagal

My code did the same thing, using raw RTF, but the image is still resizable. And using the code given at that link, an example image I used was still resizable as well.

MyndFyre

Quote from: Chriso.de on December 06, 2007, 04:29 AM
It works, but it also takes a while to process.  Since it has to convert a picture to its byte representation, create a temp file, write the data, close the file, open the file, read the data, close the file, delete the file, then replace TextRTF with a new modified one EVERY time.  Therefore the more data that is in the RTB and the more smileys that are used, the longer this function will take to process.
Why not precache the smiley images' RTF literal representation?  Then you don't need to do steps 1-8 of your list of things that it needs to do.  ::insert blinding flash of the obvious smiley here::
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Barabajagal

One possible reason is because you want them to be modifiable by the user... Other than that, though....

Mystical

search pscode, i've stumbled across somthing that worked before.

Hell-Lord

I'm not sure but Chriso hasn't posted yet but i think he was going to convert the images on startup or something so they it doesn't need to be done every time a message is received or sent. Not sure how it worked out but it might work for you too Andy.

Chriso

#10
They weren't resizable when I used the code at vbforums.com, but when I tried cacheing the RTF code and replacing the phrase with the cached smiley it was resizable. Not sure what happened, the entire RTF code looks the same in both circumstances...

MyndFyre

Quote from: Andy on December 06, 2007, 01:14 PM
One possible reason is because you want them to be modifiable by the user... Other than that, though....
So precache them on the load of the bot...?  Or whenever the images are changed by the user?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Barabajagal

It was a reason not to hardcode the emoticon data...

MyndFyre

Quote from: Andy on December 07, 2007, 01:22 AM
It was a reason not to hardcode the emoticon data...
Right.  But I didn't ask "why not hardcode," I said, "Why not precache?"
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.