Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Contents

Getting Started with COM

Introduction to COM

A COM client is a program that manipulates COM objects. These objects can run in the MATLAB® application or can be part of another application that exposes its objects as a programmatic interface to the application.

This section provides examples that show how to use MATLAB as a COM client.

    Note:   You can also access MATLAB as an Automation server from other applications, such as those written in the Microsoft® Visual Basic® programming language. For information on this technique, see MATLAB COM Automation Server Interface.

Basic COM Functions

To start using COM objects, you need to create the object and get information about it. This section covers the following topics:

Creating an Instance of a COM Object

Two MATLAB functions enable you to create COM objects:

  • actxcontrol — Creates an instance of a control in a MATLAB figure.

  • actxserver — Creates and manipulates objects from MATLAB that are exposed in an application that supports Automation.

Each function returns a handle to the object's main interface, which you use to access the object's methods, properties, and events, and any other interfaces it provides.

Getting Information About a Particular COM Control

In general, you can determine what you can do with an object using the methods, get, and events functions.

Information about Methods.  To list the methods supported by the object handle, type:

handle.methods

Information about Properties.  To list the properties of the object handle, type:

get(handle)

To see the value of the property PropertyName, type:

get(handle,'PropertyName')

Use set to change a property value.

Information about Events.  To list the events supported by the object handle, type:

handle.events

For more information on calling syntax, see Getting Interfaces to COM Object and Invoking Methods on an Object. For more information on events, see Use Events.

Getting an Object's ProgID

To get the programmatic identifier (ProgID) of a COM control that is already registered on your computer, use the actxcontrollist command. You can also use the ActiveX Control Selector, displayed with the command actxcontrolselect. This interface lets you see instances of the controls installed on your computer.

For more information on using these commands, see Creating an ActiveX Control.

Registering a Custom Control

If your MATLAB program uses a custom control (e.g., one that you have created especially for your application), you must register it with the Microsoft Windows® operating system before you can use it. You can do this from your MATLAB program by issuing an operating system command:

!regsvr32 /s filename.ocx

where filename is the name of the file containing the control. Using this command in your program enables you to provide custom-made controls that you make available to other users by registering the control on their computer when they run your MATLAB program. You might also want to supply versions of a Microsoft ActiveX® control to ensure that all users have the same version.

For more information about registration, see Registering Controls and Servers.

Was this topic helpful?