User`s guide
Making Multiple GUIs Work Together
disp('------------------------------ ----------------------- ');
disp('Improper input arguments. Pass a property value pair')
disp('whose name is "changeme_m ain" and value is the handle')
disp('to the changeme_main figu re.');
disp('eg:');
disp(' x = changeme_main()');
disp(' changeme_dialog('changeme_main', x)');
disp('------------------------------ ----------------------- ');
else
uiwait(hObject);
end
3 The changeme_dialog_Open ingFcn centers the Text Change dialog box
over the main GUI, using the passed-in handle to that figure. So, if the
main figu re is moved and the d ialog box is invoked, it opens in the same
relative position instead of always in a fixed locatio n.
function change me_d ialog_OpeningFcn(hObjec t, ...
eventdata, ha ndle s, varargin)
.
.
.
mainGuiInput = find(strcmp(varargin, 'changeme_main'));
.
.
.
handles.changeMeMain = varargin {mainGuiInput+1};
.
.
.
% Position to be relative to parent:
parentPosition = getpixelposition(handles.changeMeMain );
currentPosition = get(hObject, 'Position');
% Sets the position to be directly centere d on the main figu re
newX = parentPosition(1) + (parentPosition(3)/2 ...
- currentPositi on(3 )/2);
newY = parentPosition(2) + (parentPosition(4)/2 ...
- currentPositi on(4 )/2);
newW = currentPosition(3);
newH = currentPosition(4);
9-27