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.
  2 个评论
Mathieu
Mathieu 2015-7-8
I mean when the user click with the mouse on the figure, he can deplace this one. For example, deplace the figure from the top of the screen to the bottom. I found how to replace the figure using the ButtonFunction of the GUI but it needs a click of the user on the inside of the figure. So it is not again the final solution.

请先登录,再进行评论。

采纳的回答

Guillaume
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 个评论
Mathieu
Mathieu 2015-7-8
Ok I understand. I am discovering only now the uitab function to do tabs (before I used pushbutton will callback to switch on other windows). But until now I developped my interface with GUIDE so if I use this function (and I think I will), I have to recode all my interface so I will do this later.
Anyway, thank you a lot for your answers both of you. Matlab is so more interesting since I developp interface!

请先登录,再进行评论。

更多回答(1 个)

Lincoln Emilio Bowen Aguayo
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
%
  1 个评论
Mathieu
Mathieu 2015-7-8
编辑:Mathieu 2015-7-8
Thanks for your answer, but in your code, what prevent the modification of the interface? Because using your code the interface can be moved again.
And do you know how to resize the interface to be in full screen? Because it seems to be the case on your image.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by