Returns the current dynamic type description for an object, including any changes that have been made dynamically.
HRESULT GetDynamicClassInfo(
ITypeInfo ** ppTI,
DWORD * pdwCookie
);
Parameters
ppTI
[out] Indirect pointer to the current type information for the object.
pdwCookie
[out] Cookie to be used as a flag.
Return Values
The return value obtained from the HRESULT is one of the following:
Return Value | Meaning |
S_OK | Success. |
E_FAIL | The method failed for an unknown reason. |
E_OUTOFMEMORY | Out of memory. |
E_UNEXPECTED | The method is implemented, but an unexpected error occurred. |
Note
This method can also return any of the TYPE_E errors.
Comments
The GetDynamicClassInfo method returns an object's dynamic type information object. The dynamic type information changes as users change the object's properties, events, and methods and write code attached to the object.
Each object has only one dynamic type information object (that is, one ITypeInfo that points to dynamic type information) throughout its lifetime. Although the type information itself changes, the type information object retains its identity.
The ITypeInfo returned by this method must describe a component object class (coclass)(TKIND_COCLASS).
The pdwCookie value is saved by the host to determine whether the newly loaded object has the same type information as when it was last saved. The Save method of the visual designer's persistence interface should set the value of the cookie each time it saves the persistent data. The host checks the cookie when it gets the dynamic type information to see if the type information has changed.
Example
The following example returns a dynamic type information object:
STDMETHODIMP CMyDesigner::GetDynamicClassInfo ( ITypeInfo **ppTypeInfoOut, DWORD *pdwCookie ) { HRESULT hr; if (pdwCookie) *pdwCookie = m_dwTICookie; if (!ppTypeInfoOut) return S_OK; return GetMyDynamicTypeInfo(ppTypeInfoOut); }
The value of pdwCookie is set in the persistence methods for the visual designer. This value should be part of the data you save with the Save method of your persistence interfaces.
The example calls the local function GetMyDynamicTypeInfo, which creates the type information if necessary. You can either load a static type information object and copy it, or call CreateTypeLib2 to create a new type information object in a new format type library. For a detailed explanation, see "Providing Type Information" in Chapter 5, "Type Information and Extended Objects."