| MATLAB® | ![]() |
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 can be any of the following strings:
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 – center of screen
onscreen – nearest location with respect to current location that is on screen
The position argument can also be a two-element vector [h,v], where 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 |
movegui('position') move 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. This is useful as a string-based CreateFcn callback for a saved figure. It ensures the figure appears on screen when reloaded, regardless of its saved position.
This example demonstrates the usefulness of movegui to ensure that saved GUIs appear on screen when reloaded, regardless of the target computer's screen sizes and resolution. It creates a figure off the screen, assigns movegui as its CreateFcn callback, then saves and reloads the figure.
f = figure('Position',[10000,10000,400,300]);
set(f,'CreateFcn','movegui')
hgsave(f,'onscreenfig')
close(f)
f2 = hgload('onscreenfig');
"Creating GUIs" in the MATLAB documentation
![]() | movefile | movie | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |