| Contents | Index |
movegui(h,'position')
movegui(position)
movegui(h)
movegui
movegui(h,'position') moves the figure identified by handle h to the specified screen location, preserving the figure's size. The position argument is a string or a two-element vector, as defined in the following tables.
movegui(position) moves the callback figure (gcbf) or the current figure (gcf) to the specified position.
movegui(h) moves the figure identified by the handle h to the onscreen position.
movegui moves the callback figure (gcbf) or the current figure (gcf) to the onscreen position. You can specify 'movegui' as a CreateFcn callback for a figure. It ensures after you save it, the figure appears on screen when you reload it, regardless of its saved position. See the following example.
When it is a string, position is one of the following descriptors.
| Position String | Description |
|---|---|
| north | Top center edge of screen |
| south | Bottom center edge of screen |
| east | Right center edge of screen |
| west | Left center edge of screen |
| northeast | Top right corner of screen |
| northwest | Top left corner of screen |
| southeast | Bottom right corner of screen |
| southwest | Bottom left corner |
| center | Centered on screen |
| onscreen | Nearest location to current location that is entirely on screen |
You can also specify the position argument as a two-element vector, [h,v]. Depending on sign, h specifies the figure's offset from the left or right edge of the screen, and v specifies the figure's offset from the top or bottom of the screen, in pixels. The following table summarizes the possible values.
h (for h >= 0) | Offset of left side from left edge of screen |
h (for h < 0) | Offset of right side from right edge of screen |
v (for v >= 0) | Offset of bottom edge from bottom of screen |
v (for v < 0) | Offset of top edge from top of screen |
When you apply movegui to a maximized figure window, the window can shrink in size by a few pixels. On Microsoft Windows platforms, using it to move a maximized window toward the Windows task bar creates a gap on the opposite side of the screen about as wide as the task bar.
GUIDE and openfig call movegui when loading figures to ensure they are visible.
Use movegui to ensure that a saved GUI appears on screen you reload it, regardless of the target computer screen size and resolution. Create a figure that is off the screen, assign movegui as its CreateFcn callback, save it, and then reload the figure.
f = figure('Position',[10000,10000,400,300]);
% The figure does not display because it is created offscreen
set(f,'CreateFcn','movegui')
hgsave(f,'onscreenfig')
close(f)
f2 = hgload('onscreenfig');
% The reloaded figure is now visible
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |