CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

DoModal()函数的功能

楼主tans75(品味人生)2005-06-30 15:08:04 在 VC/MFC / 基础类 提问

帮忙回答一下,好吗?具体点。 问题点数:20、回复次数:4Top

1 楼bigelm(枯燥着快乐着)回复于 2005-06-30 15:12:40 得分 0

CDialog::DoModal    
  virtual   int   DoModal(   );  
   
  Return   Value  
   
  An   int   value   that   specifies   the   value   of   the   nResult   parameter   that   was   passed   to   the   CDialog::EndDialog   member   function,   which   is   used   to   close   the   dialog   box.   The   return   value   is   –1   if   the   function   could   not   create   the   dialog   box,   or   IDABORT   if   some   other   error   occurred.  
   
  Remarks  
   
  Call   this   member   function   to   invoke   the   modal   dialog   box   and   return   the   dialog-box   result   when   done.   This   member   function   handles   all   interaction   with   the   user   while   the   dialog   box   is   active.   This   is   what   makes   the   dialog   box   modal;   that   is,   the   user   cannot   interact   with   other   windows   until   the   dialog   box   is   closed.  
   
  If   the   user   clicks   one   of   the   pushbuttons   in   the   dialog   box,   such   as   OK   or   Cancel,   a   message-handler   member   function,   such   as   OnOK   or   OnCancel,   is   called   to   attempt   to   close   the   dialog   box.   The   default   OnOK   member   function   will   validate   and   update   the   dialog-box   data   and   close   the   dialog   box   with   result   IDOK,   and   the   default   OnCancel   member   function   will   close   the   dialog   box   with   result   IDCANCEL   without   validating   or   updating   the   dialog-box   data.   You   can   override   these   message-handler   functions   to   alter   their   behavior.  
   
  Note       PreTranslateMessage   is   now   called   for   modal   dialog   box   message   processing.  
   
  Example  
   
  void   CTstApp::OnAppAbout()  
  {  
        //   Construct   the   dialog   box   passing   the    
        //   ID   of   the   dialog   template   resource  
        CDialog   aboutDlg(IDD_ABOUTBOX);  
   
        //   Create   and   show   the   dialog   box  
        int   nRet   =   -1;  
        nRet   =   aboutDlg.DoModal();  
   
        //   Handle   the   return   value   from   DoModal  
        switch   (   nRet   )  
        {  
        case   -1:    
              AfxMessageBox("Dialog   box   could   not   be   created!");  
              break;  
        case   IDABORT:  
              //   Do   something  
              break;  
        case   IDOK:  
              //   Do   something  
              break;  
        case   IDCANCEL:  
              //   Do   something  
              break;  
        default:  
              //   Do   something  
              break;  
        };  
  }  
   
  够详细吗?Top

2 楼tans75(品味人生)回复于 2005-06-30 15:21:46 得分 0

怎么全是E文,看不懂呀!Top

3 楼hxue1981(雨山)回复于 2005-06-30 15:21:46 得分 5

顾名思义:DO     Modal  
  让对话框模式生效。主要还是用它来弹出一个对话框!  
  如CMyDialog   dlg;  
        dlg.DoModal();//弹出CMyDialog类定义的对话框Top

4 楼qrlvls( 空 气 )回复于 2005-06-30 15:31:11 得分 15

DoModal   实际上实现了对话框的创建、显示、关闭的全过程,实际上是一个函数中完成的  
  而且   DoModal   生成的是一个模态的对话框  
  DoModal   在一个函数中完成所有这些功能实际上依赖于它所伪造的一个消息循环   RunModalLoop  
  如果有举的话可以参照   MFC   的源代码Top

相关问题

  • delphi函数功能介绍?
  • 求教:IsDate类似功能函数
  • 请问assert函数的用法,功能。
  • 虚函数主要功能是什么?
  • JSP 中有没有函数的功能?
  • CIRQUEUE是什么功能的函数啊?
  • memset()函数实现什么功能?
  • 有无此功能的函数?
  • 讲解sprintf函数的功能
  • 那个函数有这样的功能?

关键词

  • 函数
  • domodal
  • dialog box
  • 对话框
  • modal
  • dialog
  • member function
  • box
  • close
  • result

得分解答快速导航

  • 帖主:tans75
  • hxue1981
  • qrlvls

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo