matlab学习------------普通dialog对话框,错误对话框errordlg,警告对话框warndlg
Dialog对话框
语法:
h = dialog('PropertyName',PropertyValue,...)
对话框的默认属性
WindowStyle的值: {normal} | modal | docked
详细实例:
out = dialog; %默认显示对话框之后点击对话框中的空白部分对话框会关闭掉
结果:
%普通对话框
out = dialog('WindowStyle', 'normal',...
'Name', '我的Dialog对话框',...
'position',[300 300 400 300]);
uicontrol('parent',out,...
'style','pushbutton',...
'position',[80 40 80 50],...
'string','确定',...
'callback','delete(gcbf)');%回调函数,点击button关闭对话框
结果:(点击button关闭对话框)
错误对话框errordlg
语法:
h = errordlg
h = errordlg(errorstring)
h = errordlg(errorstring,dlgname)
h = errordlg(errorstring,dlgname,createmode)
%createmode取值:non-modal (默认),modal,replace
举例:
h = errordlg('对话框内容','对话框标题','modal')
warndlg警告对话框(跟错误对话框类似)
语法:
h = warndlg
h = warndlg(warningstring)
h = warndlg(warningstring,dlgname)
h = warndlg(warningstring,dlgname,createmode)
举例:
warndlg('Pressing OK will clear memory','!! Warning !!')
结果: