次の方法で共有


CException::ReportError

ユーザーにメッセージ ボックスにエラー テキストを報告するには、このメンバー関数を呼び出します。

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

パラメーター

  • nType
    メッセージ ボックスのスタイルを指定します。ボックスに メッセージ ボックス スタイル の組み合わせを適用します。このパラメーターを指定しない場合、既定値は MB_OKです。

  • nMessageID
    例外オブジェクトにエラー メッセージがあるメッセージのリソース id (ストリング テーブルのエントリ) を表示するように指定します。0 は、「エラー メッセージ」が使用可能ではない表示されます。

戻り値

の値 AfxMessageBox ; はメッセージ ボックスを表示する十分なメモリがない場合は 0。可能な戻り値については、AfxMessageBox を参照してください。

使用例

CException::ReportErrorの使用例を次に示します。別の例については、catchの例を参照してください。

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(_T("\\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();
}

必要条件

ヘッダー : afx.h

参照

関連項目

CException クラス

階層図

AfxMessageBox

CFileException::GetErrorMessage