Combines the current moniker with another moniker, creating a new composite moniker.
HRESULT ComposeWith(
IMoniker *pmkRight, //Pointer to moniker to be composed onto this
//one
BOOL fOnlyIfNotGeneric, //Indicates if generic composition
//permissible
IMoniker **ppmkComposite
//Address of output variable that receives
//the IMoniker interface pointer
);
The method supports the standard return values E_OUTOFMEMORY and E_UNEXPECTED, as well as the following:
Joining two monikers together is called composition. Sometimes two monikers of the same class can be combined in what is called non-generic composition. For example, a file moniker representing an incomplete path and another file moniker representing a relative path can be combined to form a single file moniker representing the complete path. Non-generic composition for a given moniker class can be handled only in the implementation of IMoniker::ComposeWith for that moniker class.
Combining two monikers of any class is called generic composition, which can be accomplished through a call to the CreateGenericComposite function.
Composition of monikers is an associative operation. That is, if A, B, and C are monikers, then, where Comp() represents the composition operation:
Comp( Comp( A, B ), C )
is always equal to
Comp( A, Comp( B, C ) )
To combine two monikers, you should call IMoniker::ComposeWith rather than calling the CreateGenericComposite function to give the first moniker a chance to perform a non-generic composition.
An object that provides item monkers to identify its objects would call IMoniker::ComposeWith to provide a moniker that completely identifies the location of the object. This would apply, for example, to a server that supports linking to portions of a document, or a container that supports linking to embedded objects within its documents. In such a situation, you would do the following:
Most callers of IMoniker::ComposeWith should set the fOnlyIfNotGeneric parameter to FALSE.
You can use either non-generic or generic composition to compose the current moniker with the moniker that pmkRight points to. If the class of the moniker indicated by pmkRight is the same as that of the current moniker, it is possible to use the contents of pmkRight to perform a more intelligent non-generic composition.
In writing a new moniker class, you must decide if there are any kinds of monikers, whether of your own class or another class, to which you want to give special treatment. If so, implement IMoniker::ComposeWith to check whether pmkRight is a moniker of the type that should have this treatment. To do this, you can call the moniker's GetClassID method (derived from the IPersist Interface), or, if you have defined a moniker object that supports a custom interface, you can call IUnknown::QueryInterface on the moniker for that interface. An example of special treatment would be the non-generic composition of an absolute file moniker with a relative file moniker. The most common case of a special moniker is the inverse for your moniker class (whatever you return from your implementation of IMoniker::Inverse).
If pmkRight completely negates the receiver so the resulting composite is empty, you should pass back NULL in ppmkComposite and return the status code S_OK.
If the pmkRight parameter is not of a class to which you give special treatment, examine fOnlyIfNotGeneric to determine what to do next. If fOnlyIfNotGeneric is TRUE, pass back NULL through ppmkComposite and return the status code MK_E_NEEDGENERIC. If fOnlyIfNotGeneric is FALSE, call the CreateGenericComposite function to perform the composition generically.
Windows NT: Use version 3.1 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in objidl.h.
CreateGenericComposite, IMoniker::Inverse