News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using OLE to put an Image in a richedit

Started by ToutEnMasm, September 07, 2006, 03:23:41 PM

Previous topic - Next topic

ToutEnMasm

Hello,
Following this article http://support.microsoft.com/default.aspx?scid=kb;en-us;141549
I put an image in a richedit (copy-paste).This work well,and the rtf file with the image can be save and reload.

The author of the article recommend to deactivate the object when destroying the richedit.
I have translated the code that is in the code page(follow link),But it don't work in my case.

The "IRichEditOle GetObjectCount" answer there is one object (the image) but the "IRichEditOle GetObject" don't return any interface neither than flags.Following is the code.
Is there something I don't know ?.
                                                ToutEnMasm

DetruireOleRichedit PROC  Hedit:DWORD
Local reObj:REOBJECT
Local  CPT:DWORD,retour:DWORD

mov retour,0
.if ppvIRichEditOle == 0
jmp FindeDetruireOleRichedit
.endif
IRichEditOle GetObjectCount
mov CPT,eax
.if eax == 0
jmp FindeDetruireOleRichedit
.endif
;ppv of the interfaces are returned in the REOBJECT structure
;poleobj=IOleObject,pstg=IStorage,polesite=IOleClientSite
INVOKE  RtlZeroMemory, addr reObj, sizeof reObj
mov reObj.cbStruct,sizeof REOBJECT

.while (CPT)
IRichEditOle GetObject,CPT,addr reObj,REO_GETOBJ_ALL_INTERFACES ;REO_GETOBJ_POLEOBJ
mov eax,reObj.dwFlags
and eax,REO_INPLACEACTIVE
.if eax != 0
IRichEditOle InPlaceDeactivate
.endif
mov eax,reObj.dwFlags
and eax,REO_OPEN
.if eax != 0
mov eax,reObj.poleobj
mov ppvIOleObject,eax
IOleObject Close,OLECLOSE_NOSAVE
.endif
;------------- release the interfaces -----------------
mov eax,reObj.poleobj
.if eax != 0
mov ppvIOleObject,eax
IOleObject Release
.endif

mov eax,reObj.pstg
.if eax != 0
mov ppvIStorage,eax
IStorage Release
.endif

mov eax,reObj.polesite
.if eax != 0
mov ppvIOleClientSite,eax
IOleClientSite Release
.endif
;-------------------------------------------

dec CPT
.endw
IRichEditOle Release

FindeDetruireOleRichedit:
         mov eax,retour
         ret
DetruireOleRichedit endp