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

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:        if (pMsg->message == WM_DDE_EXECUTE)
                     53:        {
1.1.1.2 ! root       54: #ifndef _NTWIN
1.1       root       55:                HANDLE hCommands = (HANDLE)HIWORD(pMsg->lParam);
1.1.1.2 ! root       56: #else
        !            57: //REVIEW_NT: this is dumb, I wonder if it is correct.
        !            58:                UINT nDummy;
        !            59:                HANDLE hCommands;
        !            60:                if (!UnpackDDElParam(WM_DDE_ADVISE, pMsg->lParam,
        !            61:                        (PUINT)&hCommands, &nDummy))
        !            62:                {
        !            63:                        TRACE("Warning: Unable to unpack WM_DDE_EXECUTE lParam %08lX.\n",
        !            64:                                pMsg->lParam);
        !            65:                        return;
        !            66:                }
        !            67: #endif
1.1       root       68:                ASSERT(hCommands != NULL);
                     69: 
                     70:                LPCSTR lpCommands = (LPCSTR)::GlobalLock(hCommands);
                     71:                ASSERT(lpCommands != NULL);
                     72:                TRACE("%Fs: Execute '%Fs'\n", lpPrefix, lpCommands);
                     73:                ::GlobalUnlock(hCommands);
                     74:        }
                     75:        else if (pMsg->message == WM_DDE_ADVISE)
                     76:        {
1.1.1.2 ! root       77: #ifndef _NTWIN
1.1       root       78:                ATOM aItem = HIWORD(pMsg->lParam);
                     79:                HANDLE hAdvise = (HANDLE)LOWORD(pMsg->lParam);
1.1.1.2 ! root       80: #else
        !            81:                ATOM aItem;
        !            82:                HANDLE hAdvise;
        !            83:                if (!UnpackDDElParam(WM_DDE_ADVISE, pMsg->lParam,
        !            84:                        (PUINT)&hAdvise, (PUINT)&aItem))
        !            85:                {
        !            86:                        TRACE("Warning: Unable to unpack WM_DDE_ADVISE lParam %08lX.\n",
        !            87:                                pMsg->lParam);
        !            88:                        return;
        !            89:                }
        !            90: #endif
1.1       root       91:                ASSERT(hAdvise != NULL);
                     92: 
                     93:                DDEADVISE FAR* lpAdvise = (DDEADVISE FAR *)::GlobalLock(hAdvise);
                     94:                ASSERT(lpAdvise != NULL);                   
                     95:                char szItem[80];
                     96:                szItem[0] = '\0';
                     97: 
                     98:                if (aItem != 0)
                     99:                        ::GlobalGetAtomName(aItem, szItem, sizeof(szItem));
                    100: 
                    101:                char szFormat[80];
                    102:                szFormat[0] = '\0';
                    103:                if ((0xC000 <= lpAdvise->cfFormat) && (lpAdvise->cfFormat <= 0xFFFF))
                    104:                        ::GetClipboardFormatName(lpAdvise->cfFormat,
                    105:                                szFormat, sizeof(szFormat));
                    106: 
                    107:                        // User defined clipboard formats have a range of 0xC000->0xFFFF
                    108:                        // System clipboard formats have other ranges, but no printable
                    109:                        // format names.
                    110: 
                    111: 
                    112:                TRACE("%Fs: Advise item='%s', Format='%s', Ack=%d, Defer Update= %d\n",
                    113:                        lpPrefix, szItem, szFormat, lpAdvise->fAckReq, lpAdvise->fDeferUpd);
                    114:                ::GlobalUnlock(hAdvise);
                    115:        }
                    116: }
                    117: 
                    118: /////////////////////////////////////////////////////////////////////////////
                    119: 
                    120: void AfxTraceMsg(LPCSTR lpPrefix, const MSG* pMsg)
                    121: {
                    122:        if (pMsg->message == WM_MOUSEMOVE || pMsg->message == WM_NCMOUSEMOVE ||
1.1.1.2 ! root      123:                pMsg->message == WM_NCHITTEST ||
        !           124:                pMsg->message == WM_SETCURSOR ||
1.1       root      125: #ifndef _NTWIN
1.1.1.2 ! root      126:                pMsg->message == WM_CTLCOLOR ||
1.1       root      127: #else
1.1.1.2 ! root      128:                pMsg->message == WM_CTLCOLORMSGBOX ||
        !           129:                pMsg->message == WM_CTLCOLOREDIT ||
        !           130:                pMsg->message == WM_CTLCOLORLISTBOX ||
        !           131:                pMsg->message == WM_CTLCOLORBTN ||
        !           132:                pMsg->message == WM_CTLCOLORDLG ||
        !           133:                pMsg->message == WM_CTLCOLORSCROLLBAR ||
        !           134:                pMsg->message == WM_CTLCOLORSTATIC ||
1.1       root      135: #endif
1.1.1.2 ! root      136:                pMsg->message == WM_ENTERIDLE)
1.1       root      137:        {
                    138:                // never report mouse moves (too frequent) or other messages also
                    139:                //   sent as part of mouse movement
                    140:                return;
                    141:        }
                    142: 
                    143:        LPCSTR lpMsgName = NULL;
                    144:        char szBuf[80];
                    145: 
                    146:        // find message name
                    147:        if (pMsg->message >= 0xC000)
                    148:        {
                    149:                // Window message registered with 'RegisterWindowMessage'
                    150:                //  (actually a USER atom)
                    151:                if (::GetClipboardFormatName(pMsg->message, szBuf, sizeof(szBuf)) != 0)
                    152:                        lpMsgName = szBuf;
                    153:        }
                    154:        else if (pMsg->message >= WM_USER)
                    155:        {
                    156:                // User message
                    157:                sprintf(szBuf, "WM_USER+0x%04X", pMsg->message - WM_USER);
                    158:                lpMsgName = szBuf;
                    159:        }
                    160:        else
                    161:        {
                    162:                // a system windows message
                    163:                const UINT FAR* lpMessage;
                    164:                for (lpMessage = allMessages; *lpMessage != 0; lpMessage++)
                    165:                {
                    166:                        if (*lpMessage == pMsg->message)
                    167:                        {
                    168:                                int iMsg = lpMessage - (const UINT FAR*)allMessages;
                    169:                                lpMsgName = allMessageNames[iMsg];
                    170:                                break;
                    171:                        }
                    172:                }
                    173:        }
                    174: 
                    175:        if (lpMsgName != NULL)
                    176:        {
                    177:                TRACE("%Fs: hwnd=0x%04x, msg = %Fs (0x%04x, 0x%08x)\n", lpPrefix,
                    178:                        pMsg->hwnd, lpMsgName, pMsg->wParam, pMsg->lParam);
                    179:        }
                    180:        else
                    181:        {
                    182:                TRACE("%Fs: hwnd=0x%04x, msg = 0x%04x (0x%04x, 0x%08x)\n", lpPrefix,
                    183:                        pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
                    184:        }
                    185: 
                    186:        if (pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST)
                    187:        {
                    188:                TraceDDE(lpPrefix, pMsg);
                    189:        }
                    190: }
                    191: 
                    192: /////////////////////////////////////////////////////////////////////////////
                    193: 
                    194: #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.