www.pudn.com > DirectX source.zip > Exceptions.cpp


/*! 
	@file : Exceptions.cpp 
	This file contains the implementation of the exception classes 
 
	@author Sarmad Kh. Abdulla 
*/ 
//------------------------------------------------------------------------------ 
 
//////////////////////////////////////////////////////////////////////////////// 
// Headers 
#include "stdafx.h" 
 
 
/*! 
 * Shows a file open error message. The message will be shown in a message box. 
 * 
 * @param hwnd : Handle to the parent window. This handle is used as the parent 
 * of the MessageBox. 
 * 
 * @return void  :  
 */ 
void CFileException::ShowMessage( HWND hwnd ) 
{ 
	char buffer[50]; 
	wsprintf( buffer, "Couldn't open %s", FileName.c_str() ); 
	MessageBox( hwnd, buffer, "error", MB_OK|MB_ICONSTOP ); 
} 
 
 
/*! 
 * Shows an out of memory error message. The message will be shown in a message box. 
 * 
 * @param hwnd : Handle to the parent window. This handle is used as the parent 
 * of the MessageBox. 
 * 
 * @return void  :  
 */ 
void CMemoryException::ShowMessage( HWND hwnd ) 
{ 
	MessageBox( hwnd, "Not enough memory", "error", MB_OK|MB_ICONSTOP ); 
} 
 
 
/*! 
 * Shows a message box containing the custom message entered at the construction 
 * time. 
 * 
 * @param hwnd : Handle to the parent window. This handle is used as the parent 
 * of the MessageBox. 
 * 
 * @return void  :  
 */ 
void CCustomException::ShowMessage( HWND hwnd ) 
{ 
	MessageBox( hwnd, Message.c_str(), "error", MB_OK|MB_ICONSTOP ); 
} 
 
 
/*! 
 * Shows a message box containing the error message along with the error code. 
 * 
 * @param hwnd : Handle to the parent window. This handle is used as the parent 
 * of the MessageBox. 
 * 
 * @return void  :  
 */ 
void CDXException::ShowMessage( HWND hwnd ) 
{ 
	char buffer[500]; 
	wsprintf( buffer, "%s\nError code: %x\nDX error message: %s", Message.c_str(),  
		ErrorCode, DXGetErrorString8( ErrorCode ) ); 
	MessageBox( hwnd, buffer, "error", MB_OK|MB_ICONSTOP ); 
}