home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / DIRECTX2 / WATCOM / DXSDKWAT.ZIP / SAMPLES / DSSTREAM / WASSERT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-30  |  1.6 KB  |  57 lines

  1. /*==========================================================================
  2.  *
  3.  *  Copyright (C) 1995-1996 Microsoft Corporation. All Rights Reserved.
  4.  *
  5.  *  File:               wassert.c
  6.  *  Content:    Windows assert handler
  7.  *              You must externally define hWndMain and szAppName for this
  8.  *              to work.
  9.  *
  10.  ***************************************************************************/
  11.  
  12. #define WIN32_LEAN_AND_MEAN
  13. #include <windows.h>
  14.  
  15. extern HWND hWndMain;
  16. extern char szAppName[];
  17.  
  18. #include "wassert.h"
  19.  
  20. #ifdef __WATCOMC__
  21. extern void Int3Call( void );
  22. #pragma aux Int3Call parm caller [] = "int 3"
  23. #endif
  24.  
  25.  
  26. #ifdef WASSERT
  27. void AssertFail(char szErr[], char szFileName[], int nLine, char szMessage[])
  28.         {
  29.         char szT[256];
  30.  
  31.         if (szMessage != NULL)
  32.                 wsprintf(szT, "Assert(%s);\nFile %s, line %d.  %s", szErr, szFileName, nLine, szMessage);
  33.         else 
  34.                 wsprintf(szT, "Assert(%s);\nFile %s, line %d.", szErr, szFileName, nLine);
  35.         switch (MessageBox(hWndMain, szT, szAppName, MB_ABORTRETRYIGNORE | MB_ICONSTOP | MB_APPLMODAL))
  36.                 {
  37.                 case IDABORT:
  38.                         SendMessage(hWndMain, WM_CLOSE, 0, 0);
  39.                 case IDRETRY:
  40.                        // _asm int 3;
  41.                 #ifdef __WATCOMC__
  42.                        Int3Call();
  43.             #else
  44.                 _asm int 3;
  45.             #endif
  46.  
  47.                         // Fall Through //
  48.                 case IDIGNORE:
  49.                         break;
  50.  
  51.                 } // switch
  52.         } // AssertFail
  53.  
  54.  
  55. #endif // ASSERT
  56.  
  57.