errCheck.cpp 782 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "Win32.h"
  2. #include "ID.h"
  3. int Err(HWND hwnd, LPCTSTR title, LPCTSTR message)
  4. {
  5. if (!hwnd)
  6. {
  7. MessageBox(NULL, message, title, MB_ICONERROR);
  8. return 1;
  9. }
  10. return 0;
  11. }
  12. int Err(ATOM atom, LPCTSTR title, LPCTSTR message)
  13. {
  14. if (!atom)
  15. {
  16. MessageBox(NULL, message, title, MB_ICONERROR);
  17. return 1;
  18. }
  19. return 0;
  20. }
  21. int Err(LPCTSTR title, LPCTSTR message)
  22. {
  23. if (GetLastError() != 0)
  24. {
  25. DWORD error = GetLastError();
  26. LPWSTR errorMsg = (LPWSTR)"unknown";
  27. FormatMessage(
  28. FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  29. NULL, error, 0, errorMsg, 256, NULL);
  30. MessageBox(NULL, message, errorMsg, MB_ICONERROR);
  31. return 1;
  32. }
  33. return 0;
  34. }