Documentation

invoke

Invoke method on COM object or interface, or display methods

Syntax

S = invoke(h)
S = invoke(h,'methodname')
S = invoke(h,'methodname',arg1,arg2,...)
S = invoke(h,'custominterfacename')

Description

S = invoke(h)returns structure array,S, containing a list of all methods supported by the object or interface,h, along with the prototypes for these methods. IfSis empty, either there are no properties or methods in the object, or MATLAB®cannot read the object type library. Refer to the COM vendor documentation.

S = invoke(h,'methodname')invokes the method specified bymethodname, and returns an output value, if any, inS. The data type of the return value depends on the invoked method, which is determined by the control or server.

S = invoke(h,'methodname',arg1,arg2,...)invokes the method specified bymethodnamewith input argumentsarg1,arg2,....

S = invoke(h,'custominterfacename')returns anInterfaceobjectS, which is a handle to a custom interface implemented by the COM component. Thehargument is a handle to the COM object. Thecustominterfacenameargument is returned by theinterfacesfunction.

If the method returns a COM interface, then theinvokefunction returns a new MATLAB COM object that represents the interface returned. For a description of how MATLAB converts COM types, seeHandle COM Data in MATLAB.

COM functions are available on Microsoft®Windows®systems only.

Examples

Invoke theRedrawmethod in themwsampcontrol.

f = figure('position',[100 200 200 200]); h = actxcontrol('mwsamp.mwsampctrl.1',[0 0 200 200],f); h.Radius = 100; invoke(h,'Redraw')

Alternatively, call the method directly.

Redraw(h)

Display allmwsampmethods.

invoke(h)
ans = AboutBox = void AboutBox(handle) Beep = void Beep(handle) FireClickEvent = void FireClickEvent(handle) . .

Getting a Custom Interface Example

Once you have created a COM server, you can query the server component to see if any custom interfaces are implemented. Use theinterfacesfunction to return a list of all available custom interfaces:

h = actxserver('mytestenv.calculator'); customlist = interfaces(h)
customlist = ICalc1 ICalc2 ICalc3

To get a handle to the custom interface you want, use theinvokefunction.

c1 = invoke(h,'ICalc1')
c1 = Interface.Calc_1.0_Type_Library.ICalc_Interface

Use this handle with COM client functions to access the properties and methods of the object through the selected custom interface.

Introduced before R2006a

Was this topic helpful?