Description

Associates an object “Auto Add” with a particular McObject category.

Return Type

An ULong object.  

An identifier ("Cookie") for this attach.

Syntax

object.AttachAutoAddToCategory (varCategoryNameOrID, varTypeNameOrEnum, bstrName, [lTagNumber], [varParentTypeNameOrEnum], [eControlFlags])

The AttachAutoAddToCategory Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McObjects.
varCategoryNameOrIDRequired. A Variant value.

Category to auto create for (see RegisterCategory). ID can be NULL for the global category.

varTypeNameOrEnumRequired. A Variant value.

The type name or type enum to attach. If an interface is to be automatically instantiated as the object's data, then this type must have previously been registered with a call to RegisterInterfaceClassFactory.

bstrNameRequired. A String value.

Name to be given to the automatically created object. This name must not conflict any existing name in its namespace. Unless the name is supplied using the “::” syntax (e.g., “MyNamespace::MyAutoObjectName”), the namespace used is the current default Namespace of this instance of the McObjects ("McOM" unless the Namespace property has been changed).

lTagNumberOptional. A Long value.

An initial TagNumber property to assign to the object. If this number is positive, it must unique for all objects with the same (or no) ParentMcObject; objects with these tags can be found quickly with the LookupByTagNumber method.

varParentTypeNameOrEnumOptional. A Variant value.

If given, this is the Type of the varParentIMcObject (or one of its ancestors, see eControlFlags, below) expected for the GetCategoryItem call. It can either be a BSTR typename or a long or short mcobjTypeEnum object type, including types returned by RegisterInterfaceClassFactory.

eControlFlagsOptional. A mcobjAttachAutoAddToCategoryFlags enumeration, as described in settings.

These flags govern how a given varParentTypeNameOrEnum is used to determine the acceptable GetCategoryItem varParentIMcObject arguments for a successful auto Add. Also, you can prohibit the creation of global objects with the mcobjAATC_GlobalIsIllegal flag.

Settings

The settings for eControlFlags are:

ConstantValueDescription
 mcobjAATC_Default0

Default flags. If a varParentTypeOrEnum is given, then the GetCategoryItem call must have a varParentIMcObject of that type, or no parent, for the auto add to succeed. In any case, a missing varParentIMcObject to the GetCategoryItem call is allowed, resulting in the creation of a global object.

 mcobjAATC_ParentTypeCanBeAncestor1

If a varParentTypeOrEnum is given, then the GetCategoryItem call will succeed if a varParentIMcObject is supplied with some ancestor of that type.

 mcobjAATC_TypeIsParentsParent2

If a varParentTypeOrEnum is given, then the GetCategoryItem call will succeed only if the ParentIMcObject of a varParentIMcObject is of that type.

 mcobjAATC_GlobalIsIllegal4

The GetCategoryItem call will succeed only if a non-empty varParentIMcObject is supplied. Otherwise an empty varParentIMcObject to the GetCategoryItem will result in creation of a global McObject.

Remarks

Sets up to automatically create and add to the McObjects collection an McObject with a given name and type when a GetCategoryItem call is made and no object with the given name (and appropriate parent object) already exists. If the object type (varTypeNameOrEnum argument) is one from a previous call to RegisterInterfaceClassFactory, then when the new object is Added to the collection, its associated class factory will be fired to instantiate an enclosed interface.