External Interfaces/API | ![]() ![]() |
Create an ActiveX control in a figure window.
Syntax
h =actxcontrol (progid [, position [, handle ... [,callback |{event1 eventhandler1; ... event2 eventhandler2; ...}]]])
Arguments
progid
String that is the name of the control to create. The control vendor provides this string.
position
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]
.
handle
gcf
.
callback
Returns
A MATLAB activex object that represents the default interface for this control or server. Use the get
, set
, invoke
, propedit
, release
, and delete
methods on this object. A MATLAB error will be generated if this call fails.
Description
Create an ActiveX control at a particular location within a figure window. If the parent figure window is invisible, the control will be invisible. The returned MATLAB activex 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.)
For an example callback event handler, see the file sampev.m
in the toolbox\matlab\winfun
directory.
Example
f = figure ('pos', [100 200 200 200]); % create the control to fill the figure h = actxcontrol ('MWSAMP.MwsampCtrl.1', [0 0 200 200], ... gcf, `sampev')
h = actxcontrol ('SELECTOR.SelectorCtrl.l', ... [0 0 200 200], f, {-600 'myclick'; -601 'my2click'; ... -605 'mymoused'}) h = actxcontrol ('SELECTOR.SelectorCtrl.l', ... [0 0 200 200], f, {'Click' 'myclick'; ... 'DblClick' 'my2click'; 'MouseDown' 'mymoused'})
where the event handlers, myclick.m
, my2click.m
, and mymoused.m
are
function myclick(varargin) disp('Single click function') function my2click(varargin) disp('Double click function') function mymoused(varargin) disp('You have reached the mouse down function') disp('The X position is: ') varargin(5) disp('The Y position is: ') varargin(6)
You can use the same event handler for all the events you want to monitor using the cell array pairs. Response time will be better than using the callback style.
h = actxcontrol('SELECTOR.SelectorCtrl.1', ... [0 0 200 200], f, {'Click' 'allevents'; ... 'DblClick' 'allevents'; 'MouseDown' 'allevents'})
function allevents(varargin) if (varargin{2} = -600) disp ('Single Click Event Fired') elseif (varargin{2} = -601) disp ('Double Click Event Fired') elseif (varargin{2} = -605) disp ('Mousedown Event Fired') end
![]() | ActiveX Client Reference | actxserver | ![]() |