Annotation of mstools/samples/sdktools/ddespy/ddespy.c, revision 1.1.1.2

1.1       root        1: /****************************************************************************
                      2: 
                      3:     PROGRAM: DdeSpy.c
                      4: 
                      5: ****************************************************************************/
                      6: 
1.1.1.2 ! root        7: #define UNICODE
1.1       root        8: #include <windows.h>                /* required for all Windows applications */
                      9: #include <windowsx.h>
                     10: #include <shellapi.h>
                     11: #include <dde.h>
                     12: #include <stdio.h>
                     13: #include <io.h>
                     14: #include <errno.h>
                     15: #include <string.h>
                     16: #include <stdlib.h>
                     17: #include <ctype.h>
                     18: #include "ddespy.h"
                     19: #include "lists.h"
                     20: 
                     21: /* GLOBAL Variables used for DDESPY */
                     22: 
                     23: UINT        idInst = 0;
1.1.1.2 ! root       24: HINSTANCE   hInst;
1.1       root       25: HICON       hIcon;
                     26: HWND        hWndString = NULL;
                     27: HWND        hwndSpy = NULL;
                     28: INT         fhOutput = 0;
                     29: OFSTRUCT    ofsOpen;
1.1.1.2 ! root       30: TCHAR        OpenName[MAX_FNAME + 1];
        !            31: TCHAR        TBuf[BUFFER_SIZE];
        !            32: TCHAR        TBuf2[BUFFER_SIZE];
        !            33: TCHAR        szNULL[] = TEXT("");
        !            34: LPTSTR        apszResources[IDS_LAST + 1];
1.1       root       35: PFNCALLBACK pfnDdeCallback = NULL;
                     36: HWND        hwndTrack[IT_COUNT] = { 0 };
1.1.1.2 ! root       37: LPTSTR        TrackTitle[IT_COUNT];
1.1       root       38: BOOL        fBlockMsg[WM_DDE_LAST - WM_DDE_FIRST + 1] = { 0 };
                     39: BOOL        fBlockCb[15] = { 0 };
1.1.1.2 ! root       40: LPTSTR        TrackHeading[IT_COUNT];
1.1       root       41: struct {                           /* profile data */
                     42:     BOOL fOutput[IO_COUNT];
                     43:     BOOL fFilter[IF_COUNT];
                     44:     BOOL fTrack[IT_COUNT];
                     45:     BOOL fTerse;
                     46: } pro;
                     47: 
                     48: 
                     49: 
                     50: BOOL LoadResourceStrings()
                     51: {
                     52:     int i, cbLeft, cbRes;
1.1.1.2 ! root       53:     LPTSTR psz;
1.1       root       54: 
                     55:     cbLeft = 0x1000;
1.1.1.2 ! root       56:     psz = LocalAlloc(LPTR, sizeof(TCHAR) * cbLeft);
1.1       root       57:     for (i = 0; i <= IDS_LAST; i++) {
                     58:         apszResources[i] = psz;
                     59:         cbRes = LoadString(hInst, i, psz, cbLeft) + 1;
                     60:         cbLeft -= cbRes;
                     61:         psz += cbRes;
                     62:     }
                     63:     for (i = 0; i < IT_COUNT; i++) {
                     64:         TrackTitle[i] = RefString(IDS_TRACKTITLE_1 + i);
                     65:         TrackHeading[i] = RefString(IDS_TRACKHEADING_1 + i);
                     66:     }
1.1.1.2 ! root       67:     lstrcpy(TBuf, RefString(IDS_DEFAULT_OUTPUT_FNAME));
1.1       root       68:     GetFullPathName(TBuf, sizeof(OpenName), OpenName, (LPTSTR *)TBuf2);
                     69:     return(TRUE);
                     70: }
                     71: 
                     72: 
                     73: 
                     74: int WINAPI WinMain(
                     75:         HINSTANCE hInstance,
                     76:         HINSTANCE hPrevInstance,
                     77:         LPSTR lpCmdLine,
                     78:         int nCmdShow)
                     79: {
                     80:     MSG msg;
                     81: 
                     82:     UNREFERENCED_PARAMETER(lpCmdLine);
                     83: 
                     84:     hInst = hInstance;
                     85: 
                     86:     if (!LoadResourceStrings()) {
                     87:         return (FALSE);
                     88:     }
                     89: 
                     90:     if (!hPrevInstance)
                     91:         if (!InitApplication(hInstance)) /* Initialize shared things */
                     92:             return (FALSE);              /* Exits if unable to initialize    */
                     93: 
                     94:     /* Perform initializations that apply to a specific instance */
                     95: 
                     96:     if (!InitInstance(hInstance, nCmdShow)) {
                     97:         CloseApp();
                     98:         return (FALSE);
                     99:     }
                    100: 
                    101:     /* Acquire and dispatch messages until a WM_QUIT message is received. */
                    102: 
                    103:     while (GetMessage(&msg,        /* message structure                      */
                    104:             NULL,                  /* handle of window receiving the message */
                    105:             0,                     /* lowest message to examine              */
                    106:             0))                    /* highest message to examine             */
                    107:         {
                    108:         TranslateMessage(&msg);    /* Translates virtual key codes           */
                    109:         DispatchMessage(&msg);     /* Dispatches message to window           */
                    110:     }
                    111:     CloseApp();
                    112:     return (msg.wParam);           /* Returns the value from PostQuitMessage */
                    113: }
                    114: 
                    115: 
                    116: 
                    117: BOOL InitApplication(HINSTANCE hInstance)
                    118: {
                    119:     WNDCLASS  wc;
                    120: 
                    121:     if (!InitTestSubs())                        
                    122:         return(FALSE);
                    123: 
                    124:     /* Fill in window class structure with parameters that describe the       */
                    125:     /* main window.                                                           */
                    126: 
                    127:     wc.style = 0;                    /* Class style(s).                    */
                    128:     wc.lpfnWndProc = (WNDPROC)MainWndProc;       /* Function to retrieve messages for  */
                    129:                                         /* windows of this class.             */
                    130:     wc.cbClsExtra = 0;                  /* No per-class extra data.           */
                    131:     wc.cbWndExtra = 0;                  /* No per-window extra data.          */
                    132:     wc.hInstance = hInstance;           /* Application that owns the class.   */
                    133:     hIcon = wc.hIcon = LoadIcon(hInstance, RefString(IDS_TITLE));
                    134:     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
                    135:     wc.hbrBackground = GetStockObject(WHITE_BRUSH);
                    136:     wc.lpszMenuName =  MAKEINTRESOURCE(IDR_MENU);   /* Name of menu resource in .RC file. */
                    137:     wc.lpszClassName = RefString(IDS_CLASS);
                    138: 
                    139:     /* Register the window class and return success/failure code. */
                    140: 
                    141:     return (RegisterClass(&wc));
                    142: }
                    143: 
                    144: 
                    145: BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
                    146: {
                    147:     RECT            Rect;
                    148:     INT             i;
                    149: 
                    150:     /* Save the instance handle in static variable, which will be used in  */
                    151:     /* many subsequence calls from this application to Windows.            */
                    152: 
                    153:     pfnDdeCallback = (PFNCALLBACK)MakeProcInstance((FARPROC)DdeCallback,
                    154:             hInstance);
                    155: 
                    156:     GetProfile();
                    157: 
                    158:     /* Create a main window for this application instance.  */
                    159: 
                    160:     hwndSpy = CreateWindow(
                    161:         RefString(IDS_CLASS),
                    162:         RefString(IDS_TITLE),
                    163:         WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                    164:         CW_USEDEFAULT,                  /* Default horizontal position.       */
                    165:         CW_USEDEFAULT,                  /* Default vertical position.         */
                    166:         CW_USEDEFAULT,                  /* Default width.                     */
                    167:         CW_USEDEFAULT,                  /* Default height.                    */
                    168:         NULL,                           /* Overlapped windows have no parent. */
                    169:         NULL,                           /* Use the window class menu.         */
                    170:         hInstance,                      /* This instance owns this window.    */
                    171:         NULL                            /* Pointer not needed.                */
                    172:     );
                    173: 
                    174: 
                    175:     GetClientRect(hwndSpy, (LPRECT) &Rect);
                    176: 
                    177:     hWndString = CreateWindow(          /* String Window (class Registered in Teststubs)*/
                    178:         RefString(IDS_STRINGCLASS), 
                    179:         szNULL,
                    180:         WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL,
                    181:         0,
                    182:         0,
                    183:         Rect.right - Rect.left,
                    184:         Rect.bottom - Rect.top,
                    185:         hwndSpy, 
                    186:         NULL, 
                    187:         hInst, 
1.1.1.2 ! root      188:         (LPTSTR)MAKELONG(CCHARS, CLINES));
1.1       root      189: 
                    190:     for (i = 0; i < IT_COUNT; i++) {
                    191:         if (pro.fTrack[i]) {
                    192:             pro.fTrack[i] = FALSE;
                    193:             SendMessage(hwndSpy, WM_COMMAND,
                    194:                     GET_WM_COMMAND_MPS(IDM_TRACK_FIRST + i, 0, 0));
                    195:         }
                    196:     }
                    197: 
                    198:     if (!hwndSpy || !hWndString) {
                    199:         CloseApp();
                    200:         return (FALSE);
                    201:     }
                    202: 
                    203:     /* Make the window visible; update its client area; and return "success" */
                    204: 
                    205:     ShowWindow(hwndSpy, nCmdShow);  /* Show the window                        */
                    206:     UpdateWindow(hwndSpy);          /* Sends WM_PAINT message                 */
                    207: 
                    208:     if (SetFilters()) {
                    209:         return(FALSE);
                    210:     }
                    211: 
                    212:     return(TRUE);
                    213: }
                    214: 
                    215: 
                    216: VOID CloseApp()
                    217: {
                    218:     DdeUninitialize(idInst);        /* perform cleanup and store profile */
                    219:     SaveProfile();
                    220:     if (fhOutput)
                    221:         _lclose(fhOutput);
                    222:     UnregisterClass(RefString(IDS_CLASS), hInst);
                    223:     CloseTestSubs(hInst);
                    224: }
                    225: 
                    226: 
                    227: 
                    228: LONG  CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
                    229: {
                    230:     int i;
                    231: 
                    232:     switch (message) {
                    233:     case WM_CREATE:
                    234:         LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_ACCEL));
                    235:         if (pro.fOutput[IO_FILE])
                    236:             pro.fOutput[IO_FILE] = fhOutput =
                    237:                     DoDialog(MAKEINTRESOURCE(IDD_OPEN), (DLGPROC)OpenDlg, 0, TRUE, hWnd, hInst);
                    238:         break;
                    239: 
                    240:     case WM_INITMENU:
                    241:         if (GetMenu(hWnd) != (HMENU)wParam)
                    242:             break;
                    243: 
                    244:         for (i = 0; i < IO_COUNT; i++) {
                    245:         CheckMenuItem((HMENU)wParam, IDM_OUTPUT_FIRST + i,
                    246:                 pro.fOutput[i] ? MF_CHECKED : MF_UNCHECKED);
                    247:         }
                    248: 
                    249:         for (i = 0; i < IF_COUNT; i++) {
                    250:             CheckMenuItem((HMENU)wParam, IDM_FILTER_FIRST + i,
                    251:                 pro.fFilter[i] ? MF_CHECKED : MF_UNCHECKED);
                    252:         }
                    253: 
                    254:         for (i = 0; i < IT_COUNT; i++) {
                    255:             CheckMenuItem((HMENU)wParam, IDM_TRACK_FIRST + i,
                    256:                 pro.fTrack[i] ? MF_CHECKED : MF_UNCHECKED);
                    257:         }
                    258:         break;
                    259: 
                    260:     case WM_COMMAND:           /* message: command from application menu */
                    261:         switch (GET_WM_COMMAND_ID(wParam, lParam)) {
                    262:         case IDM_OUTPUT_FILE:
                    263:         case IDM_OUTPUT_DEBUG:
                    264:         case IDM_OUTPUT_SCREEN:
                    265:             switch (wParam) {
                    266:             case IDM_OUTPUT_FILE:
                    267:                 if (fhOutput) {
                    268:                     wsprintf(TBuf, RefString(IDS_QCLOSEFILE_TEXT), OpenName);
                    269:                     if (IDYES != MessageBox(hWnd,
                    270:                             TBuf, RefString(IDS_QCLOSEFILE_CAPTION),
                    271:                             MB_YESNO | MB_ICONQUESTION)) {
                    272:                         break;
                    273:                     }
                    274:                     _lclose(fhOutput);
                    275:                 }
                    276:                 pro.fOutput[IO_FILE] = fhOutput =
                    277:                         DoDialog(MAKEINTRESOURCE(IDD_OPEN), (DLGPROC)OpenDlg, 0, TRUE, hWnd, hInst);
                    278:                 break;
                    279: 
                    280:             case IDM_OUTPUT_DEBUG:
                    281:                 pro.fOutput[IO_DEBUG] = !pro.fOutput[IO_DEBUG];
                    282:                 break;
                    283: 
                    284:             case IDM_OUTPUT_SCREEN:
                    285:                 pro.fOutput[IO_SCREEN] = !pro.fOutput[IO_SCREEN];
                    286:                 break;
                    287: 
                    288:             }
                    289:             break;
                    290: 
                    291:         case IDM_CLEARSCREEN:
                    292:             if (hWndString) {
                    293:                 HANDLE hpsw;
                    294:                 STRWND *psw;
                    295: 
                    296:                 hpsw = (HANDLE)GetWindowLong(hWndString, 0);
                    297:                 psw = (STRWND *)LocalLock(hpsw);
                    298:                 ClearScreen(psw);
                    299:                 LocalUnlock(hpsw);
                    300:                 InvalidateRect(hWndString, NULL, TRUE);
                    301:             }
                    302:             break;
                    303: 
                    304:         case IDM_MARK:
                    305:             DoDialog(MAKEINTRESOURCE(IDD_VALUEENTRY), (DLGPROC)MarkDlgProc, 0, TRUE, hWnd, hInst);
                    306:             break;
                    307: 
                    308:         case IDM_FILTER_HSZINFO:
                    309:         case IDM_FILTER_INIT_TERM:
                    310:         case IDM_FILTER_DDEMSGS:
                    311:         case IDM_FILTER_CALLBACKS:
                    312:         case IDM_FILTER_ERRORS:
                    313:             pro.fFilter[wParam - IDM_FILTER_FIRST] =
                    314:                     !pro.fFilter[wParam - IDM_FILTER_FIRST];
                    315:             SetFilters();
                    316:             break;
                    317: 
                    318:         case IDM_FILTER_DIALOG:
                    319:             DoDialog(MAKEINTRESOURCE(IDD_MSGFILTERS), (DLGPROC)FilterDlgProc, 0, TRUE, hWnd, hInst);
                    320:             break;
                    321: 
                    322:         case IDM_TRACK_HSZS:
                    323:         case IDM_TRACK_CONVS:
                    324:         case IDM_TRACK_LINKS:
                    325:         case IDM_TRACK_SVRS:
                    326:             pro.fTrack[wParam - IDM_TRACK_FIRST] =
                    327:                     !pro.fTrack[wParam - IDM_TRACK_FIRST];
                    328:             if (pro.fTrack[wParam - IDM_TRACK_FIRST]) {
                    329:                 hwndTrack[wParam - IDM_TRACK_FIRST] = CreateMCLBFrame(
                    330:                         NULL,
                    331:                         TrackTitle[wParam - IDM_TRACK_FIRST],
                    332:                         WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MINIMIZE,
                    333:                         hIcon, (HBRUSH)(COLOR_APPWORKSPACE + 1),
                    334:                         TrackHeading[wParam - IDM_TRACK_FIRST]);
                    335:             } else {
                    336:                 DestroyWindow(hwndTrack[wParam - IDM_TRACK_FIRST]);
                    337:                 hwndTrack[wParam - IDM_TRACK_FIRST] = 0;
                    338:             }
                    339:             SetFilters();
                    340:             break;
                    341: 
                    342:         case IDM_ABOUT:
                    343:             DoDialog(MAKEINTRESOURCE(IDD_ABOUTBOX), (DLGPROC)About, 0, TRUE, hWnd, hInst);
                    344:             break;
                    345: 
                    346:         default:
                    347:             return (DefWindowProc(hWnd, message, wParam, lParam));
                    348:         }
                    349:         break;
                    350: 
                    351:     case WM_DESTROY:                  /* message: window being destroyed */
                    352:         for (i = IDM_TRACK_FIRST; i <= IDM_TRACK_LAST; i++) {
                    353:             if (pro.fTrack[i - IDM_TRACK_FIRST]) {
                    354:                 DestroyWindow(hwndTrack[i - IDM_TRACK_FIRST]);
                    355:                 hwndTrack[i - IDM_TRACK_FIRST] = 0;
                    356:             }
                    357:         }
                    358:         PostQuitMessage(0);
                    359:         break;
                    360: 
                    361:     case WM_SIZE:
                    362:         if (hWndString) {
                    363:             RECT rc;
                    364: 
                    365:             GetClientRect(hWnd, &rc);
                    366:             MoveWindow(hWndString, 0, 0, rc.right, rc.bottom, TRUE);
                    367:         }
                    368:         // fall through
                    369:     default:
                    370:         return (DefWindowProc(hWnd, message, wParam, lParam));
                    371:     }
                    372:     return (0);
                    373: }
                    374: 
                    375: 
                    376: 
                    377: 
                    378: 
                    379: BOOL  CALLBACK About(
                    380:                     HWND hDlg,
                    381:                     UINT message,
                    382:                     WPARAM wParam,
                    383:                     LPARAM lParam)
                    384: {
                    385:     switch (message) {
                    386:         case WM_INITDIALOG:                /* message: initialize dialog box */
                    387:             return (TRUE);
                    388: 
                    389:         case WM_COMMAND:                      /* message: received a command */
                    390:             if (GET_WM_COMMAND_ID(wParam, lParam) == IDOK
                    391:                 || GET_WM_COMMAND_ID(wParam, lParam) == IDCANCEL) {
                    392:                 EndDialog(hDlg, TRUE);        /* Exits the dialog box        */
                    393:                 return (TRUE);
                    394:             }
                    395:             break;
                    396:     }
                    397:     return (FALSE);                           /* Didn't process a message    */
                    398: }
                    399: 
                    400: 
                    401: HDDEDATA CALLBACK DdeCallback(
                    402:                             UINT wType,
                    403:                             UINT wFmt,
                    404:                             HCONV hConv,
                    405:                             HSZ hsz1,
                    406:                             HSZ hsz2,
                    407:                             HDDEDATA hData,
                    408:                             UINT dwData1,
                    409:                             UINT dwData2)
                    410: {
                    411:     LPVOID pData;
                    412:     UINT cb;
1.1.1.2 ! root      413:     TCHAR *psz1, *psz2, *psz3;
        !           414:     TCHAR *szAction;
1.1       root      415:     INT i;
                    416:     BOOL fInt = FALSE;
                    417:     wFmt;
                    418:     hConv;
                    419:     dwData1;
                    420: 
                    421:     switch (wType) {
                    422:     case XTYP_MONITOR:
                    423:     if (pData = DdeAccessData(hData, (LPDWORD)&cb)) {
                    424:         switch (dwData2) {
                    425:         case MF_HSZ_INFO:
                    426:             if (pro.fTrack[IT_HSZS]) {
                    427:                 switch (((MONHSZSTRUCT FAR *)pData)->fsAction) {
                    428:                 case MH_DELETE:
1.1.1.2 ! root      429:                     wsprintf(TBuf, fInt ? TEXT("0x%lx\t*\t%s(int)")
        !           430:                            : TEXT("0x%lx\t*\t%s"),
1.1       root      431:                             ((MONHSZSTRUCT FAR *)pData)->hsz, 
1.1.1.2 ! root      432:                             (LPTSTR)((MONHSZSTRUCT FAR *)pData)->str);
1.1       root      433:                     i = GetMCLBColValue(TBuf, hwndTrack[IT_HSZS], 2);
                    434:                     if (i > 1) {
1.1.1.2 ! root      435:                         wsprintf(TBuf2, fInt ? TEXT("0x%lx\t%d\t%s(int)")
        !           436:                                : TEXT("0x%lx\t%d\t%s"),
1.1       root      437:                                 ((MONHSZSTRUCT FAR *)pData)->hsz,
                    438:                                  i - 1,
1.1.1.2 ! root      439:                                  (LPTSTR)((MONHSZSTRUCT FAR *)pData)->str);
1.1       root      440:                         AddMCLBText(TBuf, TBuf2, hwndTrack[IT_HSZS]);
                    441:                     } else if (i == 1) {
                    442:                         DeleteMCLBText(TBuf, hwndTrack[IT_HSZS]);
                    443:                     }
                    444:                     break;
                    445: 
                    446:                 case MH_KEEP:
                    447:                 case MH_CREATE:
1.1.1.2 ! root      448:                     wsprintf(TBuf, fInt ? TEXT("0x%lx\t*\t%s(int)")
        !           449:                            : TEXT("0x%lx\t*\t%s"),
1.1       root      450:                             ((MONHSZSTRUCT FAR *)pData)->hsz,
1.1.1.2 ! root      451:                             (LPTSTR)((MONHSZSTRUCT FAR *)pData)->str);
1.1       root      452:                     i = GetMCLBColValue(TBuf, hwndTrack[IT_HSZS], 2) + 1;
1.1.1.2 ! root      453:                     wsprintf(TBuf2, fInt ? TEXT("0x%lx\t%d\t%s(int)")
        !           454:                            : TEXT("0x%lx\t%d\t%s"),
1.1       root      455:                             ((MONHSZSTRUCT FAR *)pData)->hsz,
                    456:                              i,
1.1.1.2 ! root      457:                              (LPTSTR)((MONHSZSTRUCT FAR *)pData)->str);
1.1       root      458:                     AddMCLBText(TBuf, TBuf2, hwndTrack[IT_HSZS]);
                    459:                 }
                    460:             }
                    461: 
                    462:             if (!pro.fFilter[IF_HSZ]) {
                    463:                 return(0);
                    464:             }
                    465: 
                    466:             switch (((MONHSZSTRUCT FAR *)pData)->fsAction) {
                    467:             case MH_CLEANUP:
                    468:                 szAction = RefString(IDS_ACTION_CLEANEDUP);
                    469:                 break;
                    470: 
                    471:             case MH_DELETE:
                    472:                 szAction = RefString(IDS_ACTION_DESTROYED);
                    473:                 break;
                    474: 
                    475:             case MH_KEEP:
                    476:                 szAction = RefString(IDS_ACTION_INCREMENTED);
                    477:                 break;
                    478: 
                    479:             case MH_CREATE:
                    480:                 szAction = RefString(IDS_ACTION_CREATED);
                    481:                 break;
                    482: 
                    483:             default:
                    484:                 DdeUnaccessData(hData);
                    485:                 return(0);
                    486:             }
                    487:             if (pro.fTerse) {
1.1.1.2 ! root      488:                 wsprintf(TBuf, TEXT("[%x:%ld] HSZ %s: %lx(%s)"),
1.1       root      489:                         ((MONHSZSTRUCT FAR *)pData)->hTask,
                    490:                         ((MONHSZSTRUCT FAR *)pData)->dwTime,
1.1.1.2 ! root      491:                         (LPTSTR)szAction,
1.1       root      492:                         ((MONHSZSTRUCT FAR *)pData)->hsz,
1.1.1.2 ! root      493:                         (LPTSTR)((MONHSZSTRUCT FAR *)pData)->str);
1.1       root      494:             } else {
1.1.1.2 ! root      495:                 wsprintf(TBuf,
        !           496:                        TEXT("Task:0x%x, Time:%ld, String Handle %s: %lx(%s)"),
1.1       root      497:                         ((MONHSZSTRUCT FAR *)pData)->hTask,
                    498:                         ((MONHSZSTRUCT FAR *)pData)->dwTime,
1.1.1.2 ! root      499:                         (LPTSTR)szAction,
1.1       root      500:                         ((MONHSZSTRUCT FAR *)pData)->hsz,
1.1.1.2 ! root      501:                         (LPTSTR)((MONHSZSTRUCT FAR *)pData)->str);
1.1       root      502:             }
                    503:             break;
                    504: 
                    505: 
                    506:         case MF_SENDMSGS:
                    507:         case MF_POSTMSGS:
                    508:             if (fBlockMsg[((MONMSGSTRUCT FAR *)pData)->wMsg - WM_DDE_FIRST]) {
                    509:                 return(0);
                    510:             }
                    511:             if (pro.fTerse) {
                    512:                 wsprintf(TBuf, RefString(IDS_FMT_TRS_MSG1),
                    513:                         ((MONMSGSTRUCT FAR *)pData)->hTask,
                    514:                         ((MONMSGSTRUCT FAR *)pData)->dwTime,
                    515:                         ((MONMSGSTRUCT FAR *)pData)->wParam,
                    516:                         ((MONMSGSTRUCT FAR *)pData)->hwndTo,
                    517:                         (dwData2 == MF_SENDMSGS) ? RefString(IDS_SENT) : RefString(IDS_POSTED),
1.1.1.2 ! root      518:                         (LPTSTR)DdeMsg2String(((MONMSGSTRUCT FAR *)pData)->wMsg));
1.1       root      519:             } else {
                    520:                 wsprintf(TBuf, RefString(IDS_FMT_MSG1),
                    521:                         ((MONMSGSTRUCT FAR *)pData)->hTask, 
                    522:                         ((MONMSGSTRUCT FAR *)pData)->dwTime, 
                    523:                         ((MONMSGSTRUCT FAR *)pData)->hwndTo,
                    524:                         (dwData2 == MF_SENDMSGS) ? RefString(IDS_SENT) : RefString(IDS_POSTED),
1.1.1.2 ! root      525:                         (LPTSTR)DdeMsg2String(((MONMSGSTRUCT FAR *)pData)->wMsg));
1.1       root      526:             }
                    527:             OutputString(TBuf);
                    528:             wsprintf(TBuf, pro.fTerse ? RefString(IDS_FMT_TRS_MSG2) : RefString(IDS_FMT_MSG2), 
                    529:                         ((MONMSGSTRUCT FAR *)pData)->wParam);
                    530:             DisectMsgLP(((MONMSGSTRUCT FAR *)pData)->wMsg, 
                    531:                         ((MONMSGSTRUCT FAR *)pData), 
1.1.1.2 ! root      532:                         &TBuf[lstrlen(TBuf)]);
1.1       root      533:             break;
                    534: 
                    535: 
                    536:         case MF_CALLBACKS:
                    537:             if (fBlockCb[(((MONCBSTRUCT FAR *)pData)->wType & XTYP_MASK) >> XTYP_SHIFT]) {
                    538:                 return(0);
                    539:             }
                    540:             wsprintf(TBuf,
                    541:                     pro.fTerse ? RefString(IDS_FMT_TRS_CB1) : RefString(IDS_FMT_CB1),
                    542:                     ((MONCBSTRUCT FAR *)pData)->hTask,
                    543:                     ((MONCBSTRUCT FAR *)pData)->dwTime,
1.1.1.2 ! root      544:                     (LPTSTR)Type2String(((MONCBSTRUCT FAR *)pData)->wType));
        !           545:             wsprintf(DumpFormat(((MONCBSTRUCT FAR *)pData)->wFmt, &TBuf[lstrlen(TBuf)]),
1.1       root      546:                     pro.fTerse ? RefString(IDS_FMT_TRS_CB2) : RefString(IDS_FMT_CB2),
                    547:                     (UINT)((MONCBSTRUCT FAR *)pData)->hConv,
                    548:                     ((MONCBSTRUCT FAR *)pData)->hsz1,
1.1.1.2 ! root      549:                     (LPTSTR)(psz1 = GetHszName(((MONCBSTRUCT FAR *)pData)->hsz1)),
1.1       root      550:                     ((MONCBSTRUCT FAR *)pData)->hsz2,
1.1.1.2 ! root      551:                     (LPTSTR)(psz2 = GetHszName(((MONCBSTRUCT FAR *)pData)->hsz2)),
1.1       root      552:                     ((MONCBSTRUCT FAR *)pData)->hData, 
                    553:                     ((MONCBSTRUCT FAR *)pData)->dwData1, 
                    554:                     ((MONCBSTRUCT FAR *)pData)->dwData2, 
                    555:                     ((MONCBSTRUCT FAR *)pData)->dwRet);
                    556:             MyFree(psz1);
                    557:             MyFree(psz2);
                    558:             OutputString(TBuf);
                    559:             if (((MONCBSTRUCT FAR *)pData)->dwData1 && 
                    560:                (((MONCBSTRUCT FAR *)pData)->wType == XTYP_CONNECT ||
                    561:                ((MONCBSTRUCT FAR *)pData)->wType == XTYP_WILDCONNECT)) {
                    562:                 // display proposed context
                    563:                 wsprintf(TBuf,
                    564:                     pro.fTerse ? RefString(IDS_FMT_TRS_CTXT1) : RefString(IDS_FMT_CTXT1),
                    565:                     ((MONCBSTRUCT FAR *)pData)->cc.wFlags,
                    566:                     ((MONCBSTRUCT FAR *)pData)->cc.wCountryID,
                    567:                     ((MONCBSTRUCT FAR *)pData)->cc.iCodePage,
                    568:                     ((MONCBSTRUCT FAR *)pData)->cc.dwLangID,
                    569:                     ((MONCBSTRUCT FAR *)pData)->cc.dwSecurity,
                    570:                     ((MONCBSTRUCT FAR *)pData)->cc.qos.ImpersonationLevel,
                    571:                     ((MONCBSTRUCT FAR *)pData)->cc.qos.ContextTrackingMode,
                    572:                     ((MONCBSTRUCT FAR *)pData)->cc.qos.EffectiveOnly);
                    573:                 OutputString(TBuf);
                    574:             }
                    575:             if (((MONCBSTRUCT FAR *)pData)->hData && ((MONCBSTRUCT FAR *)pData)->cbData) {
                    576:                 wsprintf(TBuf, RefString(IDS_INPUT_DATA));
                    577:                 OutputString(TBuf);
                    578:                 DumpData((LPBYTE)((MONCBSTRUCT FAR *)pData)->Data, 
                    579:                                  ((MONCBSTRUCT FAR *)pData)->cbData, 
                    580:                                  TBuf, 
                    581:                                  ((MONCBSTRUCT FAR *)pData)->wFmt);
                    582:                 OutputString(TBuf);
                    583:                 if (cb > MAX_DISPDATA)
                    584:                     OutputString(RefString(IDS_TABDDD));
                    585:                 DdeUnaccessData(((MONCBSTRUCT FAR *)pData)->hData);
                    586:             }
                    587:             if ((((MONCBSTRUCT FAR *)pData)->wType & XCLASS_DATA) && 
                    588:                  ((MONCBSTRUCT FAR *)pData)->dwRet && 
                    589:                  ((MONCBSTRUCT FAR *)pData)->cbData) {
                    590:                 wsprintf(TBuf, RefString(IDS_OUTPUT_DATA));
                    591:                 OutputString(TBuf);
                    592:                 DumpData((LPBYTE)((MONCBSTRUCT FAR *)pData)->Data, 
                    593:                                  ((MONCBSTRUCT FAR *)pData)->cbData, 
                    594:                                  TBuf, 
                    595:                                  ((MONCBSTRUCT FAR *)pData)->wFmt);
                    596:                 OutputString(TBuf);
                    597:                 if (cb > MAX_DISPDATA)
                    598:                     OutputString(RefString(IDS_TABDDD));
                    599:                 DdeUnaccessData(((MONCBSTRUCT FAR *)pData)->dwRet);
                    600:             }
                    601:             DdeUnaccessData(hData);
                    602:             return(0);
                    603:             break;
                    604: 
                    605:         case MF_ERRORS:
                    606:             wsprintf(TBuf, pro.fTerse ? RefString(IDS_FMT_TRS_ER1) : RefString(IDS_FMT_ER1),
                    607:                     ((MONERRSTRUCT FAR *)pData)->hTask,
                    608:                     ((MONERRSTRUCT FAR *)pData)->dwTime, 
                    609:                     ((MONERRSTRUCT FAR *)pData)->wLastError,
1.1.1.2 ! root      610:                     (LPTSTR)Error2String(((MONERRSTRUCT FAR *)pData)->wLastError));
1.1       root      611:             break;
                    612: 
                    613: 
                    614:         case MF_LINKS:
                    615:             psz1 = GetHszName(((MONLINKSTRUCT FAR *)pData)->hszSvc);
                    616:             psz2 = GetHszName(((MONLINKSTRUCT FAR *)pData)->hszTopic);
                    617:             psz3 = GetHszName(((MONLINKSTRUCT FAR *)pData)->hszItem);
                    618:             if (!GetClipboardFormatName(((MONLINKSTRUCT FAR *)pData)->wFmt, TBuf2, BUFFER_SIZE))
1.1.1.2 ! root      619:                 lstrcpy(TBuf2, pdf(((MONLINKSTRUCT FAR *)pData)->wFmt));
        !           620:             if (!lstrcmp(RefString(IDS_HUH), TBuf2)) {
        !           621:                 wsprintf(TBuf2, TEXT("%d"), ((MONLINKSTRUCT FAR *)pData)->wFmt);
1.1       root      622:             }
                    623: 
1.1.1.2 ! root      624:             wsprintf(TBuf, TEXT("%s\t%s\t%s\t%s\t%s\t%lx\t%lx"),
        !           625:                     (LPTSTR)psz1, (LPTSTR)psz2, (LPTSTR)psz3,
        !           626:                     (LPTSTR)TBuf2,
1.1       root      627:                     ((MONLINKSTRUCT FAR *)pData)->fNoData ? 
                    628:                      RefString(IDS_WARM) : RefString(IDS_HOT),
                    629:                     ((MONLINKSTRUCT FAR *)pData)->hConvClient, 
                    630:                     ((MONLINKSTRUCT FAR *)pData)->hConvServer);
                    631: 
                    632:             if (((MONLINKSTRUCT FAR *)pData)->fEstablished) {
                    633:                 AddMCLBText(TBuf, TBuf, hwndTrack[IT_LINKS]);
                    634:             } else {
                    635:                 DeleteMCLBText(TBuf, hwndTrack[IT_LINKS]);
                    636:             }
                    637: 
                    638:             MyFree(psz1);
                    639:             MyFree(psz2);
                    640:             MyFree(psz3);
                    641:             DdeUnaccessData(hData);
                    642:             return(0);
                    643: 
                    644: 
                    645:         case MF_CONV:
                    646:             psz1 = GetHszName(((MONCONVSTRUCT FAR *)pData)->hszSvc);
                    647:             psz2 = GetHszName(((MONCONVSTRUCT FAR *)pData)->hszTopic);
                    648: 
1.1.1.2 ! root      649:             wsprintf(TBuf, TEXT("%s\t%s\t%lx\t%lx"),
        !           650:                     (LPTSTR)psz1, (LPTSTR)psz2, 
1.1       root      651:                     ((MONCONVSTRUCT FAR *)pData)->hConvClient,
                    652:                     ((MONCONVSTRUCT FAR *)pData)->hConvServer);
                    653: 
                    654:             if (((MONCONVSTRUCT FAR *)pData)->fConnect) {
                    655:                 AddMCLBText(TBuf, TBuf, hwndTrack[IT_CONVS]);
                    656:             } else {
                    657:                 DeleteMCLBText(TBuf, hwndTrack[IT_CONVS]);
                    658:             }
                    659: 
                    660:             MyFree(psz1);
                    661:             MyFree(psz2);
                    662:             DdeUnaccessData(hData);
                    663:             return(0);
                    664: 
                    665: 
                    666:         default:
1.1.1.2 ! root      667:             lstrcpy(TBuf, RefString(IDS_UNKNOWN_CALLBACK));
1.1       root      668:         }
                    669:         DdeUnaccessData(hData);
                    670:         OutputString(TBuf);
                    671:     }
                    672:     break;
                    673: 
                    674:     case XTYP_REGISTER:
                    675:     case XTYP_UNREGISTER:
                    676:         if (!pro.fTrack[IT_SVRS]) {
                    677:             return(0);
                    678:         }
                    679:         psz1 = GetHszName(hsz1);
                    680:         psz2 = GetHszName(hsz2);
1.1.1.2 ! root      681:         wsprintf(TBuf, TEXT("%s\t%s"), (LPTSTR)psz1, (LPTSTR)psz2);
1.1       root      682:         if (wType == XTYP_REGISTER) {
                    683:             AddMCLBText(NULL, TBuf, hwndTrack[IT_SVRS]);
                    684:         } else {
                    685:             DeleteMCLBText(TBuf, hwndTrack[IT_SVRS]);
                    686:         }
                    687:         MyFree(psz1);
                    688:         MyFree(psz2);
                    689:         break;
                    690:     }
                    691:     return(0);
                    692: }
                    693: 
                    694: 
1.1.1.2 ! root      695: LPTSTR DisectMsgLP(UINT msg, MONMSGSTRUCT *pmms,  LPTSTR pszBuf)
1.1       root      696: {
                    697:     static LONG m2t[] = {
                    698: 
                    699:     /*              LOW                       HIGH */
                    700: 
                    701:         MAKELONG(T_APP | T_ATOM,        T_TOPIC | T_ATOM),  // WM_DDE_INITIATE
                    702:         0,                                                  // WM_DDE_TERMINATE
                    703:         MAKELONG(T_OPTIONHANDLE,        T_ITEM | T_ATOM),   // WM_DDE_ADVISE
                    704:         MAKELONG(T_FORMAT,              T_ITEM | T_ATOM),   // WM_DDE_UNADVISE
                    705:         MAKELONG(T_APP | T_ATOM | T_OR | T_STATUS,
                    706:                                         T_TOPIC | T_ITEM | T_ATOM | T_OR | T_STRINGHANDLE),
                    707:                                                             // WM_DDE_ACK
                    708:         MAKELONG(T_DATAHANDLE,          T_ITEM | T_ATOM),   // WM_DDE_DATA
                    709:         MAKELONG(T_FORMAT,              T_ITEM | T_ATOM),   // WM_DDE_REQUEST
                    710:         MAKELONG(T_DATAHANDLE,          T_ITEM | T_ATOM),   // WM_DDE_POKE
                    711:         MAKELONG(0,                     T_STRINGHANDLE),    // WM_DDE_EXECUTE
                    712:     };
                    713: 
                    714:     // ASSUMED: msg is a valid DDE message!!!
                    715: 
                    716:     pszBuf = DisectWord(LOWORD(m2t[msg - WM_DDE_FIRST]), 
                    717:                         pmms->dmhd.uiLo, &pmms->dmhd, pszBuf);
                    718:     *pszBuf++ = '\r';
                    719:     *pszBuf++ = '\n';
                    720:     *pszBuf++ = '\t';
                    721:     return(DisectWord(HIWORD(m2t[msg - WM_DDE_FIRST]), 
                    722:                         pmms->dmhd.uiHi, &pmms->dmhd, pszBuf));
                    723: }
                    724: 
                    725: 
                    726: 
                    727: 
                    728: /*
                    729:  * Allocates local memory for and retrieves the string form of an HSZ.
                    730:  * Returns a pointer to the local memory or NULL if failure.
                    731:  * The string must be freed via MyFree().
                    732:  */
1.1.1.2 ! root      733: LPTSTR GetHszName(HSZ hsz)
1.1       root      734: {
1.1.1.2 ! root      735:     LPTSTR psz;
1.1       root      736:     UINT cb;
                    737: 
                    738:     cb = (UINT)DdeQueryString(idInst, hsz, NULL, 0, 0) + 1;
1.1.1.2 ! root      739:     psz = LocalAlloc (LPTR, sizeof(TCHAR) * cb);
1.1       root      740:     DdeQueryString(idInst, hsz, psz, cb, 0);
                    741:     return(psz);
                    742: }
                    743: 
                    744: 
                    745: 
                    746: 
1.1.1.2 ! root      747: LPTSTR DisectWord( UINT type,
1.1       root      748:                  UINT data,
                    749:                  DDEML_MSG_HOOK_DATA *pdmhd,
1.1.1.2 ! root      750:                 LPTSTR pstr)
1.1       root      751: {
                    752:     UINT wT;
1.1.1.2 ! root      753:     TCHAR szData[32]; // for truncating strings w/o disturbing the hDdeData
1.1       root      754: 
                    755:     *pstr = '\0';   // in case we do nothing.
                    756: 
                    757:     if (type & T_ATOM) {
1.1.1.2 ! root      758:         wT = GlobalGetAtomName((ATOM)data, (LPTSTR)pstr, 25);
1.1       root      759:         if (wT || data == 0) {
                    760:             if (type & T_APP) {
1.1.1.2 ! root      761:                 lstrcpy(pstr, RefString(IDS_APPIS));
        !           762:                 pstr += lstrlen(pstr);
1.1       root      763:             }
                    764: 
                    765:             if (type & T_TOPIC) {
1.1.1.2 ! root      766:                 lstrcpy(pstr, RefString(IDS_TOPICIS));
        !           767:                 pstr += lstrlen(pstr);
1.1       root      768:             }
                    769: 
                    770:             if (type & T_ITEM) {
1.1.1.2 ! root      771:                 lstrcpy(pstr, RefString(IDS_ITEMIS));
        !           772:                 pstr += lstrlen(pstr);
1.1       root      773:             }
                    774:         }
                    775:         if (wT) {
1.1.1.2 ! root      776:             wsprintf(pstr, TEXT("0x%x(\""), data);
        !           777:             pstr += lstrlen(pstr);
        !           778:             GlobalGetAtomName((ATOM)data, (LPTSTR)pstr, 25);
1.1       root      779:             pstr += wT;
                    780:             if (wT == 25) {
                    781:                 *pstr++ = '.';
                    782:                 *pstr++ = '.';
                    783:                 *pstr++ = '.';
                    784:             }
                    785:             *pstr++ = '\"';
                    786:             *pstr++ = ')';
                    787:             *pstr = '\0';
                    788:             type &= ~(T_OR | T_STRINGHANDLE);  // its an atom, so its not an object!
                    789:         } else if (data == 0) {     // could be a wild atom
                    790:             *pstr++ = '*';
                    791:             *pstr = '\0';
                    792:         } else if (type & T_OR) {
                    793:             type &= ~T_OR;   // not an atom, must be somthin else.
                    794:         } else {
1.1.1.2 ! root      795:             wsprintf(pstr, TEXT("Bad Atom (0x%x)"), data);
        !           796:             pstr += lstrlen(pstr);
1.1       root      797:         }
                    798:     }
                    799: 
                    800:     if (type & T_OR) {
1.1.1.2 ! root      801:         lstrcpy(pstr, RefString(IDS_OR));
        !           802:         pstr += lstrlen(pstr);
1.1       root      803:     }
                    804: 
                    805: 
                    806:     if (type & T_OPTIONHANDLE) {
                    807:         if (pdmhd->cbData >= 4) {
                    808:             wsprintf(pstr, pro.fTerse ? RefString(IDS_FMT_TRS_STATUSIS) : RefString(IDS_FMT_STATUSIS), LOWORD(pdmhd->Data[0]));
1.1.1.2 ! root      809:             pstr += lstrlen(pstr);
1.1       root      810:             if (LOWORD(pdmhd->Data[0]) & DDE_FACKREQ) {
1.1.1.2 ! root      811:                 lstrcpy(pstr, RefString(IDS_FACKREQ));
        !           812:                 pstr += lstrlen(pstr);
1.1       root      813:             }
                    814:             if (LOWORD(pdmhd->Data[0]) & DDE_FDEFERUPD) {
1.1.1.2 ! root      815:                 lstrcpy(pstr, RefString(IDS_DEFERUPD));
        !           816:                 pstr += lstrlen(pstr);
1.1       root      817:             }
                    818:             *pstr++ = ')';
                    819:             *pstr++ = ' ';
                    820:             pstr = DumpFormat((UINT)HIWORD(pdmhd->Data[0]), pstr);
                    821:         }
                    822:     }
                    823: 
                    824:     if (type & T_FORMAT) {
                    825:         pstr = DumpFormat(data, pstr);
                    826:     }
                    827: 
                    828:     if (type & T_STATUS) {
                    829:         wsprintf(pstr, pro.fTerse ? RefString(IDS_FMT_TRS_STATUSIS) : RefString(IDS_FMT_STATUSIS), LOWORD(data));
1.1.1.2 ! root      830:         pstr += lstrlen(pstr);
1.1       root      831:         if (data & DDE_FACK) {
1.1.1.2 ! root      832:             lstrcpy(pstr, RefString(IDS_FACK));
        !           833:             pstr += lstrlen(pstr);
1.1       root      834:         }
                    835:         if (data & DDE_FBUSY) {
1.1.1.2 ! root      836:             lstrcpy(pstr, RefString(IDS_FBUSY));
        !           837:             pstr += lstrlen(pstr);
1.1       root      838:         }
                    839:         *pstr++ = ')';
                    840:         *pstr = '\0';
                    841:     }
                    842: 
                    843:     if (type & T_STRINGHANDLE && pdmhd->cbData) {
                    844:         memcpy(szData, pdmhd->Data, min(32, pdmhd->cbData));
                    845:         szData[31] = '\0';
                    846:         wsprintf(pstr, pro.fTerse ? 
                    847:                     RefString(IDS_FMT_TRS_EXEC1) : RefString(IDS_FMT_EXEC1), szData);
1.1.1.2 ! root      848:         pstr += lstrlen(pstr);
1.1       root      849:         *pstr = '\0';
                    850:     }
                    851: 
                    852:     if (type & T_DATAHANDLE && pdmhd->cbData) {
                    853:         wsprintf(pstr, pro.fTerse ? 
                    854:                     RefString(IDS_FMT_TRS_STATUSIS) : RefString(IDS_FMT_STATUSIS), 
                    855:                     LOWORD(pdmhd->Data[0]));
1.1.1.2 ! root      856:         pstr += lstrlen(pstr);
1.1       root      857:         if (LOWORD(pdmhd->Data[0]) & DDE_FRELEASE) {
1.1.1.2 ! root      858:             lstrcpy(pstr, RefString(IDS_FRELEASE));
        !           859:             pstr += lstrlen(pstr);
1.1       root      860:         }
                    861:         if (LOWORD(pdmhd->Data[0]) & DDE_FREQUESTED) {
                    862:             lstrcpy(pstr, RefString(IDS_FREQUESTED));
1.1.1.2 ! root      863:             pstr += lstrlen(pstr);
1.1       root      864:         }
                    865:         *pstr++ = ')';
                    866:         *pstr++ = ' ';
                    867:         pstr = DumpFormat(HIWORD(pdmhd->Data[0]), pstr);
1.1.1.2 ! root      868:         lstrcpy(pstr, pro.fTerse ? RefString(IDS_FMT_TRS_DATAIS1) : RefString(IDS_FMT_DATAIS1));
        !           869:         pstr += lstrlen(pstr);
1.1       root      870:         pstr = DumpData((LPBYTE)&pdmhd->Data[1], min(28, pdmhd->cbData - 4),
                    871:                 pstr, HIWORD(pdmhd->Data[0]));
                    872:     }
                    873:     return(pstr);
                    874: }
                    875: 
                    876: 
1.1.1.2 ! root      877: LPTSTR pdf(UINT fmt)
1.1       root      878: {
                    879:     INT i;
                    880:     static struct {
                    881:         UINT fmt;
1.1.1.2 ! root      882:         LPTSTR psz;
1.1       root      883:     } fmts[] = {
1.1.1.2 ! root      884:         { CF_TEXT             ,     TEXT("CF_TEXT")           }   ,
        !           885:         { CF_BITMAP           ,     TEXT("CF_BITMAP")         }   ,
        !           886:         { CF_METAFILEPICT     ,     TEXT("CF_METAFILEPICT")   }   ,
        !           887:         { CF_ENHMETAFILE      ,     TEXT("CF_ENHMETAFILE")    }   ,
        !           888:         { CF_SYLK             ,     TEXT("CF_SYLK")           }   ,
        !           889:         { CF_DIF              ,     TEXT("CF_DIF")            }   ,
        !           890:         { CF_TIFF             ,     TEXT("CF_TIFF")           }   ,
        !           891:         { CF_OEMTEXT          ,     TEXT("CF_OEMTEXT")        }   ,
        !           892:         { CF_DIB              ,     TEXT("CF_DIB")            }   ,
        !           893:         { CF_PALETTE          ,     TEXT("CF_PALETTE")        }   ,
1.1       root      894:     };
                    895:     for (i = 0; i < 10; i++)
                    896:         if (fmts[i].fmt == fmt)
                    897:             return(fmts[i].psz);
                    898:     return(RefString(IDS_HUH));
                    899: }
                    900: 
                    901: 
                    902: 
1.1.1.2 ! root      903: LPTSTR DumpFormat(UINT fmt, LPTSTR pstr)
1.1       root      904: {
                    905:     UINT cb;
                    906: 
1.1.1.2 ! root      907:     wsprintf(pstr, TEXT("fmt=0x%x(\""), (WORD)fmt);
        !           908:     pstr += lstrlen(pstr);
1.1       root      909:     if (cb = GetClipboardFormatName(fmt, pstr, 25)) {
                    910:         pstr += cb;
                    911:         *pstr++ = '\"';
                    912:         *pstr++ = ')';
                    913:     } else {
1.1.1.2 ! root      914:         wsprintf(pstr, TEXT("%s\")"), (LPTSTR)pdf(fmt));
        !           915:         pstr += lstrlen(pstr);
1.1       root      916:     }
                    917:     return(pstr);
                    918: }
                    919: 
                    920: 
                    921: 
1.1.1.2 ! root      922: LPTSTR DumpData(LPBYTE pData, UINT cb, TCHAR *szBuf, UINT fmt)
1.1       root      923: {
                    924:     register INT i;
1.1.1.2 ! root      925:     LPTSTR psz = szBuf;
1.1       root      926: 
                    927: 
                    928:     while (cb) {
                    929:         if (fmt == CF_TEXT) {
                    930:             *szBuf++ = '\t';
                    931:             *szBuf++ = '\"';
1.1.1.2 ! root      932:             memcpy(szBuf, pData, cb);
1.1       root      933:             szBuf[cb - 2] = '\0';
1.1.1.2 ! root      934:             lstrcat(szBuf, TEXT("\""));
1.1       root      935:             cb = 0;
                    936:         } else {
                    937:             memset(szBuf, ' ', 80);
                    938:             szBuf[0] = '\t';
                    939:             i = 0;
                    940:             while (cb && (i < 16)) {
1.1.1.2 ! root      941:                 wsprintf(&szBuf[i * 3 + 1], TEXT("%02x "), pData[0]);
        !           942:                 wsprintf(&szBuf[17 * 3 + i + 1], TEXT("%c"), MPRT(pData[0]));
1.1       root      943:                 pData++;
                    944:                 cb--;
                    945:                 i++;
                    946:             }
                    947:             szBuf[i * 3 + 1] = ' ';
                    948:             szBuf[17 * 3 + i + 1] = ' ';
                    949:             szBuf[68] = '\0';
                    950:         }
1.1.1.2 ! root      951:         szBuf += lstrlen(szBuf);
1.1       root      952:     }
                    953:     return(szBuf);
                    954: }
                    955: 
                    956: 
                    957: 
1.1.1.2 ! root      958: LPTSTR Error2String(UINT error)
1.1       root      959: {
1.1.1.2 ! root      960:     static TCHAR szErr[23];
1.1       root      961: 
                    962:     if (error == 0) {
1.1.1.2 ! root      963:         lstrcpy(szErr, RefString(IDS_ZERO));
1.1       root      964:     } else if (error > DMLERR_LAST || error < DMLERR_FIRST) {
1.1.1.2 ! root      965:         lstrcpy(szErr, RefString(IDS_HUH));
1.1       root      966:     } else {
1.1.1.2 ! root      967:         lstrcpy(szErr, apszResources[IDS_ERRST0 + error - DMLERR_FIRST]);
1.1       root      968:     }
                    969:     return(szErr);
                    970: }
                    971: 
                    972: 
                    973: 
1.1.1.2 ! root      974: LPTSTR DdeMsg2String(UINT msg)
1.1       root      975: {
1.1.1.2 ! root      976:     static TCHAR szBadMsg[10];
1.1       root      977: 
                    978:     if (msg < WM_DDE_FIRST || msg > WM_DDE_LAST) {
1.1.1.2 ! root      979:        wsprintf (szBadMsg, TEXT("%ld"), szBadMsg);
        !           980:        return (szBadMsg);
        !           981: //        return((LPTSTR)itoa(msg, szBadMsg, 10));
1.1       root      982:     } else {
                    983:         return(apszResources[IDS_MSG0 + msg - WM_DDE_FIRST]);
                    984:     }
                    985: }
                    986: 
                    987: 
                    988: 
1.1.1.2 ! root      989: VOID OutputString(LPTSTR pstr)
1.1       root      990: {
                    991:     if (pro.fOutput[IO_FILE] & fhOutput) {
1.1.1.2 ! root      992:         _lwrite(fhOutput, (LPCSTR) pstr, lstrlen(pstr));
        !           993:         _lwrite(fhOutput, (LPCSTR) RefString(IDS_CRLF), 2);
1.1       root      994:         flushall();
                    995:     }
                    996:     if (pro.fOutput[IO_DEBUG]) {
1.1.1.2 ! root      997:         OutputDebugString((LPTSTR)pstr);
1.1       root      998:         OutputDebugString(RefString(IDS_CRLF));
                    999:     }
                   1000:     if (pro.fOutput[IO_SCREEN]) {
                   1001:         if (IsWindow(hWndString))
                   1002:             DrawString(hWndString, pstr);
                   1003:     }
                   1004: }
                   1005: 
                   1006: 
                   1007: 
                   1008: BOOL SetFilters()
                   1009: {
                   1010:     UINT cbf;
                   1011: 
                   1012:     cbf = 0;
                   1013:     if (pro.fTrack[IT_HSZS] || pro.fFilter[IF_HSZ])
                   1014:         cbf |= MF_HSZ_INFO;
                   1015:     if (pro.fTrack[IT_LINKS])
                   1016:         cbf |= MF_LINKS;
                   1017:     if (pro.fTrack[IT_CONVS])
                   1018:         cbf |= MF_CONV;
                   1019:     if (pro.fFilter[IF_SEND])
                   1020:         cbf |= MF_SENDMSGS;
                   1021:     if (pro.fFilter[IF_POST])
                   1022:         cbf |= MF_POSTMSGS;
                   1023:     if (pro.fFilter[IF_CB])
                   1024:         cbf |= MF_CALLBACKS;
                   1025:     if (pro.fFilter[IF_ERR])
                   1026:         cbf |= MF_ERRORS;
                   1027:     return((BOOL)DdeInitialize(&idInst, pfnDdeCallback, APPCLASS_MONITOR | cbf, 0));
                   1028: }
                   1029: 
                   1030: 
                   1031: 
                   1032: 
                   1033: 
                   1034: /*
                   1035:  * This dialog returns a file handle to the opened file name given or NULL
                   1036:  * if cancel.
                   1037:  */
                   1038: 
                   1039: BOOL CALLBACK OpenDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
                   1040: {
                   1041:     HFILE  fh;
                   1042:     lParam;
                   1043: 
                   1044:     switch (message) {
                   1045:         case WM_INITDIALOG:
1.1.1.2 ! root     1046:             SetDlgItemText(hDlg, IDC_EDIT, (LPTSTR)OpenName);
1.1       root     1047:             SendDlgItemMessage(hDlg, IDC_EDIT, EM_SETSEL,
                   1048:                     GET_EM_SETSEL_MPS(0, 0x7fff));
                   1049:             SetFocus(GetDlgItem(hDlg, IDC_EDIT));
                   1050:             return (FALSE); /* Indicates the focus is set to a control */
                   1051:             break;
                   1052: 
                   1053:         case WM_COMMAND:
                   1054:             switch (GET_WM_COMMAND_ID(wParam, lParam)) {
                   1055:                 case IDOK:
                   1056:                     GetDlgItemText(hDlg, IDC_EDIT, TBuf, MAX_FNAME);
                   1057:                     GetFullPathName(TBuf, sizeof(OpenName), OpenName, (LPTSTR *)TBuf2);
1.1.1.2 ! root     1058:                     fh = _lcreat((LPCSTR) OpenName, 0);
1.1       root     1059:                     if (fh == -1) {
                   1060:                         MessageBox(hDlg, RefString(IDS_INVALID_FNAME),
                   1061:                             NULL, MB_OK | MB_ICONHAND);
                   1062:                         return (TRUE);
                   1063:                     }
                   1064: 
                   1065:                     EndDialog(hDlg, (INT)fh);
                   1066:                     return (TRUE);
                   1067: 
                   1068:                 case IDCANCEL:
                   1069:                     EndDialog(hDlg, 0);
                   1070:                     return (FALSE);
                   1071:             }
                   1072:             break;
                   1073:     }
                   1074:     return FALSE;
                   1075: }
                   1076: 
                   1077: BOOL CALLBACK FilterDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
                   1078: {
                   1079:     int i;
                   1080:     lParam;
                   1081: 
                   1082:     switch (message) {
                   1083:     case WM_INITDIALOG:
                   1084:             for (i = IDRB_WM_DDE_INITIATE; i <= IDRB_WM_DDE_EXECUTE; i++) {
                   1085:                 CheckDlgButton(hDlg, i, !fBlockMsg[i - IDRB_WM_DDE_INITIATE]);
                   1086:             }
                   1087:             for (i = IDRB_XTYP_ERROR; i <= IDRB_XTYP_WILDCONNECT; i++) {
                   1088:                 CheckDlgButton(hDlg, i, !fBlockCb[i - IDRB_XTYP_ERROR]);
                   1089:             }
                   1090:             CheckDlgButton(hDlg, IDRB_TERSE, pro.fTerse);
                   1091:             break;
                   1092: 
                   1093:         case WM_COMMAND:
                   1094:             switch (GET_WM_COMMAND_ID(wParam, lParam)) {
                   1095:                 case IDOK:
                   1096:                     for (i = IDRB_WM_DDE_INITIATE; i <= IDRB_WM_DDE_EXECUTE; i++) {
                   1097:                         fBlockMsg[i - IDRB_WM_DDE_INITIATE] = !IsDlgButtonChecked(hDlg, i);
                   1098:                     }
                   1099:                     for (i = IDRB_XTYP_ERROR; i <= IDRB_XTYP_WILDCONNECT; i++) {
                   1100:                         fBlockCb[i - IDRB_XTYP_ERROR] = !IsDlgButtonChecked(hDlg, i);
                   1101:                     }
                   1102:                     pro.fTerse = IsDlgButtonChecked(hDlg, IDRB_TERSE);
                   1103:                     EndDialog(hDlg, TRUE);
                   1104:                     break;
                   1105: 
                   1106:                 case IDCANCEL:
                   1107:                     EndDialog(hDlg, 0);
                   1108:                     break;
                   1109:             }
                   1110:             break;
                   1111:     }
                   1112:     return FALSE;
                   1113: }
                   1114: 
                   1115: 
                   1116: 
                   1117: 
                   1118: VOID GetProfile()
                   1119: {
                   1120:     pro.fOutput[IO_FILE]    = GetProfileBoolean(RefString(IDS_PROF_OUT_FILE),FALSE);
                   1121:     pro.fOutput[IO_DEBUG]   = GetProfileBoolean(RefString(IDS_PROF_OUT_DEBUG),FALSE);
                   1122:     pro.fOutput[IO_SCREEN]  = GetProfileBoolean(RefString(IDS_PROF_OUT_SCREEN),FALSE);
                   1123: 
                   1124:     pro.fFilter[IF_HSZ]     = GetProfileBoolean(RefString(IDS_PROF_MONITOR_STRINGHANDLES),FALSE);
                   1125:     pro.fFilter[IF_SEND]    = GetProfileBoolean(RefString(IDS_PROF_MONITOR_INITIATES), FALSE);
                   1126:     pro.fFilter[IF_POST]    = GetProfileBoolean(RefString(IDS_PROF_MONITOR_DDE_MESSAGES), FALSE);
                   1127:     pro.fFilter[IF_CB]      = GetProfileBoolean(RefString(IDS_PROF_MONITOR_CALLBACKS), FALSE);
                   1128:     pro.fFilter[IF_ERR]     = GetProfileBoolean(RefString(IDS_PROF_MONITOR_ERRORS),FALSE);
                   1129: 
                   1130:     pro.fTrack[IT_HSZS]     = GetProfileBoolean(RefString(IDS_PROF_TRACK_STRINGHANDLES), FALSE);
                   1131:     pro.fTrack[IT_LINKS]    = GetProfileBoolean(RefString(IDS_PROF_TRACK_LINKS), FALSE);
                   1132:     pro.fTrack[IT_CONVS]    = GetProfileBoolean(RefString(IDS_PROF_TRACK_CONVERSATIONS), FALSE);
                   1133:     pro.fTrack[IT_SVRS]     = GetProfileBoolean(RefString(IDS_PROF_TRACK_SERVICES), FALSE);
                   1134: 
                   1135:     pro.fTerse              = GetProfileBoolean(RefString(IDS_PROF_TERSE), FALSE);
                   1136: }
                   1137: 
                   1138: 
                   1139: 
                   1140: VOID SaveProfile()
                   1141: {
                   1142:     SetProfileBoolean(RefString(IDS_PROF_OUT_FILE), pro.fOutput[IO_FILE]  );
                   1143:     SetProfileBoolean(RefString(IDS_PROF_OUT_DEBUG), pro.fOutput[IO_DEBUG] );
                   1144:     SetProfileBoolean(RefString(IDS_PROF_OUT_SCREEN), pro.fOutput[IO_SCREEN]);
                   1145: 
                   1146:     SetProfileBoolean(RefString(IDS_PROF_MONITOR_STRINGHANDLES), pro.fFilter[IF_HSZ]   );
                   1147:     SetProfileBoolean(RefString(IDS_PROF_MONITOR_INITIATES), pro.fFilter[IF_SEND]  );
                   1148:     SetProfileBoolean(RefString(IDS_PROF_MONITOR_DDE_MESSAGES), pro.fFilter[IF_POST]  );
                   1149:     SetProfileBoolean(RefString(IDS_PROF_MONITOR_CALLBACKS), pro.fFilter[IF_CB]    );
                   1150:     SetProfileBoolean(RefString(IDS_PROF_MONITOR_ERRORS), pro.fFilter[IF_ERR]   );
                   1151: 
                   1152:     SetProfileBoolean(RefString(IDS_PROF_TRACK_STRINGHANDLES), pro.fTrack[IT_HSZS]   );
                   1153:     SetProfileBoolean(RefString(IDS_PROF_TRACK_LINKS), pro.fTrack[IT_LINKS]  );
                   1154:     SetProfileBoolean(RefString(IDS_PROF_TRACK_CONVERSATIONS), pro.fTrack[IT_CONVS]  );
                   1155:     SetProfileBoolean(RefString(IDS_PROF_TRACK_SERVICES), pro.fTrack[IT_SVRS]   );
                   1156: 
                   1157:     SetProfileBoolean(RefString(IDS_PROF_TERSE), pro.fTerse   );
                   1158: }
                   1159: 
                   1160: 
                   1161: 
                   1162: 
1.1.1.2 ! root     1163: BOOL GetProfileBoolean(LPTSTR pszKey, BOOL fDefault)
1.1       root     1164: {
                   1165:     GetPrivateProfileString(RefString(IDS_TITLE), pszKey, 
                   1166:                     fDefault ? RefString(IDS_YES) : RefString(IDS_NO), TBuf,
                   1167:                     sizeof(TBuf), RefString(IDS_INIFNAME));
1.1.1.2 ! root     1168:     return(lstrcmpi(RefString(IDS_NO), TBuf));
1.1       root     1169: }
                   1170: 
                   1171: 
                   1172: 
1.1.1.2 ! root     1173: VOID SetProfileBoolean(LPTSTR pszKey, BOOL fSet)
1.1       root     1174: {
                   1175:     WritePrivateProfileString(RefString(IDS_TITLE), pszKey, 
                   1176:                     fSet ? RefString(IDS_YES) : RefString(IDS_NO), 
                   1177:                     RefString(IDS_INIFNAME));
                   1178: }
                   1179: 
                   1180: /*
                   1181:  * Generic dialog invocation routine.  Handles procInstance stuff and param
                   1182:  * passing.
                   1183:  */
                   1184: INT FAR DoDialog(
1.1.1.2 ! root     1185:                 LPTSTR lpTemplateName,
1.1       root     1186:                 DLGPROC lpDlgProc,
                   1187:                 UINT param,
                   1188:                 BOOL fRememberFocus,
                   1189:                 HWND hwndParent,
                   1190:                 HANDLE hInst)
                   1191: {
                   1192:     UINT wRet;
                   1193:     HWND hwndFocus;
                   1194: 
                   1195:     if (fRememberFocus)
                   1196:         hwndFocus = GetFocus();
                   1197:     lpDlgProc = (DLGPROC)MakeProcInstance(lpDlgProc, hInst);
1.1.1.2 ! root     1198:     wRet = DialogBoxParam(hInst, (LPCTSTR)lpTemplateName, hwndParent,
1.1       root     1199:             lpDlgProc, param);
                   1200:     FreeProcInstance((FARPROC)lpDlgProc);
                   1201:     if (fRememberFocus)
                   1202:         SetFocus(hwndFocus);
                   1203:     return wRet;
                   1204: }
                   1205: 
                   1206: 
                   1207: BOOL CALLBACK MarkDlgProc(
                   1208:                         HWND hwnd,
                   1209:                         UINT msg,
                   1210:                         WPARAM wParam,
                   1211:                         LPARAM lParam)
                   1212: {
1.1.1.2 ! root     1213:     TCHAR szT[MAX_MARK + 1];
1.1       root     1214:     lParam;
                   1215: 
                   1216:     switch (msg){
                   1217:     case WM_INITDIALOG:
                   1218:         SetWindowText(hwnd, RefString(IDS_MARKDLGTITLE));
                   1219:         SendDlgItemMessage(hwnd, IDEF_VALUE, EM_LIMITTEXT, MAX_MARK, 0);
                   1220:         SetDlgItemText(hwnd, IDEF_VALUE, RefString(IDS_SEPERATOR));
                   1221:         SetDlgItemText(hwnd, IDTX_VALUE, RefString(IDS_MARKTEXT));
                   1222:         return(1);
                   1223:         break;
                   1224: 
                   1225:     case WM_COMMAND:
                   1226:         switch (GET_WM_COMMAND_ID(wParam, lParam)) {
                   1227:         case IDOK:
                   1228:             GetDlgItemText(hwnd, IDEF_VALUE, szT, MAX_MARK);
                   1229:             OutputString(szT);
                   1230:             // fall through
                   1231:         case IDCANCEL:
                   1232:             EndDialog(hwnd, 0);
                   1233:             break;
                   1234: 
                   1235:         default:
                   1236:             return(FALSE);
                   1237:         }
                   1238:         break;
                   1239:     }
                   1240:     return(FALSE);
                   1241: }

unix.superglobalmegacorp.com

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