MATLAB Function Reference |
Move GUI figure to specified location on screen
Syntax
Description
movegui(h,'
moves the figure identified by handle position
')
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.
movegui('
move the callback figure (position
')
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.
Examples
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');
See Also
"Creating GUIs" in the MATLAB documentation
movefile | movie |
© 1994-2005 The MathWorks, Inc.