Specifies the format and other data to be cached inside an embedded object.
HRESULT Cache(
FORMATETC * pFormatetc, //Pointer to the format and data to be
// cached
DWORD advf, //Flags that control the caching
DWORD * pdwConnection //Pointer to the connection for future
// calls to uncache
);
This method supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:
IOleCache::Cache can specify either data caching or view (presentation) caching. To specify data caching, a valid data format must be passed in pFormatetc. For view caching, the cache object itself decides on the format to cache, so a caller would pass a zero data format in pFormatetc as follows:
pFormatetc->cfFormat == 0
A custom object handler can choose not to store data in a given format. Instead, it can synthesize it on demand when requested.
The advf value specifies a member of the ADVF enumeration. When one of these values (or an OR'd combination of more than one value) is used in this context, these values mean the following:
ADVF Value | Description |
---|---|
ADVF_NODATA | The cache is not to be updated by changes made to the running object. Instead, the container will update the cache by explicitly calling IOleCache::SetData, IDataObject::SetData, or IOleCache2::UpdateCache. This flag is usually used when the iconic aspect of an object is being cached. |
ADVF_ONLYONCE | Update the cache one time only. After the update is complete, the advisory connection between the object and the cache is disconnected. The source object for the advisory connection calls the IAdviseSink::Release method. |
ADVF_PRIMEFIRST | The object is not to wait for the data or view to change before updating the cache. OR'd with ADVF_ONLYONCE, this parameter provides an asynchronous GetData call. |
ADVFCACHE_NOHANDLER | Synonym for ADVFCACHE_FORCEBUILTIN. |
ADVFCACHE_FORCEBUILTIN | Used by DLL object applications and object handlers that draw their objects to cache presentation data to ensure that there is a presentation in the cache. This ensures that the data can be retrieved even when the object or handler code is not available. |
ADVFCACHE_ONSAVE | Updates the cached representation only when the object containing the cache is saved. The cache is also updated when the OLE object changes from the running state back to the loaded state (because a subsequent save operation would require running the object again). |
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in oleidl.h.