Commit dae10882 authored by cutealien's avatar cutealien

Add ReportLastWinApiError to Win32 device to make internal debugging easier.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3049 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f0752acd
......@@ -1185,6 +1185,43 @@ bool CIrrDeviceWin32::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &bright
}
// shows last error in a messagebox to help internal debugging.
void CIrrDeviceWin32::ReportLastWinApiError()
{
// (based on code from ovidiucucu from http://www.codeguru.com/forum/showthread.php?t=318721)
LPCTSTR pszCaption = "Windows SDK Error Report";
DWORD dwError = GetLastError();
if(NOERROR == dwError)
{
MessageBox(NULL, "No error", pszCaption, MB_OK);
}
else
{
const DWORD dwFormatControl = FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM;
LPVOID pTextBuffer = NULL;
DWORD dwCount = FormatMessage(dwFormatControl,
NULL,
dwError,
0,
(LPTSTR) &pTextBuffer,
0,
NULL);
if(0 != dwCount)
{
MessageBox(NULL, (LPCSTR)pTextBuffer, pszCaption, MB_OK|MB_ICONERROR);
LocalFree(pTextBuffer);
}
else
{
MessageBox(NULL, "Unknown error", pszCaption, MB_OK|MB_ICONERROR);
}
}
}
} // end namespace
#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_
......
......@@ -104,6 +104,10 @@ namespace irr
//! switchs to fullscreen
bool switchToFullScreen(bool reset=false);
//! Check for and show last Windows API error to help internal debugging.
//! Does call GetLastError and on errors formats the errortext and displays it in a messagebox.
static void ReportLastWinApiError();
//! Implementation of the win32 cursor control
class CCursorControl : public gui::ICursorControl
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment