This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Move or resize control in parent window


V = move(h,position)


V = move(h,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 = move(h,[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
  move(h,[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]);

As you resize the figure window, notice that the circle moves so that it is always positioned in the center of the window.

See Also


Introduced before R2006a

Was this topic helpful?