Annotation of mstools/mfc/src/trace.cpp, revision 1.1

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 documentation provided with the library.
        !             8: // See these sources for detailed information regarding the
        !             9: // Microsoft Foundation Classes product.
        !            10: 
        !            11: 
        !            12: #include "afxwin.h"
        !            13: #pragma hdrstop
        !            14: 
        !            15: #ifdef AFX_CORE_SEG
        !            16: #pragma code_seg(AFX_CORE_SEG)
        !            17: #endif
        !            18: 
        !            19: #ifdef _DEBUG       // entire file for debugging
        !            20: 
        !            21: #include "trace_.h"
        !            22: #include <dde.h>
        !            23: 
        !            24: /////////////////////////////////////////////////////////////////////////////
        !            25: // Build data tables by including data file three times
        !            26: 
        !            27: #define DO(WM_FOO)  static char BASED_CODE sz##WM_FOO[] = #WM_FOO;
        !            28: #include "tracedat.h"
        !            29: #undef DO
        !            30: 
        !            31: static UINT BASED_CODE allMessages[] =
        !            32: {
        !            33: #define DO(WM_FOO)  WM_FOO,
        !            34: #include "tracedat.h"
        !            35: #undef DO
        !            36:        0   /* end of table */
        !            37: };
        !            38: 
        !            39: static LPCSTR BASED_CODE allMessageNames[] =
        !            40: {
        !            41: #define DO(WM_FOO)  sz##WM_FOO,
        !            42: #include "tracedat.h"
        !            43: #undef DO
        !            44:        NULL    /* end of table */
        !            45: };
        !            46: 
        !            47: /////////////////////////////////////////////////////////////////////////////
        !            48: // DDE special case
        !            49: 
        !            50: static void TraceDDE(LPCSTR lpPrefix, const MSG* pMsg)
        !            51: {
        !            52: #ifndef _NTWIN
        !            53:        if (pMsg->message == WM_DDE_EXECUTE)
        !            54:        {
        !            55:                HANDLE hCommands = (HANDLE)HIWORD(pMsg->lParam);
        !            56:                ASSERT(hCommands != NULL);
        !            57: 
        !            58:                LPCSTR lpCommands = (LPCSTR)::GlobalLock(hCommands);
        !            59:                ASSERT(lpCommands != NULL);
        !            60:                TRACE("%Fs: Execute '%Fs'\n", lpPrefix, lpCommands);
        !            61:                ::GlobalUnlock(hCommands);
        !            62:        }
        !            63:        else if (pMsg->message == WM_DDE_ADVISE)
        !            64:        {
        !            65:                ATOM aItem = HIWORD(pMsg->lParam);
        !            66:                HANDLE hAdvise = (HANDLE)LOWORD(pMsg->lParam);
        !            67:                ASSERT(hAdvise != NULL);
        !            68: 
        !            69:                DDEADVISE FAR* lpAdvise = (DDEADVISE FAR *)::GlobalLock(hAdvise);
        !            70:                ASSERT(lpAdvise != NULL);                   
        !            71:                char szItem[80];
        !            72:                szItem[0] = '\0';
        !            73: 
        !            74:                if (aItem != 0)
        !            75:                        ::GlobalGetAtomName(aItem, szItem, sizeof(szItem));
        !            76: 
        !            77:                char szFormat[80];
        !            78:                szFormat[0] = '\0';
        !            79:                if ((0xC000 <= lpAdvise->cfFormat) && (lpAdvise->cfFormat <= 0xFFFF))
        !            80:                        ::GetClipboardFormatName(lpAdvise->cfFormat,
        !            81:                                szFormat, sizeof(szFormat));
        !            82: 
        !            83:                        // User defined clipboard formats have a range of 0xC000->0xFFFF
        !            84:                        // System clipboard formats have other ranges, but no printable
        !            85:                        // format names.
        !            86: 
        !            87: 
        !            88:                TRACE("%Fs: Advise item='%s', Format='%s', Ack=%d, Defer Update= %d\n",
        !            89:                        lpPrefix, szItem, szFormat, lpAdvise->fAckReq, lpAdvise->fDeferUpd);
        !            90:                ::GlobalUnlock(hAdvise);
        !            91:        }
        !            92: #else
        !            93:        TRACE("Windows NT:  DDE Trace\n");
        !            94: #endif //!_NTWIN
        !            95: }
        !            96: 
        !            97: /////////////////////////////////////////////////////////////////////////////
        !            98: 
        !            99: void AfxTraceMsg(LPCSTR lpPrefix, const MSG* pMsg)
        !           100: {
        !           101:        if (pMsg->message == WM_MOUSEMOVE || pMsg->message == WM_NCMOUSEMOVE ||
        !           102:           pMsg->message == WM_NCHITTEST ||
        !           103:           pMsg->message == WM_SETCURSOR ||
        !           104: #ifndef _NTWIN
        !           105:           pMsg->message == WM_CTLCOLOR ||
        !           106: #else
        !           107:       pMsg->message == WM_CTLCOLORMSGBOX ||
        !           108:       pMsg->message == WM_CTLCOLOREDIT ||
        !           109:       pMsg->message == WM_CTLCOLORLISTBOX ||
        !           110:       pMsg->message == WM_CTLCOLORBTN ||
        !           111:       pMsg->message == WM_CTLCOLORDLG ||
        !           112:       pMsg->message == WM_CTLCOLORSCROLLBAR ||
        !           113:       pMsg->message == WM_CTLCOLORSTATIC ||
        !           114: #endif
        !           115:           pMsg->message == WM_ENTERIDLE)
        !           116:        {
        !           117:                // never report mouse moves (too frequent) or other messages also
        !           118:                //   sent as part of mouse movement
        !           119:                return;
        !           120:        }
        !           121: 
        !           122:        LPCSTR lpMsgName = NULL;
        !           123:        char szBuf[80];
        !           124: 
        !           125:        // find message name
        !           126:        if (pMsg->message >= 0xC000)
        !           127:        {
        !           128:                // Window message registered with 'RegisterWindowMessage'
        !           129:                //  (actually a USER atom)
        !           130:                if (::GetClipboardFormatName(pMsg->message, szBuf, sizeof(szBuf)) != 0)
        !           131:                        lpMsgName = szBuf;
        !           132:        }
        !           133:        else if (pMsg->message >= WM_USER)
        !           134:        {
        !           135:                // User message
        !           136:                sprintf(szBuf, "WM_USER+0x%04X", pMsg->message - WM_USER);
        !           137:                lpMsgName = szBuf;
        !           138:        }
        !           139:        else
        !           140:        {
        !           141:                // a system windows message
        !           142:                const UINT FAR* lpMessage;
        !           143:                for (lpMessage = allMessages; *lpMessage != 0; lpMessage++)
        !           144:                {
        !           145:                        if (*lpMessage == pMsg->message)
        !           146:                        {
        !           147:                                int iMsg = lpMessage - (const UINT FAR*)allMessages;
        !           148:                                lpMsgName = allMessageNames[iMsg];
        !           149:                                break;
        !           150:                        }
        !           151:                }
        !           152:        }
        !           153: 
        !           154:        if (lpMsgName != NULL)
        !           155:        {
        !           156:                TRACE("%Fs: hwnd=0x%04x, msg = %Fs (0x%04x, 0x%08x)\n", lpPrefix,
        !           157:                        pMsg->hwnd, lpMsgName, pMsg->wParam, pMsg->lParam);
        !           158:        }
        !           159:        else
        !           160:        {
        !           161:                TRACE("%Fs: hwnd=0x%04x, msg = 0x%04x (0x%04x, 0x%08x)\n", lpPrefix,
        !           162:                        pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
        !           163:        }
        !           164: 
        !           165:        if (pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST)
        !           166:        {
        !           167:                TraceDDE(lpPrefix, pMsg);
        !           168:        }
        !           169: }
        !           170: 
        !           171: /////////////////////////////////////////////////////////////////////////////
        !           172: 
        !           173: #endif // _DEBUG (entire file)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.