Prevent the movement of a figure with GUIDE
8 次查看(过去 30 天)
显示 更早的评论
Hello,
I am working with Matlab R2015a and use GUIDE to create my interface. When I launch my interface, a general figure contains buttons, text boxes, etc. What I wish is to prevent the movement of this general figure. Why? Because by clicking on a pushbutton, I can switch into another general figure (as if it was 2 tabs of a same figure). And I don't want any user move this general figure.
Thank you for your help. Best regards.
采纳的回答
Guillaume
2015-7-8
If you mean to prevent the user from moving the whole figure window, that cannot be done in matlab. I'm not even sure you could do it by accessing the underlying java window.
The moving of the window is handled by the OS itself, so you would have to intercept the WM_MOVE event to stop the window from moving. Matlab does not give you access to that.
In any case, it's a very bad idea to prevent the user from moving windows. You should never try to prevent the user from doing things that are naturally expected to work, like moving windows. The end result is usually that the user gets fed up by unexpected behaviour and either try to defeat your restrictions or give up using your program.
To solve your problem, you only use one figure window and either have a uitabgroup with two tabs, or two uipanels whose visibility you toggle. The user can then move the figure window where they want without affecting any of your drawing.
更多回答(1 个)
Lincoln Emilio Bowen Aguayo
2015-7-8
In this way you can make a GUI, and the user cannot modify your interface:
function tabbedGUI()
hFig = figure('Menubar','none', 'Position', [25 50 1250 550]);
set (gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
s = warning('off', 'MATLAB:uitabgroup:OldVersion');
hTabGroup = uitabgroup('Parent',hFig);
warning(s);
hTabs(1) = uitab('Parent',hTabGroup, 'Title','Opcion 1');
hTabs(2) = uitab('Parent',hTabGroup, 'Title','Opción 2');
set(hTabGroup, 'SelectedTab',hTabs(1));
uicontrol ('Style', 'pushbutton',...
'String', 'Compute',...
'BackgroundColor', [.5 .5 .5],...
'Position', [500 500 100 50],...
'Callback', @ComputeCallback,...
'Parent', hTabs(1));
function ComputeCallback (src, evt)
end
end
%
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!