|
|
1.1 ! root 1: // This is a part of the Microsoft Foundation Classes C++ library. ! 2: // Copyright (C) 1992 Microsoft Corporation ! 3: // All rights reserved. ! 4: // ! 5: // This source code is only intended as a supplement to the ! 6: // Microsoft Foundation Classes Reference and Microsoft ! 7: // QuickHelp and/or WinHelp documentation provided with the library. ! 8: // See these sources for detailed information regarding the ! 9: // Microsoft Foundation Classes product. ! 10: ! 11: ! 12: #include "stdafx.h" ! 13: ! 14: #ifdef AFX_DBG1_SEG ! 15: #pragma code_seg(AFX_DBG1_SEG) ! 16: #endif ! 17: ! 18: #ifdef _DEBUG // entire file for debugging ! 19: ! 20: #include "dde.h" ! 21: ! 22: #ifdef _DEBUG ! 23: #undef THIS_FILE ! 24: static char BASED_CODE THIS_FILE[] = __FILE__; ! 25: #endif ! 26: ! 27: ///////////////////////////////////////////////////////////////////////////// ! 28: // Build data tables by including data file three times ! 29: ! 30: #define DO(WM_FOO) static char BASED_CODE sz##WM_FOO[] = #WM_FOO; ! 31: #include "tracedat.h" ! 32: #undef DO ! 33: ! 34: static UINT BASED_CODE allMessages[] = ! 35: { ! 36: #define DO(WM_FOO) WM_FOO, ! 37: #include "tracedat.h" ! 38: #undef DO ! 39: 0 // end of table ! 40: }; ! 41: ! 42: static LPCSTR BASED_CODE allMessageNames[] = ! 43: { ! 44: #define DO(WM_FOO) sz##WM_FOO, ! 45: #include "tracedat.h" ! 46: #undef DO ! 47: NULL // end of table ! 48: }; ! 49: ! 50: ///////////////////////////////////////////////////////////////////////////// ! 51: // DDE special case ! 52: ! 53: static void PASCAL TraceDDE(LPCSTR lpszPrefix, const MSG* pMsg) ! 54: { ! 55: if (pMsg->message == WM_DDE_EXECUTE) ! 56: { ! 57: UINT nDummy; ! 58: HGLOBAL hCommands; ! 59: if (!UnpackDDElParam(WM_DDE_EXECUTE, pMsg->lParam, ! 60: &nDummy, (PUINT)&hCommands)) ! 61: { ! 62: TRACE("Warning: Unable to unpack WM_DDE_EXECUTE lParam %08lX.\n", ! 63: pMsg->lParam); ! 64: return; ! 65: } ! 66: ASSERT(hCommands != NULL); ! 67: ! 68: LPCSTR lpszCommands = (LPCSTR)::GlobalLock(hCommands); ! 69: ASSERT(lpszCommands != NULL); ! 70: TRACE2("%Fs: Execute '%Fs'\n", lpszPrefix, lpszCommands); ! 71: ::GlobalUnlock(hCommands); ! 72: } ! 73: else if (pMsg->message == WM_DDE_ADVISE) ! 74: { ! 75: ATOM aItem; ! 76: HGLOBAL hAdvise; ! 77: if (!UnpackDDElParam(WM_DDE_ADVISE, pMsg->lParam, ! 78: (PUINT)&hAdvise, (PUINT)&aItem)) ! 79: { ! 80: TRACE("Warning: Unable to unpack WM_DDE_ADVISE lParam %08lX.\n", ! 81: pMsg->lParam); ! 82: return; ! 83: } ! 84: ASSERT(aItem != NULL); ! 85: ASSERT(hAdvise != NULL); ! 86: ! 87: DDEADVISE FAR* lpAdvise = (DDEADVISE FAR*)::GlobalLock(hAdvise); ! 88: ASSERT(lpAdvise != NULL); ! 89: char szItem[80]; ! 90: szItem[0] = '\0'; ! 91: ! 92: if (aItem != 0) ! 93: ::GlobalGetAtomName(aItem, szItem, sizeof(szItem)); ! 94: ! 95: char szFormat[80]; ! 96: szFormat[0] = '\0'; ! 97: if (((UINT)0xC000 <= (UINT)lpAdvise->cfFormat) && ! 98: ((UINT)lpAdvise->cfFormat <= (UINT)0xFFFF)) ! 99: { ! 100: ::GetClipboardFormatName(lpAdvise->cfFormat, ! 101: szFormat, sizeof(szFormat)); ! 102: ! 103: // User defined clipboard formats have a range of 0xC000->0xFFFF ! 104: // System clipboard formats have other ranges, but no printable ! 105: // format names. ! 106: } ! 107: ! 108: static char BASED_DEBUG _sz[] = ! 109: "%Fs: Advise item='%s', Format='%s', Ack=%d, Defer Update= %d\n"; ! 110: AfxTrace(_sz, lpszPrefix, szItem, szFormat, lpAdvise->fAckReq, ! 111: lpAdvise->fDeferUpd); ! 112: ::GlobalUnlock(hAdvise); ! 113: } ! 114: } ! 115: ! 116: ///////////////////////////////////////////////////////////////////////////// ! 117: ! 118: void AFXAPI _AfxTraceMsg(LPCSTR lpszPrefix, const MSG* pMsg) ! 119: { ! 120: ASSERT(lpszPrefix != NULL); ! 121: ASSERT(pMsg != NULL); ! 122: ! 123: if (pMsg->message == WM_MOUSEMOVE || pMsg->message == WM_NCMOUSEMOVE || ! 124: pMsg->message == WM_NCHITTEST || ! 125: pMsg->message == WM_SETCURSOR || ! 126: pMsg->message == WM_CTLCOLORBTN || ! 127: pMsg->message == WM_CTLCOLORDLG || ! 128: pMsg->message == WM_CTLCOLOREDIT || ! 129: pMsg->message == WM_CTLCOLORLISTBOX || ! 130: pMsg->message == WM_CTLCOLORMSGBOX || ! 131: pMsg->message == WM_CTLCOLORSCROLLBAR || ! 132: pMsg->message == WM_CTLCOLORSTATIC || ! 133: pMsg->message == WM_ENTERIDLE || ! 134: pMsg->message == WM_CANCELMODE) ! 135: { ! 136: // don't report very frequently sent messages ! 137: return; ! 138: } ! 139: ! 140: LPCSTR lpszMsgName = NULL; ! 141: char szBuf[80]; ! 142: ! 143: // find message name ! 144: if (pMsg->message >= 0xC000) ! 145: { ! 146: // Window message registered with 'RegisterWindowMessage' ! 147: // (actually a USER atom) ! 148: if (::GetClipboardFormatName(pMsg->message, szBuf, sizeof(szBuf)) != 0) ! 149: lpszMsgName = szBuf; ! 150: } ! 151: else if (pMsg->message >= WM_USER) ! 152: { ! 153: // User message ! 154: sprintf(szBuf, "WM_USER+0x%04X", pMsg->message - WM_USER); ! 155: lpszMsgName = szBuf; ! 156: } ! 157: else ! 158: { ! 159: // a system windows message ! 160: const UINT FAR* lpMessage; ! 161: for (lpMessage = allMessages; *lpMessage != 0; lpMessage++) ! 162: { ! 163: if (*lpMessage == pMsg->message) ! 164: { ! 165: int iMsg = (int)(lpMessage - (const UINT FAR*)allMessages); ! 166: lpszMsgName = allMessageNames[iMsg]; ! 167: break; ! 168: } ! 169: } ! 170: } ! 171: ! 172: if (lpszMsgName != NULL) ! 173: { ! 174: static char BASED_DEBUG _sz[] = ! 175: "%Fs: hwnd=0x%04X, msg = %Fs (0x%04X, 0x%08lX)\n"; ! 176: AfxTrace(_sz, lpszPrefix, (UINT)pMsg->hwnd, lpszMsgName, ! 177: pMsg->wParam, pMsg->lParam); ! 178: } ! 179: else ! 180: { ! 181: static char BASED_DEBUG _sz[] = ! 182: "%Fs: hwnd=0x%04X, msg = 0x%04X (0x%04X, 0x%08lX)\n"; ! 183: AfxTrace(_sz, lpszPrefix, (UINT)pMsg->hwnd, pMsg->message, ! 184: pMsg->wParam, pMsg->lParam); ! 185: } ! 186: ! 187: if (pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST) ! 188: { ! 189: TraceDDE(lpszPrefix, pMsg); ! 190: } ! 191: } ! 192: ! 193: ///////////////////////////////////////////////////////////////////////////// ! 194: ! 195: #endif // _DEBUG (entire file)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.