Description
Creates a new McObject of a given type, with an optional name, parent and initial value.
-
Return Type
-
A McObject object.
The new McObject instance.
See McObject.AttachNotifySink for an explaination of Alias-related notify issues. And see SetEnumFilters and GetCategory_NewEnum for Alias-related enumeration issues.
-
Syntax
-
object.Add (varTypeNameOrEnum, [bstrName], [bstrNamespace], [varInitialValue], [varParentIMcObject], [lTagNumber], [varCategoryNameOrID])
The Add Method syntax has these parts: |
| object | An expression evaluating to an object of type McObjects. | | varTypeNameOrEnum | Required. A Variant value. Type of object to create. Can either be a BSTR typename or a long or short mcobjTypeEnum object type
| | bstrName | Optional. A String value. Name of object, or NULL or empty for an unnamed object. This name must be globally unique within its Namespace unless an varParentIMcObject argument is supplied, in which case the name must be unique among the child objects of that object.
| | bstrNamespace | Optional. A String value. Namespace for the object name, or NULL or empty to use the default Namespace (see the Namespace property, and the Item method). Namespaces you use should generally start with McOM.
| | varInitialValue | Optional. A Variant value. An intial value to be assigned to the object. If this is not given, the object is initially empty, unless the varTypeNameOrEnum was that of a type registered with the RegisterInterfaceClassFactory method. In this later case, the interface is created by calling the class factory.
| | varParentIMcObject | Optional. A Variant value. If NULL, then the object is global. Otherwise this is its parent object.
| | lTagNumber | Optional. 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) varParentIMcObject; objects with these tags can be found quickly with the LookupByTagNumber method.
| | varCategoryNameOrID | Optional. A Variant value. Category name or ID (as returned from RegisterCategory). If not empty then this is an initial category in which to make the object a member. Assign to the McObject.Category property to make the object a member of additional categories.
| Remarks
The object may be created as a child object local to some parent McObject. If the object is a child then the name may be the same as other objects within its Namespace with different parents. For object types registered by RegisterInterfaceClassFactory, the interface is created as well.
The mcobjTypeFlagAlias flag can be OR'ed with another mcobjTypeEnum to cause the object being created to be an Alias McObject. Once an Alias-type object is created, you need to assign a Shadow (see below) to its ShadowMcObject property. When you create an Alias object, you should either specify its varTypeNameOrEnum as (mcobjTypeUNKNOWN | mcobjTypeFlagAlias) or as some base type with the mcobjTypeFlagAlias OR'ed in. The latter is preferable, since in this case you get type checking when the ShadowMcObject property is assigned to. For example, an Alias created of type (mcobjTypeXOBJECT | mcobjTypeFlagAlias) then you could only assign as a ShadowMcObject objects of Type mcobjTypeXOBJECT or ones where RegisterType had been derived from mcobjTypeXOBJECT.
An alias object is one that refers to the data held by another Shadow McObject instead of holding any data of its own. An Alias McObject is associated with a particular Shadow by assigning to its ShadowMcObject property. Alias objects expose some of the properties of their current Shadow object as their own. For example, the Alias' Value property reflects the Value of the Shadow McObject, and assignments to the Alias' Value property change the Shadow McObject's Value. The following McObject properties are independently maintained for the Alias
ParentMcObject
|