|
|
|
ShellFolderViewOC Object |
|
CLSID_ShellFolderViewOC |
{9BA05971-F6A8-11CF-A442-00A0C90A8F39} |
|
IID_IFolderViewOC |
{9BA05970-F6A8-11CF-A442-00A0C90A8F39} |
|
The ShellFolderViewOC object forwards the events fired by a specified ShellFolderView object to corresponding ShellFolderViewOC event handlers.
Remarks
The ShellFolderView object fires two events, EnumDone and SelectionChanged, that must normally be handled by applications. However, some applications need to handle events from a series of ShellFolderView objects. For example, an application might host a WebBrowser control that allows users to navigate through a series of folders. Each folder has its own ShellFolderView object with its associated events. Handling these events can be rather difficult.
The ShellFolderViewOC object simplifies event handling for such scenarios. It allows applications to handle events for all ShellFolderView objects with a single pair of ShellFolderViewOC event handlers. Each time the user navigates to a new folder, the application passes the associated ShellFolderView object to the ShellFolderViewOC object by calling SetFolderView. Then, when an EnumDone or SelectionChanged event is fired, the ShellFolderViewOC object forwards the event to its own handler for processing.
|
|
Methods in VTable order |
|
|
IUnknown Methods |
Description |
|
QueryInterface |
Returns pointers to supported interfaces. |
|
AddRef |
Increments reference count. |
|
Release |
Decrements reference count. |
|
IDispatch Methods |
Description |
|
GetTypeInfoCount |
Retrieves the number of type information interfaces that an object provides (either 0 or 1). |
|
GetTypeInfo |
Gets the type information for an object. |
|
GetIDsOfNames |
Maps a single member and an optional set of argument names to a corresponding set of integer DISPIDs. |
|
Invoke |
Provides access to properties and methods exposed by an object. |
|
IShellFolderViewOC Method |
Description |
|
SetFolderView |
Forwards the events of the specified ShellFolderView object to the corresponding ShellFolderViewOC event handler. |
|
IShellFolderViewOC Events |
Description |
|
SelectionChanged |
Indicates that the selection state of one or more items in the view has changed. |
|
EnumDone |
Indicates that the ShellFolderView object has finished enumerating the folder's contents. |
|
VerbInvoked |
Undocumented. |
|
DefaultVerbInvoked |
Undocumented. |
|
BeginDrag |
Undocumented. |
|
SetFolderView |
|
FUNCTION
IFolderViewOC_SetFolderView ( _
|
|
DShellFolderViewEvents Implementation |
' ****************************************************************************************
' DShellFolderViewEvents dispatch interface
' IID = {62112AA2-EBE4-11CF-A5FB-0020AFE7292D}
' Help string = Event interface for ShellFolderView
' Attributes = 4096 [&H1000] [Dispatchable]
' Number of functions = 5
' ****************************************************************************************
' ****************************************************************************************
' EXCEPINFO structure
' ****************************************************************************************
TYPE DShellFolderViewEvents_EXCEPINFO
wCode AS WORD ' An error code describing the error.
wReserved AS WORD ' Reserved
bstrSource AS DWORD ' Source of the exception.
bstrDescription AS DWORD ' Textual description of the error.
bstrHelpFile AS DWORD ' Help file path.
dwHelpContext AS DWORD ' Help context ID.
pvReserved AS DWORD ' Reserved.
pfnDeferredFillIn AS DWORD ' Pointer to function that fills in Help and description info.
scode AS DWORD ' An error code describing the error.
END TYPE
' ****************************************************************************************
' ****************************************************************************************
' Returns a pointer to a specified interface on an object to which a client currently holds an
' interface pointer.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_IUnknown_QueryInterface (BYVAL pthis AS DWORD PTR, _
BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
LOCAL HRESULT AS LONG
CALL DWORD @@pthis[0] USING DShellFolderViewEvents_IUnknown_QueryInterface(pthis, riid, ppvObj) TO HRESULT
FUNCTION = HRESULT
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' Decrements the reference count for the calling interface on a object. If the reference count
' on the object falls to 0, the object is freed from memory.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_IUnknown_Release (BYVAL pthis AS DWORD PTR) AS DWORD
LOCAL DWRESULT AS DWORD
CALL DWORD @@pthis[2] USING DShellFolderViewEvents_IUnknown_Release(pthis) TO DWRESULT
FUNCTION = DWRESULT
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IConnectionPointContainer::FindConnectionPoint
' Returns a pointer to the IConnectionPoint interface of a connection point for a specified IID,
' if that IID describes a supported outgoing interface.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_IConnectionPointContainer_FindConnectionPoint ( _
BYVAL pthis AS DWORD PTR, BYREF riid AS GUID, BYREF ppCP AS DWORD) AS LONG
LOCAL HRESULT AS LONG
CALL DWORD @@pthis[4] USING DShellFolderViewEvents_IConnectionPointContainer_FindConnectionPoint(pthis, riid, ppCP) TO HRESULT
FUNCTION = HRESULT
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IConnectionPoint::Advise
' Establishes a connection between the connection point object and the client's sink.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_IConnectionPoint_Advise (BYVAL pthis AS DWORD PTR, _
BYVAL pUnkSink AS DWORD, BYREF pdwCookie AS DWORD) AS LONG
LOCAL HRESULT AS LONG
CALL DWORD @@pthis[5] USING DShellFolderViewEvents_IConnectionPoint_Advise(pthis, pUnkSink, pdwCookie) TO HRESULT
FUNCTION = HRESULT
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IConnectionPoint::Unadvise
' Terminates an advisory connection previously established through IConnectionPoint_Advise.
' The dwCookie parameter identifies the connection to terminate.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_IConnectionPoint_Unadvise (BYVAL pthis AS DWORD PTR, BYVAL dwCookie AS DWORD) AS LONG
LOCAL HRESULT AS LONG
CALL DWORD @@pthis[6] USING DShellFolderViewEvents_IConnectionPoint_Unadvise(pthis, dwCookie) TO HRESULT
FUNCTION = HRESULT
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' IDispatch virtual table
' ****************************************************************************************
TYPE DShellFolderViewEvents_IDispatchVtbl
QueryInterface AS DWORD ' Returns pointers to supported interfaces
AddRef AS DWORD ' Increments reference count
Release AS DWORD ' Decrements reference count
GetTypeInfoCount AS DWORD ' Retrieves the number of type descriptions
GetTypeInfo AS DWORD ' Retrieves a description of object's programmable interface
GetIDsOfNames AS DWORD ' Maps name of method or property to DispId
Invoke AS DWORD ' Calls one of the object's methods, or gets/sets one of its properties
pVtblAddr AS DWORD ' Address of the virtual table
cRef AS DWORD ' Reference counter
pthis AS DWORD ' IUnknown or IDispatch of the control that fires the events
END TYPE
' ****************************************************************************************
' ****************************************************************************************
' UI4 AddRef()
' Increments the reference counter.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_AddRef (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR) AS DWORD
INCR @@pCookie.cRef
FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' HRESULT QueryInterface([in] *GUID riid, [out] **VOID ppvObj)
' Returns the IUnknown of our class and increments the reference counter.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_QueryInterface (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, _
BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
ppvObj = pCookie
DShellFolderViewEvents_AddRef pCookie
FUNCTION = %S_OK
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' UI4 Release()
' Releases our class if there is only a reference to him and decrements the reference counter.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_Release (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR) AS DWORD
LOCAL pVtblAddr AS DWORD
IF @@pCookie.cRef = 1 THEN
pVtblAddr = @@pCookie.pVtblAddr
IF ISTRUE HeapFree(GetProcessHeap(), 0, BYVAL pVtblAddr) THEN
FUNCTION = 0
EXIT FUNCTION
ELSE
FUNCTION = @@pCookie.cRef
EXIT FUNCTION
END IF
END IF
DECR @@pCookie.cRef
FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' HRESULT GetTypeInfoCount([out] *UINT pctinfo)
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_GetTypeInfoCount (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, BYREF pctInfo AS DWORD) AS LONG
FUNCTION = %E_NOTIMPL
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' HRESULT GetTypeInfo([in] UINT itinfo, [in] UI4 lcid, [out] **VOID pptinfo)
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_GetTypeInfo (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, _
BYVAL itinfo AS DWORD, BYVAL lcid AS DWORD, BYREF pptinfo AS DWORD) AS LONG
FUNCTION = %E_NOTIMPL
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' HRESULT GetIDsOfNames([in] *GUID riid, [in] **I1 rgszNames, [in] UINT cNames, [in] UI4 lcid, [out] *I4 rgdispid)
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_GetIDsOfNames ( BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, _
BYREF riid AS GUID, BYVAL rgszNames AS DWORD, BYVAL cNames AS DWORD, BYVAL lcid AS DWORD, BYREF rgdispid AS LONG) AS LONG
FUNCTION = %E_NOTIMPL
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' Builds the IDispatch Virtual Table
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_BuildVtbl (BYVAL pthis AS DWORD) AS DWORD
LOCAL pVtbl AS DShellFolderViewEvents_IDispatchVtbl PTR
LOCAL pUnk AS DShellFolderViewEvents_IDispatchVtbl PTR
pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
IF pVtbl = 0 THEN EXIT FUNCTION
@pVtbl.QueryInterface = CODEPTR(DShellFolderViewEvents_QueryInterface)
@pVtbl.AddRef = CODEPTR(DShellFolderViewEvents_AddRef)
@pVtbl.Release = CODEPTR(DShellFolderViewEvents_Release)
@pVtbl.GetTypeInfoCount = CODEPTR(DShellFolderViewEvents_GetTypeInfoCount)
@pVtbl.GetTypeInfo = CODEPTR(DShellFolderViewEvents_GetTypeInfo)
@pVtbl.GetIDsOfNames = CODEPTR(DShellFolderViewEvents_GetIDsOfNames)
@pVtbl.Invoke = CODEPTR(DShellFolderViewEvents_Invoke)
@pVtbl.pVtblAddr = pVtbl
@pVtbl.pthis = pthis
pUnk = VARPTR(@pVtbl.pVtblAddr)
FUNCTION = pUnk
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' Establishes a connection between the connection point object and the client's sink.
' Returns a token that uniquely identifies this connection.
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_ConnectEvents (BYVAL pthis AS DWORD, BYREF pdwCookie AS DWORD) AS LONG
LOCAL HRESULT AS LONG ' HRESULT code
LOCAL pCPC AS DWORD ' IConnectionPointContainer
LOCAL pCP AS DWORD ' IConnectionPoint
LOCAL IID_CPC AS GUID ' IID_IConnectionPointContainer
LOCAL IID_CP AS GUID ' Events dispinterface
LOCAL dwCookie AS DWORD ' Returned token
LOCAL pUnkSink AS DWORD ' IUnknown of the class
IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
IID_CP = GUID$("{62112AA2-EBE4-11CF-A5FB-0020AFE7292D}")
IF pthis = 0 THEN FUNCTION = -1 : EXIT FUNCTION
HRESULT = DShellFolderViewEvents_IUnknown_QueryInterface(pthis, IID_CPC, pCPC)
IF HRESULT <> %S_OK THEN FUNCTION = HRESULT : EXIT FUNCTION
HRESULT = DShellFolderViewEvents_IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
DShellFolderViewEvents_IUnknown_Release pCPC
IF HRESULT <> %S_OK THEN FUNCTION = HRESULT : EXIT FUNCTION
pUnkSink = DShellFolderViewEvents_BuildVtbl(pthis)
IF ISTRUE pUnkSink THEN HRESULT = DShellFolderViewEvents_IConnectionPoint_Advise(pCP, pUnkSink, dwCookie)
DShellFolderViewEvents_IUnknown_Release pCP
pdwCookie = dwCookie
FUNCTION = HRESULT
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' Releases the events connection identified with the cookie returned by the ConnectEvents function
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_DisconnectEvents (BYVAL pthis AS DWORD, BYVAL dwCookie AS DWORD) AS LONG
LOCAL HRESULT AS LONG ' HRESULT code
LOCAL pCPC AS DWORD ' IConnectionPointContainer
LOCAL pCP AS DWORD ' IConnectionPoint
LOCAL IID_CPC AS GUID ' IID_IConnectionPointContainer
LOCAL IID_CP AS GUID ' ConnectionEvents dispinterface
IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
IID_CP = GUID$("{62112AA2-EBE4-11CF-A5FB-0020AFE7292D}")
IF pthis = 0 THEN FUNCTION = -1 : EXIT FUNCTION
HRESULT = DShellFolderViewEvents_IUnknown_QueryInterface(pthis, IID_CPC, pCPC)
IF HRESULT <> %S_OK THEN FUNCTION = HRESULT : EXIT FUNCTION
HRESULT = DShellFolderViewEvents_IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
DShellFolderViewEvents_IUnknown_Release pCPC
IF HRESULT <> %S_OK THEN FUNCTION = HRESULT : EXIT FUNCTION
HRESULT = DShellFolderViewEvents_IConnectionPoint_Unadvise(pCP, dwCookie)
DShellFolderViewEvents_IUnknown_Release pCP
FUNCTION = HRESULT
END FUNCTION
' ****************************************************************************************
' ****************************************************************************************
' Function name: SelectionChanged
' Dispatch interface name: DShellFolderViewEvents
' Member identifier: &H000000C8 (200)
' ****************************************************************************************
SUB DShellFolderViewEvents_SelectionChanged (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
' =======================================================================================
' Retrieve the IDispatch reference of the control that has fired the event.
' =======================================================================================
LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
' =======================================================================================
' =======================================================================================
' *** Put your code here ***
' =======================================================================================
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Function name: EnumDone
' Dispatch interface name: DShellFolderViewEvents
' Member identifier: &H000000C9 (201)
' ****************************************************************************************
SUB DShellFolderViewEvents_EnumDone (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS)
' =======================================================================================
' Retrieve the IDispatch reference of the control that has fired the event.
' =======================================================================================
LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
' =======================================================================================
' =======================================================================================
' *** Put your code here ***
' =======================================================================================
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Function name: VerbInvoked
' Dispatch interface name: DShellFolderViewEvents
' Member identifier: &H000000CA (202)
' ****************************************************************************************
SUB DShellFolderViewEvents_VerbInvoked (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS, BYREF pvarResult AS VARIANT)
' =======================================================================================
' Retrieve the IDispatch reference of the control that has fired the event.
' =======================================================================================
LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
' =======================================================================================
' =======================================================================================
' *** Put your code here ***
' Note: The return type for pvarResult is %VT_BOOL <INTEGER>
' =======================================================================================
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Function name: DefaultVerbInvoked
' Dispatch interface name: DShellFolderViewEvents
' Member identifier: &H000000CB (203)
' ****************************************************************************************
SUB DShellFolderViewEvents_DefaultVerbInvoked (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS, BYREF pvarResult AS VARIANT)
' =======================================================================================
' Retrieve the IDispatch reference of the control that has fired the event.
' =======================================================================================
LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
' =======================================================================================
' =======================================================================================
' *** Put your code here ***
' Note: The return type for pvarResult is %VT_BOOL <INTEGER>
' =======================================================================================
END SUB
' ****************************************************************************************
' ****************************************************************************************
' Function name: BeginDrag
' Dispatch interface name: DShellFolderViewEvents
' Member identifier: &H000000CC (204)
' ****************************************************************************************
SUB DShellFolderViewEvents_BeginDrag (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, BYREF pdispparams AS DISPPARAMS, BYREF pvarResult AS VARIANT)
' =======================================================================================
' Retrieve the IDispatch reference of the control that has fired the event.
' =======================================================================================
LOCAL pthis AS DWORD : pthis = @@pCookie.pthis
' =======================================================================================
' =======================================================================================
' *** Put your code here ***
' Note: The return type for pvarResult is %VT_BOOL <INTEGER>
' =======================================================================================
END SUB
' ****************************************************************************************
' ****************************************************************************************
' HRESULT Invoke([in] I4 dispidMember, [in] *GUID riid, [in] UI4 lcid, [in] UI2 wFlags, [in] *DISPPARAMS pdispparams, [out] *VARIANT pvarResult, [out] *EXCEPINFO pexcepinfo, [out] *UINT puArgErr)
' ****************************************************************************************
FUNCTION DShellFolderViewEvents_Invoke (BYVAL pCookie AS DShellFolderViewEvents_IDispatchVtbl PTR, BYVAL dispidMember AS LONG, BYREF riid AS GUID, _
BYVAL lcid AS DWORD, BYVAL wFlags AS WORD, BYREF pdispparams AS DISPPARAMS, BYREF pvarResult AS VARIANT, _
BYREF pexcepinfo AS DShellFolderViewEvents_EXCEPINFO, BYREF puArgErr AS DWORD) AS LONG
FUNCTION = %S_OK
IF VARPTR(pdispparams) THEN
SELECT CASE AS LONG dispidMember
CASE &H000000C8 ' (200) ' // SelectionChanged
DShellFolderViewEvents_SelectionChanged(pCookie, pdispparams)
CASE &H000000C9 ' (201) ' // EnumDone
DShellFolderViewEvents_EnumDone(pCookie, pdispparams)
CASE &H000000CA ' (202) ' // VerbInvoked
DShellFolderViewEvents_VerbInvoked(pCookie, pdispparams, pvarResult)
CASE &H000000CB ' (203) ' // DefaultVerbInvoked
DShellFolderViewEvents_DefaultVerbInvoked(pCookie, pdispparams, pvarResult)
CASE &H000000CC ' (204) ' // BeginDrag
DShellFolderViewEvents_BeginDrag(pCookie, pdispparams, pvarResult)
CASE ELSE
FUNCTION = %DISP_E_MEMBERNOTFOUND
END SELECT
END IF
END FUNCTION
' ****************************************************************************************
|
Page last updated on Wednesday, 15 February 2006 22:40:43 +0100