User`s guide
8 Programming a GUIDE GUI
% Update handles structure
guidata(hObject, h andles);
% UIWAIT makes mygui wait for user response (see UIRESUME)
% uiwait(handles.m ygui);
Input Arguments
The opening function has four input arguments hObject, eventdata,
handles,andvarargin. The first three are the same as described in “GUIDE
Callback Arguments” on page 8-20. the last argument,
varargin, enables
you to pass arguments from the command line to the opening function. The
opening function can take actions w ith them (for example, setting property
values) and also make the arguments available to callbacks by adding them to
the
handles structure.
For m ore information about using
varargin,seethevarargin reference page
and “Support Variable Number of Inputs”.
Passing Object Properties to an Opening Function. You c an pass a
property name/value pair for any component as two successive command
line arguments and set that value in the opening function. If you are
setting a figure property, GUIDE handles this automatically. For example,
my_gui('Position', [71.8 44.9 74.8 19.7]) opens the GUI at the
specified position, since
Position is a valid figure property (in character
units, the default).
You can define new names for p roperties or combinations of them. For
example, you can make your GUI accept an alias for a figure property as a
convenience to the user. For example, you might want the user to be able to
open the GUI with a
Title argume nt instead of calling it Na me,whichisthe
property that specifies the name on the GUI’s title bar. To do this , you must
provide code in its
OpeningFcn to set theName fi gure proper ty. The following
example illustrates how to do this.
If you pass an input argument that is not a valid figure property, your code
mustrecognizeitsnameandusethename/valuepairtosettheappropriate
property on the correct object. Otherw ise, the argument is ignored. The
following example is from the opening function for the Modal Question Dialog
8-26