1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| function Exemple()
% GUI1 %
fig1 = figure('units','pixels',...
'position',[500 500 200 200],...
'menubar','none',...
'name','fig1',...
'numbertitle','off',...
'Resize','off',...
'color',[0.941 0.941 0.941]);
% EditBox dans GUI1 %
uicontrol(fig1,...
'style','edit',...
'units','normalized',...
'position',[0.350 0.600 0.35 0.185],...
'string','',...
'tag','edit1',...
'backgroundcolor',[1 1 1]);
% Pushbutton dans GUI1 %
uicontrol(fig1,...
'style','pushbutton',...
'units','normalized',...
'position',[0.150 0.100 0.700 0.300],...
'string','Sauvegarde Variable',...
'tag','push1',...
'callback',@Save,...
'backgroundcolor',get(fig1,'color'));
% GUI2 %
fig2 = figure('units','pixels',...
'position',[300 300 200 200],...
'menubar','none',...
'name','fig2',...
'numbertitle','off',...
'Resize','off',...
'color',[0.941 0.941 0.941]);
% EditBox dans GUI2 %
uicontrol(fig2,...
'style','edit',...
'units','normalized',...
'position',[0.350 0.600 0.35 0.185],...
'string','',...
'tag','edit2',...
'backgroundcolor',[1 1 1]);
% Pushbutton dans GUI2 %
uicontrol(fig2,...
'style','pushbutton',...
'units','normalized',...
'position',[0.150 0.100 0.700 0.300],...
'string','Chargement Variable',...
'tag','push2',...
'callback',@Load,...
'backgroundcolor',get(fig2,'color'));
% Stockage handles de fig1 %
handles1 = guihandles(fig1);
guidata(fig1,handles1);
% Stockage handles de fig2 %
handles2 = guihandles(fig2);
guidata(fig2,handles2);
end
function Save(obj,event)
% On definit fig1 comme l objet parent %
fig1 = get(obj,'parent');
% Recuperation des handles de fig1 %
handles1 = guidata(fig1);
% Recuperation VarTest dans son EditBox %
VarTest = get(handles1.edit1,'string');
% Sauvegarde VarTest %
setappdata(0,'VarTest',VarTest);
end
function Load(obj,event)
% On definit fig2 comme l objet parent %
fig2 = get(obj,'parent');
% Recuperation des handles de fig2 %
handles2 = guidata(fig2);
% Recuperation VarTest %
VarTest = getappdata(0,'VarTest');
% Impression VarTest dans son EditBox %
set(handles2.edit2,'string',VarTest);
end |
Partager