MATLAB: Confused: GUI / figure /

currentfigureguiMATLAB

I have a GUIDE-built GUI I start from another script file, using the following to try to understand some things:
gui = fp_main_gui() % Start GUI, returning handle
h = figure(gui) % Set current figure
curfig = get(0,'CurrentFigure') % What is current figure?
produces
gui =
173.0125
h =
173.0125
curfig =
[]
The output of the first two lines is what I'd expect, but the third seems to indicate that the GUI figure has not been set as the current figure. Is there some difference between GUI figures and figures created with the "figure" function. I must be missing a conceptual point.
(Also I notice that a reference to "gcf" after the above always creates a new figure, which seems to imply that the GUI figure can not be the CurrentFigure.)
Thanks

Best Answer

The reason why the third attempt doesn't find the GUI is that GUIDE GUIs have their figure handle visibility set to 'callback' so it is not seen except by its callbacks (and FINDALL). You can change this by:
set(gui,'handlevisib','on')
get(0,'currentfig') % Now it shows up!