Fork me on GitHub

matlab GUI之常用对话框(三)-- dialog \ errordlg \ warndlg \ helpdlg \ msgbox \questdlg

常用的对话框(三)

1.普通对话框  dialog

调用格式:

  h=dialog('PropertyName','PropertyValue'......)

1 %普通对话框  
2 h=dialog('name','关于...','position',[200 200 200 70]);  
3 uicontrol('parent',h,'style','text','string','你好!','position',[50 40 120 20],'fontsize',12);  
4 uicontrol('parent',h,'style','pushbutton','position',...  
5    [80 10 50 20],'string','确定','callback','delete(gcbf)');  

 

2.错误对话框 errordlg

调用格式:

  h = errordlg
  h = errordlg(errorstring)
  h = errordlg(errorstring,dlgname)
  h = errordlg(errorstring,dlgname,createmode)

errordlg函数-->2 axes对象和1 pushbutton对象-->axes子对象有image对象和text对象

1 %错误对话框  
2 h=errordlg('警告','错误');  
3 ha=get(h,'children');  
4 
5 hu=findall(allchild(h),'style','pushbutton');  
6 set(hu,'string','确定');  
7 ht=findall(ha,'type','text');  
8 set(ht,'fontsize',20,'fontname','隶书');  

 

3.警告对话框

调用格式:

  h = warndlg
  h = warndlg(warningstring)
  h = warndlg(warningstring,dlgname)
  h = warndlg(warningstring,dlgname,createmode)

1 %警告对话框  
2 h=warndlg('内存不足','警告','modal');  

 

4.帮助对话框 warndlg

调用格式:

  helpdlg
  helpdlg('helpstring')
  helpdlg('helpstring','dlgname')
  h = helpdlg(...)

1 %帮助对话框  
2 helpdlg('双击对象进入编辑状态','提示');  

 

5.信息对话框 msgbox

调用格式:

  h = msgbox(Message) 
  h = msgbox(Message,Title) 
  h = msgbox(Message,Title,Icon) 
  h = msgbox(Message,Title,'custom',IconData,IconCMap) 
  h = msgbox(...,CreateMode

Icon中有‘error’、‘warn’、‘help’、‘custom’


CreateMode中有 modal   non-modal(Default) replace

1 %信息对话框  
2 msgbox('中日钓鱼岛之争愈演愈烈!','每日新闻','warn');  

 

6.提问对话框 questdlg

调用格式:

  button = questdlg('qstring')
  button = questdlg('qstring','title') 
  button = questdlg('qstring','title',default)
  button = questdlg('qstring','title','str1','str2',default) %两个按钮
  button = questdlg('qstring','title','str1','str2','str3',default) %三个按钮
  button = questdlg('qstring','title', ..., options)

1 %提问对话框  
2 questdlg('今天你学习了吗?','问题提示','Yes','No','Yes');  
posted @ 2016-06-08 15:44  wangduo  阅读(4785)  评论(0编辑  收藏  举报