Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.1 KiB

  1. //=--------------------------------------------------------------------------=
  2. // Debug.Cpp
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995-1996 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // contains various methods that will only really see any use in DEBUG builds
  13. //
  14. #ifdef DEBUG
  15. #include "IPServer.H"
  16. #include <stdlib.h>
  17. //=--------------------------------------------------------------------------=
  18. // Private Constants
  19. //---------------------------------------------------------------------------=
  20. //
  21. static const char szFormat[] = "%s\nFile %s, Line %d";
  22. static const char szFormat2[] = "%s\n%s\nFile %s, Line %d";
  23. #define _SERVERNAME_ "ActiveX Framework"
  24. static const char szTitle[] = _SERVERNAME_ " Assertion (Abort = UAE, Retry = INT 3, Ignore = Continue)";
  25. //=--------------------------------------------------------------------------=
  26. // Local functions
  27. //=--------------------------------------------------------------------------=
  28. int NEAR _IdMsgBox(LPSTR pszText, LPCSTR pszTitle, UINT mbFlags);
  29. //=--------------------------------------------------------------------------=
  30. // DisplayAssert
  31. //=--------------------------------------------------------------------------=
  32. // Display an assert message box with the given pszMsg, pszAssert, source
  33. // file name, and line number. The resulting message box has Abort, Retry,
  34. // Ignore buttons with Abort as the default. Abort does a FatalAppExit;
  35. // Retry does an int 3 then returns; Ignore just returns.
  36. //
  37. VOID DisplayAssert
  38. (
  39. LPSTR pszMsg,
  40. LPSTR pszAssert,
  41. LPSTR pszFile,
  42. UINT line
  43. )
  44. {
  45. char szMsg[250];
  46. LPSTR lpszText;
  47. lpszText = pszMsg; // Assume no file & line # info
  48. // If C file assert, where you've got a file name and a line #
  49. //
  50. if (pszFile) {
  51. // Then format the assert nicely
  52. //
  53. wsprintf(szMsg, szFormat, (pszMsg&&*pszMsg) ? pszMsg : pszAssert, pszFile, line);
  54. lpszText = szMsg;
  55. }
  56. // Put up a dialog box
  57. //
  58. switch (_IdMsgBox(lpszText, szTitle, MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SYSTEMMODAL)) {
  59. case IDABORT:
  60. FatalAppExit(0, lpszText);
  61. return;
  62. case IDRETRY:
  63. // call the win32 api to break us.
  64. //
  65. DebugBreak();
  66. return;
  67. }
  68. return;
  69. }
  70. //=---------------------------------------------------------------------------=
  71. // Beefed-up version of WinMessageBox.
  72. //=---------------------------------------------------------------------------=
  73. //
  74. int NEAR _IdMsgBox
  75. (
  76. LPSTR pszText,
  77. LPCSTR pszTitle,
  78. UINT mbFlags
  79. )
  80. {
  81. HWND hwndActive;
  82. int id;
  83. hwndActive = GetActiveWindow();
  84. id = MessageBox(hwndActive, pszText, pszTitle, mbFlags);
  85. return id;
  86. }
  87. #endif // DEBUG