home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / VFORM.ZIP / Samples / VfbEx / Debug.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-10  |  1.5 KB  |  67 lines

  1. ////////////////////////////////////////////////////////////////
  2. // Copyright 1996 Microsoft Systems Journal. 
  3. // If this program works, it was written by Paul DiLascia.
  4. // If not, I don't know who wrote it.
  5. // See debug.cpp
  6. // 
  7. #ifdef _DEBUG
  8.  
  9. //////////////////
  10. // Implements TRACEFN macro.
  11. // Don't ever use directly, just use TRACEFN
  12. //
  13. class CTraceFn {
  14. private:
  15.     static int    nIndent;    // current indent level
  16.     friend void AFX_CDECL AfxTrace(LPCTSTR lpszFormat, ...);
  17. public:
  18.     CTraceFn()  { nIndent++; }
  19.     ~CTraceFn() { nIndent--; }
  20. };
  21.  
  22. // NOTE: YOU MUST NOT USE TRACEFN IN A ONE-LINE IF STATEMENT!
  23. // This will fail:
  24. //
  25. // if (foo)
  26. //    TRACEFN(...)
  27. //
  28. // Instead, you must enclose the TRACE in squiggle-brackets
  29. //
  30. // if (foo) {
  31. //        TRACEFN(...)
  32. // }
  33. //
  34. #define TRACEFN CTraceFn __fooble; TRACE
  35.  
  36. // Goodies to get names of things.
  37. //
  38. extern CString sDbgName(CWnd* pWnd); // get name of window
  39. extern CString sDbgName(UINT uMsg);     // get name of WM_ message
  40.  
  41. #ifdef REFIID
  42.  
  43. struct DBGINTERFACENAME {
  44.     const IID* piid;    // ptr to GUID
  45.     LPCTSTR name;        // human-readable name of interface
  46. };
  47.  
  48. // Change this to whatever interfaces you want to track
  49. // Default is none
  50. //
  51. extern DBGINTERFACENAME* _pDbgInterfaceNames; 
  52.  
  53. extern CString sDbgName(REFIID iid);    // get name of COM interface
  54.  
  55. #endif // REFIID
  56.  
  57. #else // Not _DEBUG
  58.  
  59. #define sDbgName(x)    CString()
  60. #define TRACEFN TRACE
  61.  
  62. #endif
  63.  
  64. // Macro casts to LPCTSTR for use with TRACE/printf/CString::Format
  65. //
  66. #define DbgName(x) (LPCTSTR)sDbgName(x)
  67.