网站首页  词典首页

请输入您要查询的计算机术语:

 

术语 CException::ReportError
释义 CException::ReportError

virtual int ReportError(UINT nType = MB_OK, UINT nMessageID = 0);

返回值:
一个AfxMessage值。如果没有足够的内存来显示消息框,则返回0。请参阅AfxMessageBox,了解可能的返回值。

参数:
nType指定消息框的风格。把消息框风格应用在框上。如果不指定此参数,缺省为MB_OK。
nMessageID如果异常对象没有错误消息,指定要显示的消息资源的ID(字符串表入口)。如果为0,显示“没有可用的错误消息”。

说明:
调用此成员函数在消息框中向用户报告出错文本。

示例:
以下是一个使用此函数的例子:
CFile fileInput;
CFileException ex;

// try to open a file for reading.
// The file will certainly not
// exist because there are too many explicit
// directories in the name.

// if the call to Open() fails, ex will be
// initialized with exception
// information. the call to ex.ReportError() will
// display an appropriate
// error message to the user, such as
// "\\Too\\Many\\Bad\\Dirs.DAT contains an
// invalid path." The error message text will be
// appropriate for the
// file name and error condition.

if (!fileInput.Open("\\\\Too\\\\Many\\\\Bad\\\\Dirs.DAT", CFile::modeRead, &ex))
{
   ex.ReportError();
}
else
{
   // the file was opened, so do whatever work
   // with fileInput we were planning...
   // :

   fileInput.Close();
}

请参阅:AfxMessageBox, CException::GetErrorMessage
随便看

 

MFC类库中文详解手册包含4274条MFC类库参考词条,基本涵盖了Microsoft基本类库中的类、全局函数、全局变量和宏的内容,是计算机编程的有利工具。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 12:21:21