home *** CD-ROM | disk | FTP | other *** search
/ NEXT Generation 27 / NEXT27.iso / pc / demos / emperor / dx3.exe / SDK / SAMPLES / DSSTREAM / WASSERT.C < prev    next >
C/C++ Source or Header  |  1996-08-28  |  1KB  |  46 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.  
  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.