The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ToutEnMasm on September 09, 2005, 12:52:50 PM

Title: EM_SETOLECALLBACK for a richedit
Post by: ToutEnMasm on September 09, 2005, 12:52:50 PM
Hello,
I try to insert images and the like in a richedit.I have got several samples (c++ and power basic) that send the message EM_SETOLECALLBACK to the richedit before calling EM_GETOLEINTERFACE.
This message call only IRichEditOleCallback_AddRef , and it is when he returns that there is one error

With masm , when i call EM_GETOLEINTERFACE , i have an access violation.
Is there some Help here or some sample in masm ?
                              ToutEnMasm


.code
               WM_CREATE
                Hredit = handle to richedit
               invoke SendMessage,Hredit,EM_SETOLECALLBACK, 0,addr Com_Data.ppv
.data

Com_Data OLERICHEDITCALLBACK <offset vtablecallback,0,0,0>

vtablecallback dd IRichEditOleCallback_QueryInterface
dd IRichEditOleCallback_AddRef
dd IRichEditOleCallback_Release
dd IRichEditOleCallback_GetNewStorage
dd IRichEditOleCallback_GetInPlaceContext
dd IRichEditOleCallback_ShowContainerUI
dd IRichEditOleCallback_QueryInsertObject
dd IRichEditOleCallback_DeleteObject
dd IRichEditOleCallback_QueryAcceptData
dd IRichEditOleCallback_ContextSensitiveHelp
dd IRichEditOleCallback_GetClipboardData
dd IRichEditOleCallback_GetDragDropEffect
dd IRichEditOleCallback_GetContextMenu
Title: Re: EM_SETOLECALLBACK for a richedit
Post by: ToutEnMasm on September 10, 2005, 07:25:06 AM
Hello,
After searching,it seems that the IRichEditOleCallback has one parameter added to all of it's proto.
Only power basic and masm need to use it.    :green   
The c++ use proto as declare in richole.h.
If someone could explain me why it is like that ,I would be glad to ear it.
                           ToutEnMasm

Title: Re: EM_SETOLECALLBACK for a richedit
Post by: Tedd on September 12, 2005, 11:38:09 AM
It's the 'this' pointer - it points to the object you're using.
All of the functions in the vtable need to know which object they're supposed to act on - this is done automagically for you in C++. It's just OOP stuff :wink
So your extra parameter is the first one, which is normally 'hidden' because the (C++) compiler takes care of it for you. But in the case of masm, you have to do it yourself.