home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / directx / dsstream / wassert.c < prev    next >
C/C++ Source or Header  |  1997-07-14  |  1KB  |  46 lines

  1. /*==========================================================================
  2.  *
  3.  *  Copyright (C) 1995-1997 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.  
  21. #ifdef WASSERT
  22. void AssertFail(char szErr[], char szFileName[], int nLine, char szMessage[])
  23.     {
  24.     char szT[256];
  25.  
  26.     if (szMessage != NULL)
  27.         wsprintf(szT, "Assert(%s);\nFile %s, line %d.  %s", szErr, szFileName, nLine, szMessage);
  28.     else 
  29.         wsprintf(szT, "Assert(%s);\nFile %s, line %d.", szErr, szFileName, nLine);
  30.     switch (MessageBox(hWndMain, szT, szAppName, MB_ABORTRETRYIGNORE | MB_ICONSTOP | MB_APPLMODAL))
  31.         {
  32.         case IDABORT:
  33.             SendMessage(hWndMain, WM_CLOSE, 0, 0);
  34.         case IDRETRY:
  35.             _asm int 3;
  36.             // Fall Through //
  37.         case IDIGNORE:
  38.             break;
  39.  
  40.         } // switch
  41.     } // AssertFail
  42.  
  43.  
  44. #endif // ASSERT
  45.  
  46.