From: Alex on
Yeah, I was having the same problem for a while.
You can instead use guidata like in their tutorial to pass hObject to the subgui.
hObject is a handle to the current gui, so you can do something like this to avoid calling the OpeningFcn.

What you can do is:

Main gui function:

subgui_handle=subgui; %opens the subgui
subgui_data_handle=guidata(subgui_handle); %points to the handles of the subgui

%now, in the main gui writing
%subgui_data_handle.variable=5;
%is the same as saying
%handles.variable=5; in the subgui. It's very useful for passing data around.

subgui_data_handle.variable='passed to subgui'; %setting random variable in subgui to 'passed to subgui'
subgui_data_handle.main_gui_handle=hObject; %hObject is the handle to the current gui, the main gui in this case.

guidata(subgui_handle, subgui_data_handle); %update subgui's handles

Subgui function:
%Now we're in a subgui function.
handles.variable %without the semicolon it will print out whatever's in handles.variable
%this was set by the main gui.

handles.main_gui_handle %this contains the handle to the main gui, obtained without calling OpeningFcn.
main_gui_data_handle=guidata(handles.main_gui_handle); %get handle to main gui's handles variable

main_gui_data_handle.variable2='passed to main gui'; %passed to main gui's handles.

guidata(main_gui_handle, main_gui_data_handle); %update main_gui's handles
From: Alex on
That's really too long of an explanation, lets shorten it to:

main gui function:
subgui_handle=subgui; %opens the subgui
subgui_data_handle=guidata(subgui_handle); %points to the handles of the subgui
subgui_data_handle.main_gui_handle=hObject; %hObject=handle to main gui
guidata(subgui_handle, subgui_data_handle); %update subgui's handles

subgui function:
%now you want to get the passed variable out of handles
handles.main_gui_handle %this is the handle to the main gui.

So instead of calling
main_gui_handle=main_gui;
like in the tutorial you can send the subgui hObject and get the handle that way.