Move or resize control in parent window
V = h.move(position)
V = move(h, position)
V = h.move(position) moves the control to the position specified by the position argument. When you use move with only the handle argument, h, it returns a four-element vector indicating the current position of the control.
The position argument is a four-element vector specifying the position and size of the control in the parent figure window. The elements of the vector are:
[x, y, width, height]
where x and y are offsets, in pixels, from the bottom left corner of the figure window to the same corner of the control, and width and height are the size of the control itself.
This example moves the control:
f = figure('Position', [100 100 200 200]); h = actxcontrol('mwsamp.mwsampctrl.1', [0 0 200 200], f); pos = h.move([50 50 200 200]) pos = 50 50 200 200
The next example resizes the control to always be centered in the figure as you resize the figure window. Start by creating the script resizectrl.m that contains
% Get the new position and size of the figure window fpos = get(gcbo, 'position'); % Resize the control accordingly h.move([0 0 fpos(3) fpos(4)]);
Now execute the following:
f = figure('Position', [100 100 200 200]); h = actxcontrol('mwsamp.mwsampctrl.1', [0 0 200 200]); set(f, 'ResizeFcn', 'resizectrl');
As you resize the figure window, notice that the circle moves so that it is always positioned in the center of the window.