#include "stdhdr.h"
#include "Debug.h"
static TCHAR szErrorBuf[512], szMessage[256];
void DisplayError(LPCTSTR szFile, int nLine, LPCTSTR lpMessage)
{
wsprintf(szErrorBuf, _T("%s (%d): %s"),
szFile, nLine, lpMessage);
#ifdef _DEBUG
OutputDebugString(szErrorBuf);
#endif
MessageBox(NULL, szErrorBuf, _T("Error"), MB_OK);
}
void DisplayError(LPCTSTR szFile, int nLine, HRESULT hResult, LPCTSTR lpMessage)
{
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, hResult, 0, szMessage,
sizeof(szMessage) / sizeof(TCHAR), NULL);
wsprintf(szErrorBuf, _T("%s (%d): %s\nError code 0x%08X: %s"),
szFile, nLine, lpMessage, hResult, szMessage);
#ifdef _DEBUG
OutputDebugString(szErrorBuf);
#endif
MessageBox(NULL, szErrorBuf, _T("Error"), MB_OK);
}
void Trace(LPCTSTR lpFormat, ...)
{
va_list ap;
va_start(ap, lpFormat);
wvsprintf(szErrorBuf, lpFormat, ap);
va_end(ap);
OutputDebugString(szErrorBuf);
}