1 /* Code to print windows messages */
2 /* mdh 9/30/03 */
3
4 #ifdef DEBUGCHATTY
5
6 /* This table generated from cygwin /usr/include/w32api/winuser.h
7 * with :
8 * grep WM_ /usr/include/w32api/winuser.h |
9 * sed 's/#define \([^ ]*\) \(.*\)/{\2,\"\1\"},/' > foo
10 * then edited!
11 */
12 #define WM_USER 1024
13
14 struct wmsginfo { int num; char *msg };
15
16 struct wmsginfo msginfo[] = {
17 {6,"WM_ACTIVATE"},
18 {28,"WM_ACTIVATEAPP"},
19 /* FIXME/CHECK: Are WM_AFX{FIRST,LAST} valid for WINVER < 0x400? */
20 {864,"WM_AFXFIRST"},
21 {895,"WM_AFXLAST"},
22 {780,"WM_ASKCBFORMATNAME"},
23 {75,"WM_CANCELJOURNAL"},
24 {31,"WM_CANCELMODE"},
25 {533,"WM_CAPTURECHANGED"},
26 {781,"WM_CHANGECBCHAIN"},
27 {258,"WM_CHAR"},
28 {47,"WM_CHARTOITEM"},
29 {34,"WM_CHILDACTIVATE"},
30 {771,"WM_CLEAR"},
31 {16,"WM_CLOSE"},
32 {273,"WM_COMMAND"},
33 {68 /* obsolete */,"WM_COMMNOTIFY"},
34 {65,"WM_COMPACTING"},
35 {57,"WM_COMPAREITEM"},
36 {123,"WM_CONTEXTMENU"},
37 {769,"WM_COPY"},
38 {74,"WM_COPYDATA"},
39 {1,"WM_CREATE"},
40 {309,"WM_CTLCOLORBTN"},
41 {310,"WM_CTLCOLORDLG"},
42 {307,"WM_CTLCOLOREDIT"},
43 {308,"WM_CTLCOLORLISTBOX"},
44 {306,"WM_CTLCOLORMSGBOX"},
45 {311,"WM_CTLCOLORSCROLLBAR"},
46 {312,"WM_CTLCOLORSTATIC"},
47 {768,"WM_CUT"},
48 {259,"WM_DEADCHAR"},
49 {45,"WM_DELETEITEM"},
50 {2,"WM_DESTROY"},
51 {775,"WM_DESTROYCLIPBOARD"},
52 {537,"WM_DEVICECHANGE"},
53 {27,"WM_DEVMODECHANGE"},
54 {126,"WM_DISPLAYCHANGE"},
55 {776,"WM_DRAWCLIPBOARD"},
56 {43,"WM_DRAWITEM"},
57 {563,"WM_DROPFILES"},
58 {10,"WM_ENABLE"},
59 {22,"WM_ENDSESSION"},
60 {289,"WM_ENTERIDLE"},
61 {529,"WM_ENTERMENULOOP"},
62 {561,"WM_ENTERSIZEMOVE"},
63 {20,"WM_ERASEBKGND"},
64 {530,"WM_EXITMENULOOP"},
65 {562,"WM_EXITSIZEMOVE"},
66 {29,"WM_FONTCHANGE"},
67 {135,"WM_GETDLGCODE"},
68 {49,"WM_GETFONT"},
69 {51,"WM_GETHOTKEY"},
70 {127,"WM_GETICON"},
71 {36,"WM_GETMINMAXINFO"},
72 {13,"WM_GETTEXT"},
73 {14,"WM_GETTEXTLENGTH"},
74 /* FIXME/CHECK: Are WM_HANDHEL{FIRST,LAST} valid for WINVER < 0x400? */
75 {856,"WM_HANDHELDFIRST"},
76 {863,"WM_HANDHELDLAST"},
77 {83,"WM_HELP"},
78 {786,"WM_HOTKEY"},
79 {276,"WM_HSCROLL"},
80 {782,"WM_HSCROLLCLIPBOARD"},
81 {39,"WM_ICONERASEBKGND"},
82 {272,"WM_INITDIALOG"},
83 {278,"WM_INITMENU"},
84 {279,"WM_INITMENUPOPUP"},
85 {81,"WM_INPUTLANGCHANGE"},
86 {80,"WM_INPUTLANGCHANGEREQUEST"},
87 {256,"WM_KEYDOWN"},
88 {257,"WM_KEYUP"},
89 {8,"WM_KILLFOCUS"},
90 {546,"WM_MDIACTIVATE"},
91 {551,"WM_MDICASCADE"},
92 {544,"WM_MDICREATE"},
93 {545,"WM_MDIDESTROY"},
94 {553,"WM_MDIGETACTIVE"},
95 {552,"WM_MDIICONARRANGE"},
96 {549,"WM_MDIMAXIMIZE"},
97 {548,"WM_MDINEXT"},
98 {564,"WM_MDIREFRESHMENU"},
99 {547,"WM_MDIRESTORE"},
100 {560,"WM_MDISETMENU"},
101 {550,"WM_MDITILE"},
102 {44,"WM_MEASUREITEM"},
103 {290,"WM_MENURBUTTONUP"},
104 {288,"WM_MENUCHAR"},
105 {287,"WM_MENUSELECT"},
106 {531,"WM_NEXTMENU"},
107 {3,"WM_MOVE"},
108 {534,"WM_MOVING"},
109 {134,"WM_NCACTIVATE"},
110 {131,"WM_NCCALCSIZE"},
111 {129,"WM_NCCREATE"},
112 {130,"WM_NCDESTROY"},
113 {132,"WM_NCHITTEST"},
114 {163,"WM_NCLBUTTONDBLCLK"},
115 {161,"WM_NCLBUTTONDOWN"},
116 {162,"WM_NCLBUTTONUP"},
117 {169,"WM_NCMBUTTONDBLCLK"},
118 {167,"WM_NCMBUTTONDOWN"},
119 {168,"WM_NCMBUTTONUP"},
120 {160,"WM_NCMOUSEMOVE"},
121 {133,"WM_NCPAINT"},
122 {166,"WM_NCRBUTTONDBLCLK"},
123 {164,"WM_NCRBUTTONDOWN"},
124 {165,"WM_NCRBUTTONUP"},
125 {40,"WM_NEXTDLGCTL"},
126 {531,"WM_NEXTMENU"},
127 {78,"WM_NOTIFY"},
128 {85,"WM_NOTIFYFORMAT"},
129 {0,"WM_NULL"},
130 {15,"WM_PAINT"},
131 {777,"WM_PAINTCLIPBOARD"},
132 {38,"WM_PAINTICON"},
133 {785,"WM_PALETTECHANGED"},
134 {784,"WM_PALETTEISCHANGING"},
135 {528,"WM_PARENTNOTIFY"},
136 {770,"WM_PASTE"},
137 {896,"WM_PENWINFIRST"},
138 {911,"WM_PENWINLAST"},
139 {72,"WM_POWER"},
140 {536,"WM_POWERBROADCAST"},
141 {791,"WM_PRINT"},
142 {792,"WM_PRINTCLIENT"},
143 {55,"WM_QUERYDRAGICON"},
144 {17,"WM_QUERYENDSESSION"},
145 {783,"WM_QUERYNEWPALETTE"},
146 {19,"WM_QUERYOPEN"},
147 {35,"WM_QUEUESYNC"},
148 {18,"WM_QUIT"},
149 {774,"WM_RENDERALLFORMATS"},
150 {773,"WM_RENDERFORMAT"},
151 {32,"WM_SETCURSOR"},
152 {7,"WM_SETFOCUS"},
153 {48,"WM_SETFONT"},
154 {50,"WM_SETHOTKEY"},
155 {128,"WM_SETICON"},
156 {11,"WM_SETREDRAW"},
157 {12,"WM_SETTEXT"},
158 {26,"WM_SETTINGCHANGE"},
159 {24,"WM_SHOWWINDOW"},
160 {5,"WM_SIZE"},
161 {779,"WM_SIZECLIPBOARD"},
162 {532,"WM_SIZING"},
163 {42,"WM_SPOOLERSTATUS"},
164 {125,"WM_STYLECHANGED"},
165 {124,"WM_STYLECHANGING"},
166 {262,"WM_SYSCHAR"},
167 {21,"WM_SYSCOLORCHANGE"},
168 {274,"WM_SYSCOMMAND"},
169 {263,"WM_SYSDEADCHAR"},
170 {260,"WM_SYSKEYDOWN"},
171 {261,"WM_SYSKEYUP"},
172 {82,"WM_TCARD"},
173 {30,"WM_TIMECHANGE"},
174 {275,"WM_TIMER"},
175 {772,"WM_UNDO"},
176 {1024,"WM_USER"},
177 {84,"WM_USERCHANGED"},
178 {46,"WM_VKEYTOITEM"},
179 {277,"WM_VSCROLL"},
180 {778,"WM_VSCROLLCLIPBOARD"},
181 {71,"WM_WINDOWPOSCHANGED"},
182 {70,"WM_WINDOWPOSCHANGING"},
183 {26,"WM_WININICHANGE"},
184 {256,"WM_KEYFIRST"},
185 {264,"WM_KEYLAST"},
186 { 136,"WM_SYNCPAINT"},
187 {33,"WM_MOUSEACTIVATE"},
188 {512,"WM_MOUSEMOVE"},
189 {513,"WM_LBUTTONDOWN"},
190 {514,"WM_LBUTTONUP"},
191 {515,"WM_LBUTTONDBLCLK"},
192 {516,"WM_RBUTTONDOWN"},
193 {517,"WM_RBUTTONUP"},
194 {518,"WM_RBUTTONDBLCLK"},
195 {519,"WM_MBUTTONDOWN"},
196 {520,"WM_MBUTTONUP"},
197 {521,"WM_MBUTTONDBLCLK"},
198 {522,"WM_MOUSEWHEEL"},
199 {512,"WM_MOUSEFIRST"},
200 {522,"WM_MOUSELAST"},
201 {0x2A1, "WM_MOUSEHOVER"},
202 {0x2A3, "WM_MOUSELEAVE"},
203 {WM_USER,"DM_GETDEFID"},
204 {(WM_USER+1),"DM_SETDEFID"},
205 {(WM_USER+2),"DM_REPOSITION"},
206 {(WM_USER+100),"PSM_PAGEINFO"},
207 {(WM_USER+101),"PSM_SHEETINFO"},
208 {0xc,"HELP_WM_HELP"},
209 {32768,"WM_APP"}
210 };
211
212 #define MAX_TEXT 2048
213
214 static char *msgstr[MAX_TEXT];
215 static char *unknown = "(unknown)";
216
217 static int need_init = 1;
218
msgtotext(int msg)219 char *msgtotext(int msg)
220 {
221 int i;
222 if (need_init) {
223 printf("Init messages\n");
224 for (i=0; i < MAX_TEXT; i++) msgstr[i] = unknown;
225 for (i=0; msginfo[i].num < 32767; i++) {
226 if (msginfo[i].num >= MAX_TEXT)
227 printf("Warning: ignore %d, %s\n", msginfo[i].num,
228 msginfo[i].msg);
229 else {
230 if (msgstr[msginfo[i].num] != unknown)
231 printf("Warning: duplicate %d %s and %s\n", msginfo[i].num,
232 msgstr[msginfo[i].num], msginfo[i].msg);
233 else
234 msgstr[msginfo[i].num] = msginfo[i].msg;
235 }
236 }
237 need_init = 0;
238 }
239 if (msg >= MAX_TEXT)
240 return unknown;
241 else
242 return msgstr[msg];
243 }
244
245 #else /* not DEBUGCHATTY */
msgtotext(int msg)246 char *msgtotext(int msg)
247 {
248 return "(msgtotext)";
249 }
250 #endif /* DEBUGCHATTY */
251