Open project2 from button

2 views (last 30 days)
Rayane
Rayane on 26 Dec 2013
Commented: Rayane on 27 Dec 2013
Hello
I'm having a problem when loading project2 from button in project1
My issue here is that when project2 opens it doesn't load what was created in the opening function of this project ! it only shows uicontrols created from outside in guide whitout also the changes made on them ...
here's how project2 in opened:
fig = openfig('Project2.fig');
& Those Changes weren't made ;
function Project2_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for Truss
handles.output = hObject;
global h
h=handles;
%--------------Image to Background-----------------------
img=imread('TrussMain.jpg');
[M, N, C]=size(img);
hAxes=axes;
hfigure=handles.figure1;
set(hfigure,'units','pixels','Position',[100 100 N M],'numbertitle','off');
set(hAxes,'units','pixels','Position',[1 1 N M],'box','off','tickdir','out','XLimMode','manual','XLim',[1 N],'YLimMode','manual','YLim',[1 M],'ydir','reverse');
hAxes=image(img);
%--------------Objects-----------------------
set(h.a2,'Position',[30,10,150,30]);
set(h.pp1,'Position',[195,36,10,6]);
set(h.t1,'Position',[170,39.5,25,2]);
Thank you in advance

Accepted Answer

Walter Roberson
Walter Roberson on 26 Dec 2013
When you have a figure created with GUIDE, you need to run the function that has the same name as the fig. In this case, it would be Project2(). Note that this will go through the whole singleton control and will create its own version of "handles", so you need to keep track of which "handles" you are using.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!