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 / dsshow / wassert.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-15  |  1.1 KB  |  45 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. #include <windows.h>
  13.  
  14. extern HWND hWndMain;
  15. extern char szAppName[];
  16.  
  17. #include "wassert.h"
  18.  
  19.  
  20. #ifdef ASSERT
  21. void AssertFail(char szErr[], char szFileName[], int nLine, char szMessage[])
  22.     {
  23.     char szT[256];
  24.  
  25.     if (szMessage != NULL)
  26.         wsprintf(szT, "Assert(%s);\nFile %s, line %d.  %s", szErr, szFileName, nLine, szMessage);
  27.     else 
  28.         wsprintf(szT, "Assert(%s);\nFile %s, line %d.", szErr, szFileName, nLine);
  29.     switch (MessageBox(hWndMain, szT, szAppName, MB_ABORTRETRYIGNORE | MB_ICONSTOP | MB_APPLMODAL))
  30.         {
  31.         case IDABORT:
  32.             SendMessage(hWndMain, WM_CLOSE, 0, 0);
  33.         case IDRETRY:
  34.             _asm int 3;
  35.             // Fall Through //
  36.         case IDIGNORE:
  37.             break;
  38.  
  39.         } // switch
  40.     } // AssertFail
  41.  
  42.  
  43. #endif // ASSERT
  44.  
  45.