|
|
//=--------------------------------------------------------------------------=
// Debug.Cpp
//=--------------------------------------------------------------------------=
// Copyright 1995-1996 Microsoft Corporation. All Rights Reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//=--------------------------------------------------------------------------=
//
// contains various methods that will only really see any use in DEBUG builds
//
#ifdef DEBUG
#include "IPServer.H"
#include <stdlib.h>
//=--------------------------------------------------------------------------=
// Private Constants
//---------------------------------------------------------------------------=
//
static const char szFormat[] = "%s\nFile %s, Line %d"; static const char szFormat2[] = "%s\n%s\nFile %s, Line %d";
#define _SERVERNAME_ "ActiveX Framework"
static const char szTitle[] = _SERVERNAME_ " Assertion (Abort = UAE, Retry = INT 3, Ignore = Continue)";
//=--------------------------------------------------------------------------=
// Local functions
//=--------------------------------------------------------------------------=
int NEAR _IdMsgBox(LPSTR pszText, LPCSTR pszTitle, UINT mbFlags);
//=--------------------------------------------------------------------------=
// DisplayAssert
//=--------------------------------------------------------------------------=
// Display an assert message box with the given pszMsg, pszAssert, source
// file name, and line number. The resulting message box has Abort, Retry,
// Ignore buttons with Abort as the default. Abort does a FatalAppExit;
// Retry does an int 3 then returns; Ignore just returns.
//
VOID DisplayAssert ( LPSTR pszMsg, LPSTR pszAssert, LPSTR pszFile, UINT line ) { char szMsg[250]; LPSTR lpszText;
lpszText = pszMsg; // Assume no file & line # info
// If C file assert, where you've got a file name and a line #
//
if (pszFile) {
// Then format the assert nicely
//
wsprintf(szMsg, szFormat, (pszMsg&&*pszMsg) ? pszMsg : pszAssert, pszFile, line); lpszText = szMsg; }
// Put up a dialog box
//
switch (_IdMsgBox(lpszText, szTitle, MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SYSTEMMODAL)) { case IDABORT: FatalAppExit(0, lpszText); return;
case IDRETRY: // call the win32 api to break us.
//
DebugBreak(); return; }
return; }
//=---------------------------------------------------------------------------=
// Beefed-up version of WinMessageBox.
//=---------------------------------------------------------------------------=
//
int NEAR _IdMsgBox ( LPSTR pszText, LPCSTR pszTitle, UINT mbFlags ) { HWND hwndActive; int id;
hwndActive = GetActiveWindow();
id = MessageBox(hwndActive, pszText, pszTitle, mbFlags);
return id; }
#endif // DEBUG
|