Valhalla Legends Forums Archive | General Programming | [VB6] RichTextBox Prevent OLE Arbitrary Resizing?

AuthorMessageTime
DDA-TriCk-E
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
December 6, 2007, 4:19 AM
Barabajagal
There's absolutely no way to prevent it whatsoever. I've tried everything, including attempting to subclass the resizing, and it does nothing.
December 6, 2007, 5:01 AM
DDA-TriCk-E
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...
December 6, 2007, 5:35 AM
Hell-Lord
You need to convert the picture into a RTF string and it should work fine :)

http://vbforums.com/showpost.php?p=2131039&postcount=5
December 6, 2007, 7:20 AM
DDA-TriCk-E
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.
December 6, 2007, 10:29 AM
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.
December 6, 2007, 11:29 AM
Myndfyr
[quote author=Chriso.de link=topic=17210.msg175302#msg175302 date=1196936959]
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.
[/quote]
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::
December 6, 2007, 1:55 PM
Barabajagal
One possible reason is because you want them to be modifiable by the user... Other than that, though....
December 6, 2007, 7:14 PM
MyStiCaL
search pscode, i've stumbled across somthing that worked before.
December 6, 2007, 7:51 PM
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.
December 7, 2007, 12:21 AM
DDA-TriCk-E
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...
December 7, 2007, 1:53 AM
Myndfyr
[quote author=Andy link=topic=17210.msg175306#msg175306 date=1196968448]
One possible reason is because you want them to be modifiable by the user... Other than that, though....
[/quote]
So precache them on the load of the bot...?  Or whenever the images are changed by the user?
December 7, 2007, 2:42 AM
Barabajagal
It was a reason not to hardcode the emoticon data...
December 7, 2007, 7:22 AM
Myndfyr
[quote author=Andy link=topic=17210.msg175315#msg175315 date=1197012150]
It was a reason not to hardcode the emoticon data...
[/quote]
Right.  But I didn't ask "why not hardcode," I said, "Why not precache?"
December 7, 2007, 7:50 PM

Search