External Interfaces/API Reference |
Create a COM control in a figure window
Syntax
h = actxcontrol (progid [, position [, fig_handle ... [, callback | {event1 eventhandler1; event2 eventhandler2; ...} [, filename]]]])
Arguments
progid
String that is the name of the control to create. The control vendor provides this string.
position
Position vector containing the x
and y
location and the xsize
and ysize
of the control, expressed in pixel units as [x y xsize ysize]
. Defaults to [20 20 60 60]
.
fig_handle
Handle Graphics handle of the figure window in which the control is to be created. If the control should be invisible, use the handle of an invisible figure window. Defaults to gcf
.
callback
Name of an M-function that accepts a variable number of arguments. This function will be called whenever the control triggers an event. Each argument is converted to a MATLAB string. See the section, Writing Event Handlers in the External Interfaces documentation for more information on handling control events.
event
Triggered event specified by either number or name.
eventhandler
Name of an M-function that accepts a variable number of arguments. This function will be called whenever the control triggers the event associated with it. See Writing Event Handlers in the External Interfaces documentation for more information on handling control events.
filename
The name of a file to which a previously created control has been saved. When you specify filename
, MATLAB creates a new control using the position
, handle
, and event/eventhandler
arguments, and then initializes the control from the specified file. The progid
argument in actxcontrol
must match the progid
of the saved control.
Description
Create a COM control at a particular location within a figure window. If the parent figure window is invisible, the control will be invisible. The returned COM object represents the default interface for the control. This interface must be released through a call to release
when it is no longer needed to free the memory and resources used by the interface. Note that releasing the interface does not delete the control itself (use the delete
command to delete the control.)
The strings specified in the callback
, event
, and eventhandler
arguments are not case sensitive.
For an example callback event handler, see the file sampev.m
in the toolbox\matlab\winfun\comcli
directory.
Basic Control Methods
Create a control that runs Microsoft's Calendar application:
f = figure('pos',[300 300 500 500]); cal = actxcontrol('mscal.calendar', [0 0 500 500], f) cal = COM.mscal.calendar
Call the get
method on cal
to list all properties of the Calendar:
get(cal) BackColor: 2.1475e+009 Day: 23 DayFont: [1x1 Interface.mscal.calendar.DayFont] Value: '8/20/2001' . .
Read just one property to record today's date:
Set the Day
property to a new value:
Calling invoke
with no arguments lists all available methods:
meth = invoke(cal) meth = NextDay: 'HRESULT NextDay(handle)' NextMonth: 'HRESULT NextMonth(handle)' NextWeek: 'HRESULT NextWeek(handle)' NextYear: 'HRESULT NextYear(handle)' . .
Invoke the NextWeek
method to advance the current date by one week:
Call events
to list all Calendar events that can be triggered:
events(cal) ans = Click = void Click() DblClick = void DblClick() KeyDown = void KeyDown(int16 KeyCode, int16 Shift) KeyPress = void KeyPress(int16 KeyAscii) KeyUp = void KeyUp(int16 KeyCode, int16 Shift) BeforeUpdate = void BeforeUpdate(int16 Cancel) AfterUpdate = void AfterUpdate() NewMonth = void NewMonth() NewYear = void NewYear()
Set Up Event Handling
See the section, Sample Event Handlers in the External Interfaces documentation for examples of event handler functions and how to register them with MATLAB.
See Also
actxserver
, release
, delete
, save
, load
COM Functions | actxserver |