MATLAB: How to set default properties when adding uicontrols to the GUI in GUIDE in MATLAB 7.7 (R2008b)

MATLAB

When creating GUIs I am used to using the same default properties for my uicontrol (like units, background color, foreground color, horizontal alignment). What I would like is to have those properties already defined when I add my uicontrol, i.e. change the default properties of uicontrols in GUIDE.

Best Answer

The ability to change default properties of uicontrols in GUIDE is not available in MATLAB 7.7 (R2008b).
The only workaround is to create a function that sets the properties for each object and call that function in the GUI program file. For example:
1. Create a function that takes gui handles in a structure as input.
2. Inside this function, create a loop that will set each property of each object depending on your default preferences for each style of uicontrol.
3. In the Opening Function of your gui, call this function passing to it the handles of you gui.
This will not allow you to have your default preferencies when you are creating the uicontrol but this will allow to not worry about the properties of each uicontrol you create and have these properties set when executing the gui.