WM.C
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:37k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /******************************************************************************
  2. *       This is a part of the Microsoft Source Code Samples. 
  3. *       Copyright (C) 1993-1997 Microsoft Corporation.
  4. *       All rights reserved. 
  5. *       This source code is only intended as a supplement to 
  6. *       Microsoft Development Tools and/or WinHelp documentation.
  7. *       See these sources for detailed information regarding the 
  8. *       Microsoft samples programs.
  9. ******************************************************************************/
  10. /*****************************************************************************
  11. *
  12. * Module: wm.c
  13. *
  14. * Contains functions that lookup and format messages received by the
  15. * Windows debugging Spy SDK applet.
  16. *
  17. * Functions:
  18. *
  19. *    CalculatePrintfTabs()
  20. *    PrintMsg()
  21. *    DecodeGeneric()
  22. *    MsgCmp()
  23. *    mprintf()
  24. *
  25. * Comments:
  26. *
  27. *****************************************************************************/
  28. #include "spy.h"
  29. #include <stdlib.h>
  30. #include <dde.h>
  31. PRIVATE CHAR szFormatName[] = "%08Xt%st%08Xt%08Xrn";
  32. PRIVATE CHAR szFormatUSER[] = "%08XtWM_USER+%dt%08Xt%08Xrn";
  33. PRIVATE CHAR szFormatUnknown[] = "%08XtWM_%04Xt%08Xt%08Xrn";
  34. VOID DecodeGeneric(HWND hwnd, UINT msg, PSPYMSGDATA psmd) {}
  35. //
  36. // Message description table.  Describes each message that can be spied on.
  37. // This table must be kept in sorted order.
  38. //
  39. MSGDESC gaMsgs[] =
  40. {
  41.     { "WM_NULL", WM_NULL,                                   // 0x0000
  42.         0, DecodeGeneric },
  43.     { "WM_CREATE", WM_CREATE,                               // 0x0001
  44.         0, DecodeGeneric },
  45.     { "WM_DESTROY", WM_DESTROY,                             // 0x0002
  46.         0, DecodeGeneric },
  47.     { "WM_MOVE", WM_MOVE,                                   // 0x0003
  48.         0, DecodeGeneric },
  49.     { "WM_SIZE", WM_SIZE,                                   // 0x0005
  50.         0, DecodeGeneric },
  51.     { "WM_ACTIVATE", WM_ACTIVATE,                           // 0x0006
  52.         0, DecodeGeneric },
  53.     { "WM_SETFOCUS", WM_SETFOCUS,                           // 0x0007
  54.         0, DecodeGeneric },
  55.     { "WM_KILLFOCUS", WM_KILLFOCUS,                         // 0x0008
  56.         0, DecodeGeneric },
  57.     { "WM_ENABLE", WM_ENABLE,                               // 0x000A
  58.         0, DecodeGeneric },
  59.     { "WM_SETREDRAW", WM_SETREDRAW,                         // 0x000B
  60.         0, DecodeGeneric },
  61.     { "WM_SETTEXT", WM_SETTEXT,                             // 0x000C
  62.         0, DecodeGeneric },
  63.     { "WM_GETTEXT", WM_GETTEXT,                             // 0x000D
  64.         0, DecodeGeneric },
  65.     { "WM_GETTEXTLENGTH", WM_GETTEXTLENGTH,                 // 0x000E
  66.         0, DecodeGeneric },
  67.     { "WM_PAINT", WM_PAINT,                                 // 0x000F
  68.         0, DecodeGeneric },
  69.     { "WM_CLOSE", WM_CLOSE,                                 // 0x0010
  70.         0, DecodeGeneric },
  71.     { "WM_QUERYENDSESSION", WM_QUERYENDSESSION,             // 0x0011
  72.         0, DecodeGeneric },
  73.     { "WM_QUIT", WM_QUIT,                                   // 0x0012
  74.         0, DecodeGeneric },
  75.     { "WM_QUERYOPEN", WM_QUERYOPEN,                         // 0x0013
  76.         0, DecodeGeneric },
  77.     { "WM_ERASEBKGND", WM_ERASEBKGND,                       // 0x0014
  78.         0, DecodeGeneric },
  79.     { "WM_SYSCOLORCHANGE", WM_SYSCOLORCHANGE,               // 0x0015
  80.         0, DecodeGeneric },
  81.     { "WM_ENDSESSION", WM_ENDSESSION,                       // 0x0016
  82.         0, DecodeGeneric },
  83.     { "WM_SHOWWINDOW", WM_SHOWWINDOW,                       // 0x0018
  84.         0, DecodeGeneric },
  85.     { "WM_WININICHANGE", WM_WININICHANGE,                   // 0x001A
  86.         0, DecodeGeneric },
  87.     { "WM_DEVMODECHANGE", WM_DEVMODECHANGE,                 // 0x001B
  88.         0, DecodeGeneric },
  89.     { "WM_ACTIVATEAPP", WM_ACTIVATEAPP,                     // 0x001C
  90.         0, DecodeGeneric },
  91.     { "WM_FONTCHANGE", WM_FONTCHANGE,                       // 0x001D
  92.         0, DecodeGeneric },
  93.     { "WM_TIMECHANGE", WM_TIMECHANGE,                       // 0x001E
  94.         0, DecodeGeneric },
  95.     { "WM_CANCELMODE", WM_CANCELMODE,                       // 0x001F
  96.         0, DecodeGeneric },
  97.     { "WM_SETCURSOR", WM_SETCURSOR,                         // 0x0020
  98.         MTF_TYPE_MOUSE, DecodeGeneric },
  99.     { "WM_MOUSEACTIVATE", WM_MOUSEACTIVATE,                 // 0x0021
  100.         MTF_TYPE_MOUSE, DecodeGeneric },
  101.     { "WM_CHILDACTIVATE", WM_CHILDACTIVATE,                 // 0x0022
  102.         0, DecodeGeneric },
  103.     { "WM_QUEUESYNC", WM_QUEUESYNC,                         // 0x0023
  104.         0, DecodeGeneric },
  105.     { "WM_GETMINMAXINFO", WM_GETMINMAXINFO,                 // 0x0024
  106.         0, DecodeGeneric },
  107.     { "WM_PAINTICON", WM_PAINTICON,                         // 0x0026
  108.         0, DecodeGeneric },
  109.     { "WM_ICONERASEBKGND", WM_ICONERASEBKGND,               // 0x0027
  110.         0, DecodeGeneric },
  111.     { "WM_NEXTDLGCTL", WM_NEXTDLGCTL,                       // 0x0028
  112.         0, DecodeGeneric },
  113.     { "WM_SPOOLERSTATUS", WM_SPOOLERSTATUS,                 // 0x002A
  114.         0, DecodeGeneric },
  115.     { "WM_DRAWITEM", WM_DRAWITEM,                           // 0x002B
  116.         0, DecodeGeneric },
  117.     { "WM_MEASUREITEM", WM_MEASUREITEM,                     // 0x002C
  118.         0, DecodeGeneric },
  119.     { "WM_DELETEITEM", WM_DELETEITEM,                       // 0x002D
  120.         0, DecodeGeneric },
  121.     { "WM_VKEYTOITEM", WM_VKEYTOITEM,                       // 0x002E
  122.         MTF_TYPE_KEYBD, DecodeGeneric },
  123.     { "WM_CHARTOITEM", WM_CHARTOITEM,                       // 0x002F
  124.         MTF_TYPE_KEYBD, DecodeGeneric },
  125.     { "WM_SETFONT", WM_SETFONT,                             // 0x0030
  126.         0, DecodeGeneric },
  127.     { "WM_GETFONT", WM_GETFONT,                             // 0x0031
  128.         0, DecodeGeneric },
  129.     { "WM_SETHOTKEY", WM_SETHOTKEY,                         // 0x0032
  130.         MTF_TYPE_KEYBD, DecodeGeneric },
  131.     { "WM_GETHOTKEY", WM_GETHOTKEY,                         // 0x0033
  132.         MTF_TYPE_KEYBD, DecodeGeneric },
  133.     { "WM_QUERYDRAGICON", WM_QUERYDRAGICON,                 // 0x0037
  134.         0, DecodeGeneric },
  135.     { "WM_COMPAREITEM", WM_COMPAREITEM,                     // 0x0039
  136.         0, DecodeGeneric },
  137.     { "WM_COMPACTING", WM_COMPACTING,                       // 0x0041
  138.         0, DecodeGeneric },
  139.     { "WM_WINDOWPOSCHANGING", WM_WINDOWPOSCHANGING,         // 0x0046
  140.         0, DecodeGeneric },
  141.     { "WM_WINDOWPOSCHANGED", WM_WINDOWPOSCHANGED,           // 0x0047
  142.         0, DecodeGeneric },
  143.     { "WM_POWER", WM_POWER,                                 // 0x0048
  144.         0, DecodeGeneric },
  145.     { "WM_COPYDATA", WM_COPYDATA,                           // 0x004A
  146.         0, DecodeGeneric },
  147.     { "WM_CANCELJOURNAL", WM_CANCELJOURNAL,                 // 0x004B
  148.         0, DecodeGeneric },
  149.     { "WM_NCCREATE", WM_NCCREATE,                           // 0x0081
  150.         MTF_TYPE_NC, DecodeGeneric },
  151.     { "WM_NCDESTROY", WM_NCDESTROY,                         // 0x0082
  152.         MTF_TYPE_NC, DecodeGeneric },
  153.     { "WM_NCCALCSIZE", WM_NCCALCSIZE,                       // 0x0083
  154.         MTF_TYPE_NC, DecodeGeneric },
  155.     { "WM_NCHITTEST", WM_NCHITTEST,                         // 0x0084
  156.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  157.     { "WM_NCPAINT", WM_NCPAINT,                             // 0x0085
  158.         MTF_TYPE_NC, DecodeGeneric },
  159.     { "WM_NCACTIVATE", WM_NCACTIVATE,                       // 0x0086
  160.         MTF_TYPE_NC, DecodeGeneric },
  161.     { "WM_GETDLGCODE", WM_GETDLGCODE,                       // 0x0087
  162.         0, DecodeGeneric },
  163.     { "WM_NCMOUSEMOVE", WM_NCMOUSEMOVE,                     // 0x00A0
  164.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  165.     { "WM_NCLBUTTONDOWN", WM_NCLBUTTONDOWN,                 // 0x00A1
  166.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  167.     { "WM_NCLBUTTONUP", WM_NCLBUTTONUP,                     // 0x00A2
  168.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  169.     { "WM_NCLBUTTONDBLCLK", WM_NCLBUTTONDBLCLK,             // 0x00A3
  170.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  171.     { "WM_NCRBUTTONDOWN", WM_NCRBUTTONDOWN,                 // 0x00A4
  172.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  173.     { "WM_NCRBUTTONUP", WM_NCRBUTTONUP,                     // 0x00A5
  174.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  175.     { "WM_NCRBUTTONDBLCLK", WM_NCRBUTTONDBLCLK,             // 0x00A6
  176.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  177.     { "WM_NCMBUTTONDOWN", WM_NCMBUTTONDOWN,                 // 0x00A7
  178.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  179.     { "WM_NCMBUTTONUP", WM_NCMBUTTONUP,                     // 0x00A8
  180.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  181.     { "WM_NCMBUTTONDBLCLK", WM_NCMBUTTONDBLCLK,             // 0x00A9
  182.         MTF_TYPE_NC | MTF_TYPE_MOUSE, DecodeGeneric },
  183.     { "EM_GETSEL", EM_GETSEL,                               // 0x00B0
  184.         MTF_TYPE_EM, DecodeGeneric },
  185.     { "EM_SETSEL", EM_SETSEL,                               // 0x00B1
  186.         MTF_TYPE_EM, DecodeGeneric },
  187.     { "EM_GETRECT", EM_GETRECT,                             // 0x00B2
  188.         MTF_TYPE_EM, DecodeGeneric },
  189.     { "EM_SETRECT", EM_SETRECT,                             // 0x00B3
  190.         MTF_TYPE_EM, DecodeGeneric },
  191.     { "EM_SETRECTNP", EM_SETRECTNP,                         // 0x00B4
  192.         MTF_TYPE_EM, DecodeGeneric },
  193.     { "EM_SCROLL", EM_SCROLL,                               // 0x00B5
  194.         MTF_TYPE_EM, DecodeGeneric },
  195.     { "EM_LINESCROLL", EM_LINESCROLL,                       // 0x00B6
  196.         MTF_TYPE_EM, DecodeGeneric },
  197.     { "EM_SCROLLCARET", EM_SCROLLCARET,                     // 0x00B7
  198.         MTF_TYPE_EM, DecodeGeneric },
  199.     { "EM_GETMODIFY", EM_GETMODIFY,                         // 0x00B8
  200.         MTF_TYPE_EM, DecodeGeneric },
  201.     { "EM_SETMODIFY", EM_SETMODIFY,                         // 0x00B9
  202.         MTF_TYPE_EM, DecodeGeneric },
  203.     { "EM_GETLINECOUNT", EM_GETLINECOUNT,                   // 0x00BA
  204.         MTF_TYPE_EM, DecodeGeneric },
  205.     { "EM_LINEINDEX", EM_LINEINDEX,                         // 0x00BB
  206.         MTF_TYPE_EM, DecodeGeneric },
  207.     { "EM_SETHANDLE", EM_SETHANDLE,                         // 0x00BC
  208.         MTF_TYPE_EM, DecodeGeneric },
  209.     { "EM_GETHANDLE", EM_GETHANDLE,                         // 0x00BD
  210.         MTF_TYPE_EM, DecodeGeneric },
  211.     { "EM_GETTHUMB", EM_GETTHUMB,                           // 0x00BE
  212.         MTF_TYPE_EM, DecodeGeneric },
  213.     { "EM_LINELENGTH", EM_LINELENGTH,                       // 0x00C1
  214.         MTF_TYPE_EM, DecodeGeneric },
  215.     { "EM_REPLACESEL", EM_REPLACESEL,                       // 0x00C2
  216.         MTF_TYPE_EM, DecodeGeneric },
  217.     { "EM_GETLINE", EM_GETLINE,                             // 0x00C4
  218.         MTF_TYPE_EM, DecodeGeneric },
  219.     { "EM_LIMITTEXT", EM_LIMITTEXT,                         // 0x00C5
  220.         MTF_TYPE_EM, DecodeGeneric },
  221.     { "EM_CANUNDO", EM_CANUNDO,                             // 0x00C6
  222.         MTF_TYPE_EM, DecodeGeneric },
  223.     { "EM_UNDO", EM_UNDO,                                   // 0x00C7
  224.         MTF_TYPE_EM, DecodeGeneric },
  225.     { "EM_FMTLINES", EM_FMTLINES,                           // 0x00C8
  226.         MTF_TYPE_EM, DecodeGeneric },
  227.     { "EM_LINEFROMCHAR", EM_LINEFROMCHAR,                   // 0x00C9
  228.         MTF_TYPE_EM, DecodeGeneric },
  229.     { "EM_SETTABSTOPS", EM_SETTABSTOPS,                     // 0x00CB
  230.         MTF_TYPE_EM, DecodeGeneric },
  231.     { "EM_SETPASSWORDCHAR", EM_SETPASSWORDCHAR,             // 0x00CC
  232.         MTF_TYPE_EM, DecodeGeneric },
  233.     { "EM_EMPTYUNDOBUFFER", EM_EMPTYUNDOBUFFER,             // 0x00CD
  234.         MTF_TYPE_EM, DecodeGeneric },
  235.     { "EM_GETFIRSTVISIBLELINE", EM_GETFIRSTVISIBLELINE,     // 0x00CE
  236.         MTF_TYPE_EM, DecodeGeneric },
  237.     { "EM_SETREADONLY", EM_SETREADONLY,                     // 0x00CF
  238.         MTF_TYPE_EM, DecodeGeneric },
  239.     { "EM_SETWORDBREAKPROC", EM_SETWORDBREAKPROC,           // 0x00D0
  240.         MTF_TYPE_EM, DecodeGeneric },
  241.     { "EM_GETWORDBREAKPROC", EM_GETWORDBREAKPROC,           // 0x00D1
  242.         MTF_TYPE_EM, DecodeGeneric },
  243.     { "EM_GETPASSWORDCHAR", EM_GETPASSWORDCHAR,             // 0x00D2
  244.         MTF_TYPE_EM, DecodeGeneric },
  245.     { "SBM_SETPOS", SBM_SETPOS,                             // 0x00E0
  246.         0, DecodeGeneric },
  247.     { "SBM_GETPOS", SBM_GETPOS,                             // 0x00E1
  248.         0, DecodeGeneric },
  249.     { "SBM_SETRANGE", SBM_SETRANGE,                         // 0x00E2
  250.         0, DecodeGeneric },
  251.     { "SBM_GETRANGE", SBM_GETRANGE,                         // 0x00E3
  252.         0, DecodeGeneric },
  253.     { "SBM_ENABLE_ARROWS", SBM_ENABLE_ARROWS,               // 0x00E4
  254.         0, DecodeGeneric },
  255.     { "SBM_SETRANGEREDRAW", SBM_SETRANGEREDRAW,             // 0x00E6
  256.         0, DecodeGeneric },
  257.     { "BM_GETCHECK", BM_GETCHECK,                           // 0x00F0
  258.         MTF_TYPE_BM, DecodeGeneric },
  259.     { "BM_SETCHECK", BM_SETCHECK,                           // 0x00F1
  260.         MTF_TYPE_BM, DecodeGeneric },
  261.     { "BM_GETSTATE", BM_GETSTATE,                           // 0x00F2
  262.         MTF_TYPE_BM, DecodeGeneric },
  263.     { "BM_SETSTATE", BM_SETSTATE,                           // 0x00F3
  264.         MTF_TYPE_BM, DecodeGeneric },
  265.     { "BM_SETSTYLE", BM_SETSTYLE,                           // 0x00F4
  266.         MTF_TYPE_BM, DecodeGeneric },
  267.     { "WM_KEYDOWN", WM_KEYDOWN,                             // 0x0100
  268.         MTF_TYPE_KEYBD, DecodeGeneric },
  269.     { "WM_KEYUP", WM_KEYUP,                                 // 0x0101
  270.         MTF_TYPE_KEYBD, DecodeGeneric },
  271.     { "WM_CHAR", WM_CHAR,                                   // 0x0102
  272.         MTF_TYPE_KEYBD, DecodeGeneric },
  273.     { "WM_DEADCHAR", WM_DEADCHAR,                           // 0x0103
  274.         MTF_TYPE_KEYBD, DecodeGeneric },
  275.     { "WM_SYSKEYDOWN", WM_SYSKEYDOWN,                       // 0x0104
  276.         MTF_TYPE_KEYBD, DecodeGeneric },
  277.     { "WM_SYSKEYUP", WM_SYSKEYUP,                           // 0x0105
  278.         MTF_TYPE_KEYBD, DecodeGeneric },
  279.     { "WM_SYSCHAR", WM_SYSCHAR,                             // 0x0106
  280.         MTF_TYPE_KEYBD, DecodeGeneric },
  281.     { "WM_SYSDEADCHAR", WM_SYSDEADCHAR,                     // 0x0107
  282.         MTF_TYPE_KEYBD, DecodeGeneric },
  283. #ifdef  FE_IME
  284.     { "WM_WNT_CONVERTREQUESTEX", WM_WNT_CONVERTREQUESTEX,   // 0x0109
  285.         MTF_TYPE_IME, DecodeGeneric },
  286.     { "WM_CONVERTREQUEST", WM_CONVERTREQUEST,               // 0x010A
  287.         MTF_TYPE_IME, DecodeGeneric },
  288.     { "WM_CONVERTRESULT", WM_CONVERTRESULT,                 // 0x010B
  289.         MTF_TYPE_IME, DecodeGeneric },
  290.     { "WM_INTERIM", WM_INTERIM,                             // 0x010C
  291.         MTF_TYPE_IME, DecodeGeneric },
  292. #   define TMP_MTF_TYPE_IME     MTF_TYPE_IME
  293. #else // not FE_IME
  294. #   define TMP_MTF_TYPE_IME     0
  295. #endif
  296.     { "WM_IME_STARTCOMPOSITION", WM_IME_STARTCOMPOSITION,   // 0x010D
  297.         TMP_MTF_TYPE_IME, DecodeGeneric },
  298.     { "WM_IME_ENDCOMPOSITION",   WM_IME_ENDCOMPOSITION,     // 0x010E
  299.         TMP_MTF_TYPE_IME, DecodeGeneric },
  300.     { "WM_IME_COMPOSITION",      WM_IME_COMPOSITION,        // 0x010F
  301.         TMP_MTF_TYPE_IME, DecodeGeneric },
  302.     { "WM_INITDIALOG", WM_INITDIALOG,                       // 0x0110
  303.         0, DecodeGeneric },
  304.     { "WM_COMMAND", WM_COMMAND,                             // 0x0111
  305.         0, DecodeGeneric },
  306.     { "WM_SYSCOMMAND", WM_SYSCOMMAND,                       // 0x0112
  307.         0, DecodeGeneric },
  308.     { "WM_TIMER", WM_TIMER,                                 // 0x0113
  309.         0, DecodeGeneric },
  310.     { "WM_HSCROLL", WM_HSCROLL,                             // 0x0114
  311.         0, DecodeGeneric },
  312.     { "WM_VSCROLL", WM_VSCROLL,                             // 0x0115
  313.         0, DecodeGeneric },
  314.     { "WM_INITMENU", WM_INITMENU,                           // 0x0116
  315.         0, DecodeGeneric },
  316.     { "WM_INITMENUPOPUP", WM_INITMENUPOPUP,                 // 0x0117
  317.         0, DecodeGeneric },
  318.     { "WM_MENUSELECT", WM_MENUSELECT,                       // 0x011F
  319.         0, DecodeGeneric },
  320.     { "WM_MENUCHAR", WM_MENUCHAR,                           // 0x0120
  321.         0, DecodeGeneric },
  322.     { "WM_ENTERIDLE", WM_ENTERIDLE,                         // 0x0121
  323.         0, DecodeGeneric },
  324.     { "WM_CTLCOLORMSGBOX", WM_CTLCOLORMSGBOX,               // 0x0132
  325.         0, DecodeGeneric },
  326.     { "WM_CTLCOLOREDIT", WM_CTLCOLOREDIT,                   // 0x0133
  327.         0, DecodeGeneric },
  328.     { "WM_CTLCOLORLISTBOX", WM_CTLCOLORLISTBOX,             // 0x0134
  329.         0, DecodeGeneric },
  330.     { "WM_CTLCOLORBTN", WM_CTLCOLORBTN,                     // 0x0135
  331.         0, DecodeGeneric },
  332.     { "WM_CTLCOLORDLG", WM_CTLCOLORDLG,                     // 0x0136
  333.         0, DecodeGeneric },
  334.     { "WM_CTLCOLORSCROLLBAR", WM_CTLCOLORSCROLLBAR,         // 0x0137
  335.         0, DecodeGeneric },
  336.     { "WM_CTLCOLORSTATIC", WM_CTLCOLORSTATIC,               // 0x0138
  337.         0, DecodeGeneric },
  338.     { "CB_GETEDITSEL", CB_GETEDITSEL,                       // 0x0140
  339.         MTF_TYPE_CB, DecodeGeneric },
  340.     { "CB_LIMITTEXT", CB_LIMITTEXT,                         // 0x0141
  341.         MTF_TYPE_CB, DecodeGeneric },
  342.     { "CB_SETEDITSEL", CB_SETEDITSEL,                       // 0x0142
  343.         MTF_TYPE_CB, DecodeGeneric },
  344.     { "CB_ADDSTRING", CB_ADDSTRING,                         // 0x0143
  345.         MTF_TYPE_CB, DecodeGeneric },
  346.     { "CB_DELETESTRING", CB_DELETESTRING,                   // 0x0144
  347.         MTF_TYPE_CB, DecodeGeneric },
  348.     { "CB_DIR", CB_DIR,                                     // 0x0145
  349.         MTF_TYPE_CB, DecodeGeneric },
  350.     { "CB_GETCOUNT", CB_GETCOUNT,                           // 0x0146
  351.         MTF_TYPE_CB, DecodeGeneric },
  352.     { "CB_GETCURSEL", CB_GETCURSEL,                         // 0x0147
  353.         MTF_TYPE_CB, DecodeGeneric },
  354.     { "CB_GETLBTEXT", CB_GETLBTEXT,                         // 0x0148
  355.         MTF_TYPE_CB, DecodeGeneric },
  356.     { "CB_GETLBTEXTLEN", CB_GETLBTEXTLEN,                   // 0x0149
  357.         MTF_TYPE_CB, DecodeGeneric },
  358.     { "CB_INSERTSTRING", CB_INSERTSTRING,                   // 0x014A
  359.         MTF_TYPE_CB, DecodeGeneric },
  360.     { "CB_RESETCONTENT", CB_RESETCONTENT,                   // 0x014B
  361.         MTF_TYPE_CB, DecodeGeneric },
  362.     { "CB_FINDSTRING", CB_FINDSTRING,                       // 0x014C
  363.         MTF_TYPE_CB, DecodeGeneric },
  364.     { "CB_SELECTSTRING", CB_SELECTSTRING,                   // 0x014D
  365.         MTF_TYPE_CB, DecodeGeneric },
  366.     { "CB_SETCURSEL", CB_SETCURSEL,                         // 0x014E
  367.         MTF_TYPE_CB, DecodeGeneric },
  368.     { "CB_SHOWDROPDOWN", CB_SHOWDROPDOWN,                   // 0x014F
  369.         MTF_TYPE_CB, DecodeGeneric },
  370.     { "CB_GETITEMDATA", CB_GETITEMDATA,                     // 0x0150
  371.         MTF_TYPE_CB, DecodeGeneric },
  372.     { "CB_SETITEMDATA", CB_SETITEMDATA,                     // 0x0151
  373.         MTF_TYPE_CB, DecodeGeneric },
  374.     { "CB_GETDROPPEDCONTROLRECT", CB_GETDROPPEDCONTROLRECT, // 0x0152
  375.         MTF_TYPE_CB, DecodeGeneric },
  376.     { "CB_SETITEMHEIGHT", CB_SETITEMHEIGHT,                 // 0x0153
  377.         MTF_TYPE_CB, DecodeGeneric },
  378.     { "CB_GETITEMHEIGHT", CB_GETITEMHEIGHT,                 // 0x0154
  379.         MTF_TYPE_CB, DecodeGeneric },
  380.     { "CB_SETEXTENDEDUI", CB_SETEXTENDEDUI,                 // 0x0155
  381.         MTF_TYPE_CB, DecodeGeneric },
  382.     { "CB_GETEXTENDEDUI", CB_GETEXTENDEDUI,                 // 0x0156
  383.         MTF_TYPE_CB, DecodeGeneric },
  384.     { "CB_GETDROPPEDSTATE", CB_GETDROPPEDSTATE,             // 0x0157
  385.         MTF_TYPE_CB, DecodeGeneric },
  386.     { "CB_FINDSTRINGEXACT", CB_FINDSTRINGEXACT,             // 0x0158
  387.         MTF_TYPE_CB, DecodeGeneric },
  388.     { "CB_SETLOCALE", CB_SETLOCALE,                         // 0x0159
  389.         MTF_TYPE_CB, DecodeGeneric },
  390.     { "CB_GETLOCALE", CB_GETLOCALE,                         // 0x015A
  391.         MTF_TYPE_CB, DecodeGeneric },
  392.     { "STM_SETICON", STM_SETICON,                           // 0x0170
  393.         MTF_TYPE_STM, DecodeGeneric },
  394.     { "STM_GETICON", STM_GETICON,                           // 0x0171
  395.         MTF_TYPE_STM, DecodeGeneric },
  396.     { "LB_ADDSTRING", LB_ADDSTRING,                         // 0x0180
  397.         MTF_TYPE_LB, DecodeGeneric },
  398.     { "LB_INSERTSTRING", LB_INSERTSTRING,                   // 0x0181
  399.         MTF_TYPE_LB, DecodeGeneric },
  400.     { "LB_DELETESTRING", LB_DELETESTRING,                   // 0x0182
  401.         MTF_TYPE_LB, DecodeGeneric },
  402.     { "LB_SELITEMRANGEEX", LB_SELITEMRANGEEX,               // 0x0183
  403.         MTF_TYPE_LB, DecodeGeneric },
  404.     { "LB_RESETCONTENT", LB_RESETCONTENT,                   // 0x0184
  405.         MTF_TYPE_LB, DecodeGeneric },
  406.     { "LB_SETSEL", LB_SETSEL,                               // 0x0185
  407.         MTF_TYPE_LB, DecodeGeneric },
  408.     { "LB_SETCURSEL", LB_SETCURSEL,                         // 0x0186
  409.         MTF_TYPE_LB, DecodeGeneric },
  410.     { "LB_GETSEL", LB_GETSEL,                               // 0x0187
  411.         MTF_TYPE_LB, DecodeGeneric },
  412.     { "LB_GETCURSEL", LB_GETCURSEL,                         // 0x0188
  413.         MTF_TYPE_LB, DecodeGeneric },
  414.     { "LB_GETTEXT", LB_GETTEXT,                             // 0x0189
  415.         MTF_TYPE_LB, DecodeGeneric },
  416.     { "LB_GETTEXTLEN", LB_GETTEXTLEN,                       // 0x018A
  417.         MTF_TYPE_LB, DecodeGeneric },
  418.     { "LB_GETCOUNT", LB_GETCOUNT,                           // 0x018B
  419.         MTF_TYPE_LB, DecodeGeneric },
  420.     { "LB_SELECTSTRING", LB_SELECTSTRING,                   // 0x018C
  421.         MTF_TYPE_LB, DecodeGeneric },
  422.     { "LB_DIR", LB_DIR,                                     // 0x018D
  423.         MTF_TYPE_LB, DecodeGeneric },
  424.     { "LB_GETTOPINDEX", LB_GETTOPINDEX,                     // 0x018E
  425.         MTF_TYPE_LB, DecodeGeneric },
  426.     { "LB_FINDSTRING", LB_FINDSTRING,                       // 0x018F
  427.         MTF_TYPE_LB, DecodeGeneric },
  428.     { "LB_GETSELCOUNT", LB_GETSELCOUNT,                     // 0x0190
  429.         MTF_TYPE_LB, DecodeGeneric },
  430.     { "LB_GETSELITEMS", LB_GETSELITEMS,                     // 0x0191
  431.         MTF_TYPE_LB, DecodeGeneric },
  432.     { "LB_SETTABSTOPS", LB_SETTABSTOPS,                     // 0x0192
  433.         MTF_TYPE_LB, DecodeGeneric },
  434.     { "LB_GETHORIZONTALEXTENT", LB_GETHORIZONTALEXTENT,     // 0x0193
  435.         MTF_TYPE_LB, DecodeGeneric },
  436.     { "LB_SETHORIZONTALEXTENT", LB_SETHORIZONTALEXTENT,     // 0x0194
  437.         MTF_TYPE_LB, DecodeGeneric },
  438.     { "LB_SETCOLUMNWIDTH", LB_SETCOLUMNWIDTH,               // 0x0195
  439.         MTF_TYPE_LB, DecodeGeneric },
  440.     { "LB_ADDFILE", LB_ADDFILE,                             // 0x0196
  441.         MTF_TYPE_LB, DecodeGeneric },
  442.     { "LB_SETTOPINDEX", LB_SETTOPINDEX,                     // 0x0197
  443.         MTF_TYPE_LB, DecodeGeneric },
  444.     { "LB_GETITEMRECT", LB_GETITEMRECT,                     // 0x0198
  445.         MTF_TYPE_LB, DecodeGeneric },
  446.     { "LB_GETITEMDATA", LB_GETITEMDATA,                     // 0x0199
  447.         MTF_TYPE_LB, DecodeGeneric },
  448.     { "LB_SETITEMDATA", LB_SETITEMDATA,                     // 0x019A
  449.         MTF_TYPE_LB, DecodeGeneric },
  450.     { "LB_SELITEMRANGE", LB_SELITEMRANGE,                   // 0x019B
  451.         MTF_TYPE_LB, DecodeGeneric },
  452.     { "LB_SETANCHORINDEX", LB_SETANCHORINDEX,               // 0x019C
  453.         MTF_TYPE_LB, DecodeGeneric },
  454.     { "LB_GETANCHORINDEX", LB_GETANCHORINDEX,               // 0x019D
  455.         MTF_TYPE_LB, DecodeGeneric },
  456.     { "LB_SETCARETINDEX", LB_SETCARETINDEX,                 // 0x019E
  457.         MTF_TYPE_LB, DecodeGeneric },
  458.     { "LB_GETCARETINDEX", LB_GETCARETINDEX,                 // 0x019F
  459.         MTF_TYPE_LB, DecodeGeneric },
  460.     { "LB_SETITEMHEIGHT", LB_SETITEMHEIGHT,                 // 0x01A0
  461.         MTF_TYPE_LB, DecodeGeneric },
  462.     { "LB_GETITEMHEIGHT", LB_GETITEMHEIGHT,                 // 0x01A1
  463.         MTF_TYPE_LB, DecodeGeneric },
  464.     { "LB_FINDSTRINGEXACT", LB_FINDSTRINGEXACT,             // 0x01A2
  465.         MTF_TYPE_LB, DecodeGeneric },
  466.     { "LB_SETLOCALE", LB_SETLOCALE,                         // 0x01A5
  467.         MTF_TYPE_LB, DecodeGeneric },
  468.     { "LB_GETLOCALE", LB_GETLOCALE,                         // 0x01A6
  469.         MTF_TYPE_LB, DecodeGeneric },
  470.     { "LB_SETCOUNT", LB_SETCOUNT,                           // 0x01A7
  471.         MTF_TYPE_LB, DecodeGeneric },
  472.     { "WM_MOUSEMOVE", WM_MOUSEMOVE,                         // 0x0200
  473.         MTF_TYPE_MOUSE, DecodeGeneric },
  474.     { "WM_LBUTTONDOWN", WM_LBUTTONDOWN,                     // 0x0201
  475.         MTF_TYPE_MOUSE, DecodeGeneric },
  476.     { "WM_LBUTTONUP", WM_LBUTTONUP,                         // 0x0202
  477.         MTF_TYPE_MOUSE, DecodeGeneric },
  478.     { "WM_LBUTTONDBLCLK", WM_LBUTTONDBLCLK,                 // 0x0203
  479.         MTF_TYPE_MOUSE, DecodeGeneric },
  480.     { "WM_RBUTTONDOWN", WM_RBUTTONDOWN,                     // 0x0204
  481.         MTF_TYPE_MOUSE, DecodeGeneric },
  482.     { "WM_RBUTTONUP", WM_RBUTTONUP,                         // 0x0205
  483.         MTF_TYPE_MOUSE, DecodeGeneric },
  484.     { "WM_RBUTTONDBLCLK", WM_RBUTTONDBLCLK,                 // 0x0206
  485.         MTF_TYPE_MOUSE, DecodeGeneric },
  486.     { "WM_MBUTTONDOWN", WM_MBUTTONDOWN,                     // 0x0207
  487.         MTF_TYPE_MOUSE, DecodeGeneric },
  488.     { "WM_MBUTTONUP", WM_MBUTTONUP,                         // 0x0208
  489.         MTF_TYPE_MOUSE, DecodeGeneric },
  490.     { "WM_MBUTTONDBLCLK", WM_MBUTTONDBLCLK,                 // 0x0209
  491.         MTF_TYPE_MOUSE, DecodeGeneric },
  492.     { "WM_PARENTNOTIFY", WM_PARENTNOTIFY,                   // 0x0210
  493.         MTF_TYPE_MOUSE, DecodeGeneric },
  494.     { "WM_ENTERMENULOOP", WM_ENTERMENULOOP,                 // 0x0211
  495.         0, DecodeGeneric },
  496.     { "WM_EXITMENULOOP", WM_EXITMENULOOP,                   // 0x0212
  497.         0, DecodeGeneric },
  498.     { "WM_MDICREATE", WM_MDICREATE,                         // 0x0220
  499.         0, DecodeGeneric },
  500.     { "WM_MDIDESTROY", WM_MDIDESTROY,                       // 0x0221
  501.         0, DecodeGeneric },
  502.     { "WM_MDIACTIVATE", WM_MDIACTIVATE,                     // 0x0222
  503.         0, DecodeGeneric },
  504.     { "WM_MDIRESTORE", WM_MDIRESTORE,                       // 0x0223
  505.         0, DecodeGeneric },
  506.     { "WM_MDINEXT", WM_MDINEXT,                             // 0x0224
  507.         0, DecodeGeneric },
  508.     { "WM_MDIMAXIMIZE", WM_MDIMAXIMIZE,                     // 0x0225
  509.         0, DecodeGeneric },
  510.     { "WM_MDITILE", WM_MDITILE,                             // 0x0226
  511.         0, DecodeGeneric },
  512.     { "WM_MDICASCADE", WM_MDICASCADE,                       // 0x0227
  513.         0, DecodeGeneric },
  514.     { "WM_MDIICONARRANGE", WM_MDIICONARRANGE,               // 0x0228
  515.         0, DecodeGeneric },
  516.     { "WM_MDIGETACTIVE", WM_MDIGETACTIVE,                   // 0x0229
  517.         0, DecodeGeneric },
  518.     { "WM_MDISETMENU", WM_MDISETMENU,                       // 0x0230
  519.         0, DecodeGeneric },
  520.     { "WM_ENTERSIZEMOVE", WM_ENTERSIZEMOVE,                 // 0x0231
  521.         0, DecodeGeneric },
  522.     { "WM_EXITSIZEMOVE", WM_EXITSIZEMOVE,                   // 0x0232
  523.         0, DecodeGeneric },
  524.     { "WM_DROPFILES", WM_DROPFILES,                         // 0x0233
  525.         0, DecodeGeneric },
  526.     { "WM_MDIREFRESHMENU", WM_MDIREFRESHMENU,               // 0x0234
  527.         0, DecodeGeneric },
  528. #ifdef  FE_IME
  529.     { "WM_IME_REPORT", WM_IME_REPORT,                       // 0x0280
  530.         MTF_TYPE_IME, DecodeGeneric },
  531. #endif
  532.     { "WM_IME_SETCONTEXT",      WM_IME_SETCONTEXT,          // 0x0281
  533.         TMP_MTF_TYPE_IME, DecodeGeneric },
  534.     { "WM_IME_NOTIFY",          WM_IME_NOTIFY,              // 0x0282
  535.         TMP_MTF_TYPE_IME, DecodeGeneric },
  536.     { "WM_IME_CONTROL",         WM_IME_CONTROL,             // 0x0283
  537.         TMP_MTF_TYPE_IME, DecodeGeneric },
  538.     { "WM_IME_COMPOSITIONFULL", WM_IME_COMPOSITIONFULL,     // 0x0284
  539.         TMP_MTF_TYPE_IME, DecodeGeneric },
  540.     { "WM_IME_SELECT",          WM_IME_SELECT,              // 0x0285
  541.         TMP_MTF_TYPE_IME, DecodeGeneric },
  542.     { "WM_IME_CHAR",            WM_IME_CHAR,                // 0x0286
  543.         TMP_MTF_TYPE_IME, DecodeGeneric },
  544. #ifdef  FE_IME
  545.     { "WM_IMEKEYDOWN", WM_IMEKEYDOWN,                       // 0x0290
  546.         MTF_TYPE_IME, DecodeGeneric },
  547.     { "WM_IMEKEYUP", WM_IMEKEYUP,                           // 0x0291
  548.         MTF_TYPE_IME, DecodeGeneric },
  549. #endif
  550.     { "WM_CUT", WM_CUT,                                     // 0x0300
  551.         MTF_TYPE_CLIP, DecodeGeneric },
  552.     { "WM_COPY", WM_COPY,                                   // 0x0301
  553.         MTF_TYPE_CLIP, DecodeGeneric },
  554.     { "WM_PASTE", WM_PASTE,                                 // 0x0302
  555.         MTF_TYPE_CLIP, DecodeGeneric },
  556.     { "WM_CLEAR", WM_CLEAR,                                 // 0x0303
  557.         MTF_TYPE_CLIP, DecodeGeneric },
  558.     { "WM_UNDO", WM_UNDO,                                   // 0x0304
  559.         MTF_TYPE_CLIP, DecodeGeneric },
  560.     { "WM_RENDERFORMAT", WM_RENDERFORMAT,                   // 0x0305
  561.         MTF_TYPE_CLIP, DecodeGeneric },
  562.     { "WM_RENDERALLFORMATS", WM_RENDERALLFORMATS,           // 0x0306
  563.         MTF_TYPE_CLIP, DecodeGeneric },
  564.     { "WM_DESTROYCLIPBOARD", WM_DESTROYCLIPBOARD,           // 0x0307
  565.         MTF_TYPE_CLIP, DecodeGeneric },
  566.     { "WM_DRAWCLIPBOARD", WM_DRAWCLIPBOARD,                 // 0x0308
  567.         MTF_TYPE_CLIP, DecodeGeneric },
  568.     { "WM_PAINTCLIPBOARD", WM_PAINTCLIPBOARD,               // 0x0309
  569.         MTF_TYPE_CLIP, DecodeGeneric },
  570.     { "WM_VSCROLLCLIPBOARD", WM_VSCROLLCLIPBOARD,           // 0x030A
  571.         MTF_TYPE_CLIP, DecodeGeneric },
  572.     { "WM_SIZECLIPBOARD", WM_SIZECLIPBOARD,                 // 0x030B
  573.         MTF_TYPE_CLIP, DecodeGeneric },
  574.     { "WM_ASKCBFORMATNAME", WM_ASKCBFORMATNAME,             // 0x030C
  575.         MTF_TYPE_CLIP, DecodeGeneric },
  576.     { "WM_CHANGECBCHAIN", WM_CHANGECBCHAIN,                 // 0x030D
  577.         MTF_TYPE_CLIP, DecodeGeneric },
  578.     { "WM_HSCROLLCLIPBOARD", WM_HSCROLLCLIPBOARD,           // 0x030E
  579.         MTF_TYPE_CLIP, DecodeGeneric },
  580.     { "WM_QUERYNEWPALETTE", WM_QUERYNEWPALETTE,             // 0x030F
  581.         0, DecodeGeneric },
  582.     { "WM_PALETTEISCHANGING", WM_PALETTEISCHANGING,         // 0x0310
  583.         0, DecodeGeneric },
  584.     { "WM_PALETTECHANGED", WM_PALETTECHANGED,               // 0x0311
  585.         0, DecodeGeneric },
  586.     { "WM_HOTKEY", WM_HOTKEY,                               // 0x0312
  587.         MTF_TYPE_KEYBD, DecodeGeneric },
  588.     { "WM_DDE_INITIATE", WM_DDE_INITIATE,                   // 0x03E0
  589.         MTF_TYPE_DDE, DecodeGeneric },
  590.     { "WM_DDE_TERMINATE", WM_DDE_TERMINATE,                 // 0x03E1
  591.         MTF_TYPE_DDE, DecodeGeneric },
  592.     { "WM_DDE_ADVISE", WM_DDE_ADVISE,                       // 0x03E2
  593.         MTF_TYPE_DDE, DecodeGeneric },
  594.     { "WM_DDE_UNADVISE", WM_DDE_UNADVISE,                   // 0x03E3
  595.         MTF_TYPE_DDE, DecodeGeneric },
  596.     { "WM_DDE_ACK", WM_DDE_ACK,                             // 0x03E4
  597.         MTF_TYPE_DDE, DecodeGeneric },
  598.     { "WM_DDE_DATA", WM_DDE_DATA,                           // 0x03E5
  599.         MTF_TYPE_DDE, DecodeGeneric },
  600.     { "WM_DDE_REQUEST", WM_DDE_REQUEST,                     // 0x03E6
  601.         MTF_TYPE_DDE, DecodeGeneric },
  602.     { "WM_DDE_POKE", WM_DDE_POKE,                           // 0x03E7
  603.         MTF_TYPE_DDE, DecodeGeneric },
  604.     { "WM_DDE_EXECUTE", WM_DDE_EXECUTE,                     // 0x03E8
  605.         MTF_TYPE_DDE, DecodeGeneric }
  606. };
  607. INT gcMessages = sizeof(gaMsgs) / sizeof(MSGDESC);
  608. //
  609. // Arrays of integers large enough to hold the indexes of all
  610. // the messages in the message table.  This is used when
  611. // selecting messages with the Messages dialog.
  612. //
  613. INT gaiSelected[sizeof(gaMsgs) / sizeof(MSGDESC)];
  614. INT gaiSelected2[sizeof(gaMsgs) / sizeof(MSGDESC)];
  615. MSGGROUP gaMsgGroup[] =
  616. {
  617.     { DID_MSGSDDE,      MTF_TYPE_DDE,   0,  0 },
  618.     { DID_MSGSCLIP,     MTF_TYPE_CLIP,  0,  0 },
  619.     { DID_MSGSMOUSE,    MTF_TYPE_MOUSE, 0,  0 },
  620.     { DID_MSGSNC,       MTF_TYPE_NC,    0,  0 },
  621.     { DID_MSGSKEYBD,    MTF_TYPE_KEYBD, 0,  0 },
  622. #ifdef FE_IME
  623.     { DID_MSGSIME,      MTF_TYPE_IME,   0,  0 },
  624. #endif
  625.     { DID_MSGSBM,       MTF_TYPE_BM,    0,  0 },
  626.     { DID_MSGSCB,       MTF_TYPE_CB,    0,  0 },
  627.     { DID_MSGSEM,       MTF_TYPE_EM,    0,  0 },
  628.     { DID_MSGSLB,       MTF_TYPE_LB,    0,  0 },
  629.     { DID_MSGSSTM,      MTF_TYPE_STM,   0,  0 }
  630. };
  631. INT gcMsgGroups = sizeof(gaMsgGroup) / sizeof(MSGGROUP);
  632. INT __cdecl  MsgCmp(const void *p1, const void *p2);
  633. PRIVATE VOID mprintf(LPSTR format, ...);
  634. /*****************************************************************************
  635. * MsgCmp
  636. *
  637. * Callback function for qsort that sorts messages.
  638. *
  639. * Arguments:
  640. *    void *p1 - pointer to first item
  641. *    void *p2 - pointer to second item
  642. *
  643. * Returns:
  644. *    -1 if first input less than second input
  645. *    1  if second input is less than first input
  646. *    0  if inputs are equal
  647. *
  648. *****************************************************************************/
  649. INT __cdecl
  650. MsgCmp(
  651.     const void *p1,
  652.     const void *p2
  653.     )
  654. {
  655.     MSGDESC *pmd1 = (PMSGDESC)p1;
  656.     MSGDESC *pmd2 = (PMSGDESC)p2;
  657.     return pmd1->msg < pmd2->msg ? -1 : (pmd1->msg > pmd2->msg ? 1 : 0);
  658. }
  659. /*****************************************************************************
  660. * CalculatePrintfTabs
  661. *
  662. * Calculates the tabs needed for each field in the printf window.  This
  663. * is based on the largest string in the message table and the specified
  664. * font.
  665. *
  666. * Arguments:
  667. *   HFONT hfont - Font to use in the calculations.
  668. *
  669. * Returns:
  670. *   VOID
  671. *****************************************************************************/
  672. VOID
  673. CalculatePrintfTabs(
  674.     HFONT hfont
  675.     )
  676. {
  677.     MSGDESC *pmd;
  678.     HDC hdc;
  679.     INT dxMsg;
  680.     INT dxSpace;
  681.     INT dxHwnd;
  682.     INT tabs[3];
  683.     SIZE siz;
  684.     HFONT hfontOld;
  685.     INT i;
  686.     hdc = GetDC(NULL);
  687.     hfontOld = SelectObject(hdc, hfont);
  688.     dxMsg = 0;
  689.     for (pmd = gaMsgs, i = 0; i < gcMessages; pmd++, i++)
  690.     {
  691.         GetTextExtentPoint(hdc, pmd->pszMsg, lstrlen(pmd->pszMsg), &siz);
  692.         dxMsg = max(dxMsg, siz.cx);
  693.     }
  694.     //
  695.     // Calculate the widest possible hwnd value.  It is assumed that the
  696.     // font will have the same width for all digits (or that '0' would
  697.     // be the widest).
  698.     //
  699.     GetTextExtentPoint(hdc, "00000000", 8, &siz);
  700.     dxHwnd = siz.cx;
  701.     GetTextExtentPoint(hdc, "AAAAAAAA", 8, &siz);
  702.     dxHwnd = max(dxHwnd, siz.cx);
  703.     GetTextExtentPoint(hdc, "BBBBBBBB", 8, &siz);
  704.     dxHwnd = max(dxHwnd, siz.cx);
  705.     GetTextExtentPoint(hdc, "CCCCCCCC", 8, &siz);
  706.     dxHwnd = max(dxHwnd, siz.cx);
  707.     GetTextExtentPoint(hdc, "DDDDDDDD", 8, &siz);
  708.     dxHwnd = max(dxHwnd, siz.cx);
  709.     GetTextExtentPoint(hdc, "EEEEEEEE", 8, &siz);
  710.     dxHwnd = max(dxHwnd, siz.cx);
  711.     GetTextExtentPoint(hdc, "FFFFFFFF", 8, &siz);
  712.     dxHwnd = max(dxHwnd, siz.cx);
  713.     GetTextExtentPoint(hdc, " ", 1, &siz);
  714.     dxSpace = siz.cx;
  715.     SelectObject(hdc, hfontOld);
  716.     ReleaseDC(NULL, hdc);
  717.     tabs[0] = dxHwnd + dxSpace;
  718.     tabs[1] = tabs[0] + dxMsg + dxSpace;
  719.     tabs[2] = tabs[1] + dxHwnd + dxSpace;
  720.     SetPrintfTabs(3, tabs);
  721. }
  722. /*****************************************************************************
  723. * PrintMsg
  724. *
  725. * Writes out a specified message.
  726. *
  727. * Arguments:
  728. *    LPMSG lpMsg - message to print out
  729. *
  730. * Returns:
  731. *    VOID
  732. *****************************************************************************/
  733. VOID
  734. PrintMsg(
  735.     LPMSG lpMsg
  736.     )
  737. {
  738.     static MSGDESC md;
  739.     PMSGDESC pmd;
  740.     md.msg = lpMsg->message;
  741.     pmd = (PMSGDESC)bsearch(&md, gaMsgs, gcMessages, sizeof(MSGDESC), MsgCmp);
  742.     if (pmd)
  743.     {
  744.         if (pmd->Flags & MTF_SELECTED)
  745.         {
  746.             mprintf(szFormatName, lpMsg->hwnd, pmd->pszMsg, lpMsg->wParam,
  747.                 lpMsg->lParam);
  748.         }
  749.     }
  750.     else
  751.     {
  752.         if (lpMsg->message >= WM_USER)
  753.         {
  754.             if (gfMsgsUser)
  755.             {
  756.                 mprintf(szFormatUSER, lpMsg->hwnd, lpMsg->message - WM_USER,
  757.                     lpMsg->wParam, lpMsg->lParam);
  758.             }
  759.         }
  760.         else
  761.         {
  762.             if (gfMsgsUnknown)
  763.             {
  764.                 mprintf(szFormatUnknown, lpMsg->hwnd, lpMsg->message,
  765.                     lpMsg->wParam, lpMsg->lParam);
  766.             }
  767.         }
  768.     }
  769. }
  770. /*****************************************************************************
  771. * mprintf
  772. *
  773. * Writes out a message to the specified device.
  774. *
  775. * Arguments:
  776. *   LPSTR format - Format string.
  777. *   ...          - Optional arguments.
  778. *
  779. * Returns:
  780. *
  781. *
  782. *****************************************************************************/
  783. PUBLIC INT FAR cdecl
  784. ITvwprintf(
  785. HWND  hwnd,
  786. LPSTR format,
  787. va_list marker
  788. )
  789. {
  790.     LPSTR p;
  791.     TCHAR szBuffer[512];
  792.     for( p = format; *p != ''; p++ ) {
  793.         if (*p == 'r')
  794.             *p = ' ';
  795.     }
  796.     wvsprintf(szBuffer, format, marker );
  797.     return SendMessage( hwnd, WM_VWPRINTF, (WPARAM)szBuffer, (LPARAM)0 );
  798. }
  799. PRIVATE VOID
  800. mprintf(
  801.     LPSTR format,
  802.     ...
  803.     )
  804. {
  805.     va_list marker;
  806.     CHAR szTemp[MAXSTRING];
  807.     INT iLen;
  808.     va_start(marker, format);
  809.     if (gfOutputWin)
  810.     {
  811.         ITvwprintf(ghwndPrintf, format, marker);
  812.     }
  813. #if 0
  814.     if (gfOutputCom1)
  815.     {
  816.         iLen = wvsprintf(szTemp, format, marker);
  817.         M_lwrite(INT2HFILE(FH_COM1), szTemp, iLen);
  818.     }
  819. #else //BUGBUG this doesn't work under NT.  The com device needs to be explicitly opened.
  820.     if (gfOutputCom1 && gfhCom1 != INVALID_HANDLE_VALUE)
  821.     {
  822.         DWORD   dwBytesWritten;
  823.         iLen = wvsprintf(szTemp, format, marker);
  824.         WriteFile(gfhCom1, szTemp, iLen, &dwBytesWritten, NULL);
  825.         WriteFile(gfhCom1, "rn", 2,    &dwBytesWritten, NULL);
  826.     }
  827. #endif // fix by Japanese team
  828.     if (gfOutputFile && gfhFile)
  829.     {
  830.         iLen = wvsprintf(szTemp, format, marker);
  831.         _lwrite(gfhFile, szTemp, iLen);
  832. //BUGBUG        _lclose(DUPHFILE(gfhFile));    /* flush the file buffer */
  833.     }
  834.     va_end(marker);
  835. }