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');  
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值