OK, I have to create myself an IRichEditCallback interface and implement it for my richedit control.
I know there is no IRichEditCallback interface implemented by default.
An Interface is a virtual method table.
[code] Dim vtable(12) as ptr
vtable(0) = AddressOf U_QueryInterface
vtable(1) = AddressOf U_AddRef
vtable(2) = AddressOf U_Release
vtable(3) = AddressOf GetNewStorage ’ VTable offset = 12
vtable(4) = AddressOf GetInPlaceContext ’ VTable offset = 16
vtable(5) = AddressOf ShowContainerUI’ VTable offset = 20
vtable(6) = AddressOf QueryInsertObject’ VTable offset = 24
vtable(7) = AddressOf DeleteObject’ VTable offset = 28
vtable(8) = AddressOf QueryAcceptData ’ VTable offset = 32
vtable(9) = AddressOf ContextSensitiveHelp ’ VTable offset = 36
vtable(10) = AddressOf GetClipboardData’ VTable offset = 40
vtable(11) = AddressOf GetDragDropEffect ’ VTable offset = 44
vtable(12) = AddressOf GetContextMenu ’ VTable offset = 48
Dim mbv as new MemoryBlock(52)
for i = 0 to 12
mbv.Ptr(4*i) = vtable(i)
next i
Dim pmbv as ptr = mbv
Call SendMessagePtr (mWnd, EM_SETOLECALLBACK, 0, pmbv)
[/code]
How to write the 3 first call back methods ? I tried :
Shared Function U_AddRef (This as ptr) As integer
#Pragma X86CallingConvention StdCall
Declare Function InterlockedIncrement Lib "kernel32" (lpAddend As ptr) As Integer
dim m as MemoryBlock = This
m.Int32Value(0) = m.Int32Value(0) + 4
return InterlockedIncrement (This)
End Function
U_AddRef method fires !
But the other methods don’t and app hangs as soon I right click, or copy/paste, etc.