| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #include "Win32.h"
- static bool errShow = FALSE;
- static LPWSTR GetError()
- {
- DWORD error = GetLastError();
- LPWSTR errorMsg = NULL;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, error, 0, (LPWSTR)&errorMsg, 256, NULL);
- return errorMsg;
- }
- int Err(HWND hwnd, LPCTSTR message)
- {
- if ((!hwnd) && !errShow)
- {
- errShow = TRUE;
- MessageBox(NULL, message, GetError(), MB_ICONERROR);
- errShow = FALSE;
- return 1;
- }
- return 0;
- }
- int Err(ATOM atom, LPCTSTR message)
- {
- if ((!atom) && !errShow)
- {
- errShow = TRUE;
- MessageBox(NULL, message, GetError(), MB_ICONERROR);
- errShow = FALSE;
- return 1;
- }
- return 0;
- }
- int Err(LPCTSTR message)
- {
- if ((GetLastError() != 0) && !errShow)
- {
- errShow = TRUE;
- MessageBox(NULL, message, GetError(), MB_ICONERROR);
- errShow = FALSE;
- return 1;
- }
- return 0;
- }
- void ForceErrCheck(LPCTSTR title)
- {
- MessageBox(NULL, GetError(), title, MB_ICONWARNING);
- }
- int Err(std::ifstream* file, LPCTSTR message)
- {
- if ((!file) && !errShow)
- {
- errShow = TRUE;
- MessageBox(NULL, message, GetError(), MB_ICONERROR);
- errShow = FALSE;
- return 1;
- }
- return 0;
- }
- int Err(std::ofstream* file, LPCTSTR message)
- {
- if ((!file) && !errShow)
- {
- errShow = TRUE;
- MessageBox(NULL, message, GetError(), MB_ICONERROR);
- errShow = FALSE;
- return 1;
- }
- return 0;
- }
|