|
|
|
IAdviseSink2 Interface |
|
IID_IAdviseSink2 |
{00000125-0000-0000-C000-000000000046} |
|
The IAdviseSink2 interface is an extension of IAdviseSink, adding the method OnLinkSrcChange to the contract to handle a change in the moniker of a linked object. This avoids overloading the implementation IAdviseSink::OnRename to handle the renaming of both embedded objects and linked objects. In applications where different blocks of code might execute depending on which of these two similar events has occurred, using the same method for both events complicates testing and debugging.
|
|
Methods in VTable order |
|
|
IUnknown Methods |
Description |
|
QueryInterface |
Returns pointers to supported interfaces. |
|
AddRef |
Increments reference count. |
|
Release |
Decrements reference count. |
|
IAdviseSink Methods |
Description |
|
OnDataChange |
Advises that data has changed. |
|
OnViewChange |
Advises that view of object has changed. |
|
OnRename |
Advises that name of object has changed. |
|
OnSave |
Advises that object has been saved to disk. |
|
OnClose |
Advises that object has been closed. |
|
IAdviseSink2 Method |
Description |
|
OnLinkSrcChange |
Advises that link source has changed. |
|
IAdviseSink2 interface implementation |
$IID_IAdviseSink2 = GUID$("{00000125-0000-0000-C000-000000000046}")
UNION STGMEDIUMDATA
hBitmap AS DWORD
hMetaFilePict AS DWORD
hEnhMetaFile AS DWORD
hGlobal AS DWORD
lpszFileName AS DWORD
pstm AS DWORD
pstg AS DWORD
END UNION
TYPE STGMEDIUM
tymed AS DWORD
tsmd AS STGMEDIUMDATA
pUnkForRelease AS DWORD
END TYPE
TYPE DVTARGETDEVICE
tdSize AS DWORD
tdDriverNameOffset AS WORD
tdDeviceNameOffset AS WORD
tdPortNameOffset AS WORD
tdExtDevmodeOffset AS WORD
tdData(0) AS BYTE
END TYPE
TYPE FORMATETC
cfFormat AS DWORD
ptd AS DVTARGETDEVICE PTR
dwAspect AS DWORD
lindex AS LONG
tymed AS DWORD
END TYPE
' ****************************************************************************************
' IAdviseSink2 interface
' ****************************************************************************************
TYPE IAdviseSink2Vtbl
' IUnknown methods
pQueryInterface AS DWORD ' // QueryInterface method
pAddRef AS DWORD ' // AddRef method
pRelease AS DWORD ' // Release method
' IAdviseSink methods
pOnDataChange AS DWORD ' // OnDataChange method
pOnViewChange AS DWORD ' // OnViewChange method
pOnRename AS DWORD ' // OnRename method
pOnsave AS DWORD ' // OnSave method
pOnClose AS DWORD ' // OnClose method
' IAdviseSink2 method
pOnLinkSrcChange AS DWORD ' // OnLinkSrcChange method
' Custom data
pVtblAddr AS DWORD ' // Address of the virtual table
cRef AS DWORD ' // Reference count
END TYPE
' ****************************************************************************************
' ****************************************************************************************
' Builds the IAdviseSink2 Virtual Table
' Returns a cookie that is a pointer to a IAdviseSink2Vtbl structure.
' ****************************************************************************************
FUNCTION IAdviseSink2_BuildVtbl () AS DWORD
LOCAL pVtbl AS IAdviseSink2Vtbl PTR
LOCAL pUnk AS IAdviseSink2Vtbl PTR
pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
IF pVtbl = 0 THEN EXIT FUNCTION
@pVtbl.pQueryInterface = CODEPTR(IAdviseSink2_QueryInterface)
@pVtbl.pAddRef = CODEPTR(IAdviseSink2_AddRef)
@pVtbl.pRelease = CODEPTR(IAdviseSink2_Release)
@pVtbl.pOnDataChange = CODEPTR(IAdviseSink2_OnDataChange)
@pVtbl.pOnViewChange = CODEPTR(IAdviseSink2_OnViewChange)
@pVtbl.pOnRename = CODEPTR(IAdviseSink2_OnRename)
@pVtbl.pOnSave = CODEPTR(IAdviseSink2_OnSave)
@pVtbl.pOnClose = CODEPTR(IAdviseSink2_OnClose)
@pVtbl.pOnLinkSrcChange = CODEPTR(IAdviseSink2_OnLinkSrcChange)
@pVtbl.pVtblAddr = pVtbl
@pVtbl.cRef = 1
pUnk = VARPTR(@pVtbl.pVtblAddr)
FUNCTION = pUnk
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IAdviseSink2_QueryInterface method
' Returns the IUnknown of our class and increments the reference counter.
' ****************************************************************************************
FUNCTION IAdviseSink2_QueryInterface (BYVAL pCookie AS IAdviseSink2Vtbl PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
IF riid = $IID_IAdviseSink2 THEN
ppvObj = pCookie
INCR @@pCookie.cRef
FUNCTION = %S_OK
ELSE
FUNCTION = %E_NOINTERFACE
END IF
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IAdviseSink2_IUnknown_AddRef method
' Increments the reference counter.
' ****************************************************************************************
FUNCTION IAdviseSink2_AddRef (BYVAL pCookie AS IAdviseSink2Vtbl PTR) AS DWORD
INCR @@pCookie.cRef
FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IAdviseSink2_IUnknown_Release method
' Releases our class if there is only a reference to him and decrements the reference counter.
' ****************************************************************************************
FUNCTION IAdviseSink2_Release (BYVAL pCookie AS IAdviseSink2Vtbl PTR) AS DWORD
DECR @@pCookie.cRef
FUNCTION = @@pCookie.cRef
IF @@pCookie.cRef = 0 THEN
IF ISTRUE @@pCookie.pVtblAddr THEN
HeapFree(GetProcessHeap(), 0, BYVAL @@pCookie.pVtblAddr)
END IF
END IF
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' Advises that data has changed.
' ****************************************************************************************
SUB IAdviseSink2_OnDataChange (BYVAL pCookie AS IAdviseSink2Vtbl PTR, BYREF pformatetc AS FORMATETC, BYREF pStgmed AS STGMEDIUM)
' Put your code here
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Advises that view of object has changed.
' ****************************************************************************************
SUB IAdviseSink2_OnViewChange (BYVAL pCookie AS IAdviseSink2Vtbl PTR, BYVAL dwAspect AS DWORD, BYVAL lindex AS LONG)
' Put your code here
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Advises that name of object has changed.
' ****************************************************************************************
SUB IAdviseSink2_OnRename (BYVAL pCookie AS IAdviseSink2Vtbl PTR, BYVAL pmk AS DWORD)
' Put your code here
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Advises that object has been saved to disk.
' ****************************************************************************************
SUB IAdviseSink2_OnSave (BYVAL pCookie AS IAdviseSink2Vtbl PTR)
' Put your code here
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Advises that object has been closed.
' ****************************************************************************************
SUB IAdviseSink2_OnClose (BYVAL pCookie AS IAdviseSink2Vtbl PTR)
' Put your code here
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Advises that link source has changed.
' ****************************************************************************************
SUB IAdviseSink2_OnLinkSrcChange (BYVAL pCookie AS IAdviseSink2Vtbl PTR, BYVAL pmk AS DWORD)
' Put your code here
END SUB
' ****************************************************************************************
|
Page last updated on Monday, 03 April 2006 20:28:30 +0200