Home COM GDI+ WebBrowser Data Access

IOleContainer Interface

 

IID_IOleContainer

{0000011B-0000-0000-C000-000000000046}

 

 

The IOleContainer interface is used to enumerate objects in a compound document or lock a container in the running state. Container and object applications both implement this interface.

 

Call IOleContainer to enumerate the objects in a compound document or to lock a container so that silent updates of link sources can occur without interruption until the container is explicitly released.

 

Many applications inherit the functions of IOleContainer by implementing IOleItemContainer, which is used to bind item monikers.

 

 

Methods in VTable order

IUnknown Methods

Description

QueryInterface

Returns pointers to supported interfaces.

AddRef

Increments reference count.

Release

Decrements reference count.

IParseDisplayName Method

Description

ParseDisplayName

Parses the display name returning a moniker corresponding to it.

IOleContainer Methods

Description

EnumObjects

Enumerates objects in a container.

LockContainer

Keeps container running until explicitly released.

 

EnumObjects

 

FUNCTION IOleContainer_EnumObjects ( _

  BYVAL pthis AS DWORD PTR _

, BYVAL grfFlags AS DWORD _

, BYREF ppenum AS DWORD _

  ) AS LONG

  LOCAL HRESULT AS LONG
  CALL DWORD @@pthis[4] USING IOleContainer_EnumObjects (pthis, grfFlags, ppenum) TO HRESULT
  FUNCTION = HRESULT


END FUNCTION

 

 

LockContainer

 

FUNCTION IOleContainer_LockContainer ( _

  BYVAL pthis AS DWORD PTR _

, BYVAL fLock AS LONG _

  ) AS LONG

  LOCAL HRESULT AS LONG
  CALL DWORD @@pthis[5] USING IOleContainer_LockContainer (pthis, fLock) TO HRESULT
  FUNCTION = HRESULT


END FUNCTION

 

 

IOleContainer interface implementation

 


$IID_IOleContainer = GUID$("{0000011b-0000-0000-C000-000000000046}")

' ****************************************************************************************
' IOleContainer interface
' ****************************************************************************************
TYPE IOleContainerVtbl
   ' IUnknown methods
   pQueryInterface          AS DWORD          ' // QueryInterface method
   pAddRef                  AS DWORD          ' // AddRef method
   pRelease                 AS DWORD          ' // Release method
   ' IParseDisplayName  members
   pParseDisplayName        AS DWORD          ' // ParseDisplayName method
   ' IOleContainer members
   pEnumObjects             AS DWORD          ' // EnumObjects method
   pLockContainer           AS DWORD          ' // LockContainer method
   ' Custom data
   pVtblAddr                AS DWORD          ' // Address of the virtual table
   cRef                     AS DWORD          ' // Reference count
END TYPE
' ****************************************************************************************

' ****************************************************************************************
' Builds the IOleContainer Virtual Table
' Returns a cookie that is a pointer to a IOleContainerVtbl structure.
' ****************************************************************************************
FUNCTION IOleContainer_BuildVtbl () AS DWORD

   LOCAL pVtbl AS IOleContainerVtbl PTR
   LOCAL pUnk AS IOleContainerVtbl PTR

   pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
   IF pVtbl = 0 THEN EXIT FUNCTION

   @pVtbl.pQueryInterface          = CODEPTR(IOleContainer_QueryInterface)
   @pVtbl.pAddRef                  = CODEPTR(IOleContainer_AddRef)
   @pVtbl.pRelease                 = CODEPTR(IOleContainer_Release)

   @pVtbl.pParseDisplayName        = CODEPTR(IOleContainer_ParseDisplayName)
   @pVtbl.pEnumObjects             = CODEPTR(IOleContainer_EnumObjects)
   @pVtbl.pLockContainer           = CODEPTR(IOleContainer_LockContainer)

   @pVtbl.pVtblAddr                = pVtbl
   @pVtbl.cRef                     = 1

   pUnk = VARPTR(@pVtbl.pVtblAddr)
   FUNCTION = pUnk

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IOleContainer_QueryInterface method
' Returns the IUnknown of our class and increments the reference counter.
' ****************************************************************************************
FUNCTION IOleContainer_QueryInterface (BYVAL pCookie AS IOleContainerVtbl PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
   IF riid = $IID_IOleContainer THEN
      ppvObj = pCookie
      INCR @@pCookie.cRef
      FUNCTION = %S_OK
   ELSE
      FUNCTION = %E_NOINTERFACE
   END IF
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IOleContainer_AddRef method
' Increments the reference counter.
' ****************************************************************************************
FUNCTION IOleContainer_AddRef (BYVAL pCookie AS IOleContainerVtbl PTR) AS DWORD
   INCR @@pCookie.cRef
   FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IOleContainer_Release method
' Releases our class if there is only a reference to him and decrements the reference counter.
' ****************************************************************************************
FUNCTION IOleContainer_Release (BYVAL pCookie AS IOleContainerVtbl 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
' ****************************************************************************************

' ****************************************************************************************
' Parses the display name returning a moniker corresponding to it.
' ****************************************************************************************
FUNCTION IOleContainer_ParseDisplayName (BYVAL pCookie AS IOleContainerVtbl PTR, BYVAL pbc AS DWORD, BYVAL pszDisplayName AS STRING,  BYREF pchEaten AS DWORD, BYREF ppmkOut AS DWORD) AS LONG
   ' Put your code here
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' Parses the display name returning a moniker corresponding to it.
' ****************************************************************************************
FUNCTION IOleContainer_EnumObjects (BYVAL pCookie AS IOleContainerVtbl PTR, BYVAL grfFlags AS DWORD, BYREF ppenum AS DWORD) AS LONG
   ' Put your code here
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' Keeps container running until explicitly released.
' ****************************************************************************************
FUNCTION IOleContainer_LockContainer (BYVAL pCookie AS IOleContainerVtbl PTR, BYVAL fLock AS LONG) AS LONG
   ' Put your code here
END FUNCTION
' ****************************************************************************************
 

 

Page last updated on Monday, 03 April 2006 20:31:06 +0200