答案 0 :(得分:1)
好像你必须覆盖CloseRequestFcn
事件处理程序,请参阅here。您无法隐藏或禁用关闭按钮,但您可以确保用户点击它不会产生任何影响。
答案 1 :(得分:1)
这样你可以禁用所有:
set( findall(handles.your_uipanel, '-property', 'Enable'), 'Enable', 'off')
但只禁用关闭的一个:
function closeRequestDemo
figHdl = dialog('Name','Close Request Demo',...
'CloseRequestFcn',@cmdClose_Callback);...dialog creates a nice stripped down figure
uicontrol('Parent',figHdl,...
'String','Close',...
'Callback',@cmdClose_Callback);
function cmdClose_Callback(hObject,varargin)
disp(['Close Request coming from: ',get(hObject,'Type')]);
%do cleanup here
delete(figHdl);
end %cmdClose_Callback
end %closeRequestDemo
来源https://www.mathworks.com/matlabcentral/newsreader/view_thread/290049
另一种方式是:
% Get all the handles to everything we want to set in a single array.
handleArray = [handles.editText, handles.pushbutton, handles.listbox];
% Set them all disabled.
set(handlesArray, 'Enable', 'off');
答案 2 :(得分:1)
您可以通过输入以下内容来替换其功能:
set(fig_obj,'CloseRequestFcn','code to execute')
在我的例子中,我将其替换为:
set(fig_obj,'CloseRequestFcn','set(fig_obj,"Visible","off");');
您可以在此处找到更多相关信息:
https://www.mathworks.com/help/matlab/ref/matlab.ui.figure-properties.html#buiwuyk-1-CloseRequestFcn