HRESULT WINAPI DXTraceA(const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox) { char msg[1024]; if (bPopMsgBox) { snprintf(msg, sizeof(msg), "File: %s\nLine: %d\nError Code: %s (0x%08x)\nCalling: %s", strFile, dwLine, DXGetErrorString8A(hr), hr, strMsg); MessageBoxA(0, msg, "Unexpected error encountered", MB_OK|MB_ICONERROR); } else { snprintf(msg, sizeof(msg), "%s(%d): %s (hr=%s (0x%08x))", strFile, dwLine, strMsg, DXGetErrorString8A(hr), hr); OutputDebugStringA(msg); } return hr; }
//! Create a dialog box and tell the user what went wrong bool DisplayError(LPSTR lpstrErr, HRESULT hres) { static bool InError = false; int retval = 0; if (!InError) { InError = true; #ifdef DDSCAPS_PRIMARYSURFACELEFT const char *message = hres?DXGetErrorString8A(hres):0; #else char message[256]; if(hres) D3DXGetErrorString(hres, 256, message); #endif retval = MessageBoxA(g_hAppWnd, lpstrErr, hres?message:"Error!", MB_OK|MB_ICONERROR); InError = false; } return false; }