2017-06-17 75 views

回答

1

似乎您必須重寫CloseRequestFcn事件處理程序,請參閱here。您不能隱藏或禁用關閉按鈕,但可以確保用戶點擊它不會產生任何影響。

+0

謝謝你的反應,但它沒有任何解決方案。 –

+0

我該怎麼做? –

+0

@MasoudZayyani,方法如下:https://www.mathworks.com/matlabcentral/answers/139854-how-to-change-the-gui-close-function-whithout-changing-the-close-function-of-figures – randomir

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'); 
+0

謝謝,但我應該在哪裏插入第一個代碼?在** CloseRequestFcn **? –

+0

@MasoudZayyani不完全,我會添加另一個選擇,你可以在這裏查看:https://www.mathworks.com/matlabcentral/answers/72650-hide-and-disable-uicontrols-in-groups你不會插入它,你執行它。 –

+0

@MasoudZayyani我更新了答案,我希望能幫助你,別忘了接受答案,如果有幫助的話:) –