Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

COM Collections

COM collections are a way to support groups of related COM objects that can be iterated over. A collection is itself an interface with a read-only Count property and an Item method to retrieve a single item from the collection.

The Item method is indexed, which means that it requires an argument that specifies which item in the collection is being requested. The data type of the index is a data type specified by the control or server that supports the collection. Although integer indices are common, the index could also be a text value. Often, the return value from the Item method is itself an interface. Like all interfaces, release this interface when you are finished with it.

This example iterates through the members of a collection. Each member of the collection is itself an interface (called Plot and represented by a MATLAB® COM object called hPlot). In particular, this example iterates through a collection of Plot interfaces, invokes the Redraw method for each interface, and then releases each interface:

hCollection = hControl.Plots;
for i = 1:hCollection.Count
   hPlot = invoke(hCollection,'Item', i);
   Redraw(hPlot)
   release(hPlot);
end;
release(hCollection);
Was this topic helpful?