Hi Everyone,

Is it possible/easy to draw graphics into a normal Richedit control, after searching the internet for hours, i cant really find any examples that make much sense, especially not in asm.

I think its got something to do with IRichEditOleCallback.. but i dont know what this is or how to use it...

If anyone has got any idea's or source code i would be very grateful

Thank you,
Posted on 2003-09-27 23:40:51 by Lennon
Nobody got any idea's ? :confused:
Posted on 2003-09-28 11:47:17 by Lennon
Been searching all day, still cant find anything

Posted on 2003-09-29 11:53:39 by Lennon
Don't know much about this stuff so I'm not sure it will help you, but you can try using GetDC and draw directly on the richedit control.
Posted on 2003-09-29 13:25:22 by Delight
huh. I thought I have seen at least 3 such threads here. I don't code any richedit, so I haven't saved them on my hdd. Maybe you should search better. "richedit AND background" ...
Posted on 2003-09-29 14:34:53 by Ultrano
I dont want to draw text over some fancy background, i found those posts on the forum.

I want to display graphics for a chat progam, as is in something like this : :alright:

looking at this http://www.codeguru.com/richedit/richeditrc.html

it seems its possible...
Posted on 2003-09-29 15:31:51 by Lennon
I understand. Then search for the Miranda IM . It's an open-source project, a wonderful ICQ client that I use. It has such images inside of the textfield.
In fact, no need to search - the site is
Posted on 2003-09-29 23:45:40 by Ultrano

Just got back from a few days away, thanks for the link Ultrano i will have a look and see if i can find any usefull information/source code

Thank you,
Posted on 2003-10-02 10:48:06 by Lennon
arrgggg its no good :mad:

i've been looking all over the place for info but nothing is making sense to me, unless its asm and strait win32 api i just dont understand :rolleyes:

I've managed to find this .....


can anybody make sense of it and explain it to me?
Posted on 2003-10-05 21:32:11 by Lennon
I'm still new at OOP, but I tried to convert the code at MSDN (and failed miserably :( ).
Here's the source... if anyone with some experience in this could point out my mistakes, I'll appreciate it.
It seems to run fine until OleCreateFromFile is called. It returns error "incorrect tymed".

BTW, all the structures and equates were taken from VC and converted to MASM syntax "by hand", so please look if there are any mistakes there...
Posted on 2003-10-07 17:38:29 by QvasiModo
hi QvasiModo,

First of all, you dont know just how grateful i am that you took the time to actually try and convert the code, now that i have something to work with i might get somewhere, i will look over your code and see what i can learn from it, then hopefully i can help to try and find the fault.

My problem is i am too "old school" when people start talking MFC ...OOP ...COM ... i get totally lost, i really need to get my head down and learn something about this stuff, but as ever the problem is where to start.

Thank you VERY VERY much...

Posted on 2003-10-07 21:30:34 by Lennon

sc = ::OleCreateFromFile(clsid, T2COLE(lpszFileName),
IID_IUnknown, OLERENDER_DRAW, lpFormatEtc, m_lpClientSite, m_lpStorage,

you put:

invoke OleCreateFromFile, offset IID_NULL, pFile, offset IID_IUnknown, OLERENDER_DRAW, addr formatEtc, addr pClientSite, addr pStorage, addr pObject

I think, it is:

invoke OleCreateFromFile, offset IID_NULL, pFile, offset IID_IUnknown, OLERENDER_DRAW, addr formatEtc, pClientSite, pStorage, addr pObject

But still it does not work :)
Posted on 2003-10-07 21:38:12 by Jnrz

I've been checking over your code and so far i cant see anything wrong, altho i dont know why you call CreateTextServices after ExitProcess

;invoke ExitProcess,eax
;invoke CreateTextServices,eax,eax,eax

The problem seems to be with OleCreateFromFile, so why not try and create the object from a resource instead?

i think there is source to do it here

I will keep checking for any possible errors in your source, altho i dont really know what the hell i am doing :rolleyes:

Thank you ,
Posted on 2003-10-09 03:48:55 by Lennon
@Jnrz: You are right, that's what I meant to do... it's a silly typo :)

@Lennon: Hey, no problem. I'm "old school" too, I've been programming in MASM for like a year now and I still have trouble to stop using 8 and 16 bits registers ;)

The CreateTextServices is deliberately after ExitProcess so it doesn't get executed. I was too lazy to put the code to load the richedit library dynamically. :grin:

I also was a little lost here... in my opinion some things are not necessary, like creating an object with an IUnknown interface and then getting the pointer to IRichEditOle... wouldn't it have been easier to get IRichEditOle in the first place? :confused:

Anyway, since it doesn't work we don't loose anything by experimenting a bit, so let's try making our own changes to the code and see what happens...

I'm also taking a look at the last link you posted. I'll be busy till next week, but I'll try to convert it to MASM to compare the differences with the code we have, that might reveal what's wrong with it.
Posted on 2003-10-09 14:53:34 by QvasiModo
Hey Boyz

Here some Basic sourcecode which does just that... I don't have time lately or else I'd have a look.
Posted on 2003-10-09 22:05:18 by JimmyClif
here it is :)
Posted on 2003-10-10 00:22:53 by Jnrz
oh wow....you've only gone and done it!,


I owe you all a few pints down the local pub.

I will have a go at putting the code into my chat source and see what i can come up with, i'll report back.

Thanks again everyone.

Posted on 2003-10-10 06:08:46 by Lennon
Found 2 problems :confused:

First, there seems to be a memory leak, every time a picture is inserted memory is lost, and this just keeps getting bigger and bigger...even if backspace is pressed and the object deleted, the memory is not made free.

Second, every time a picture is inserted, MSPAINT loads up! (if you watch in Task Manager) and then closes again... this cant be good!

I will have to try and work out what is going on...


*edit* probably really obviously, its the call to OleCreateFromFile that is taking the memory and loading MSPAINT....
Posted on 2003-10-10 13:42:03 by Lennon
Oh dear, it seems that it isnt a memory leak, and nothing wrong with your code...

Its just the way it works :eek:

The same memory usage happens with the C++ examples you converted, also if you open Wordpad and paste bmp's into it, same problem again.

Now i need to find a less memory hungry way of doing things :mad:

and just when i thought the problem was over...
Posted on 2003-10-10 22:39:26 by Lennon
I see said the blind man, thought i had found the answer, but it doesnt look like i have now...

I thought that instead of creating a new object every time i wanted to insert an Emoticon, i would just create the object (so if i had 10 different Emoticons, i would create a new object for each of them) at the init stage of the chat client, and then whenever i need to insert an Emoticon into the richedit control i could just call -:

;insert the object into richedit at the current selection point
mov eax,pRichEditOle
mov edx,OFFSET reo ;with a reo structure setup for each Emoticon
push edx
push eax
mov eax,
call .IRichEditOle.InsertObject

...but...it just doesnt do anything after the first call to InsertObject, it seems it can only be used once.

can anybody tell me why it was a really bad idea?
Posted on 2003-10-11 07:08:58 by Lennon