DEBUG.CPP
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:3k
源码类别:
Windows编程
开发平台:
Visual C++
- //=--------------------------------------------------------------------------=
- // Debug.Cpp
- //=--------------------------------------------------------------------------=
- // Copyright 1995-1997 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[] = "%snFile %s, Line %d";
- static const char szFormat2[] = "%sn%snFile %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