dinput: Use vid/pid for first chunk of product guid on OSX, too.
[wine.git] / dlls / user32 / winproc.c
blobb2d4fd223b122c446440e78a942a33dd4cc2c471
1 /*
2 * Window procedure callbacks
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1996 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <assert.h>
26 #include <stdarg.h>
27 #include <string.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "controls.h"
33 #include "win.h"
34 #include "user_private.h"
35 #include "wine/unicode.h"
36 #include "wine/debug.h"
38 WINE_DECLARE_DEBUG_CHANNEL(msg);
39 WINE_DECLARE_DEBUG_CHANNEL(relay);
40 WINE_DEFAULT_DEBUG_CHANNEL(win);
42 typedef struct tagWINDOWPROC
44 WNDPROC procA; /* ASCII window proc */
45 WNDPROC procW; /* Unicode window proc */
46 } WINDOWPROC;
48 #define MAX_WINPROCS 4096
49 #define MAX_WINPROC_RECURSION 64
50 #define WINPROC_PROC16 ((WINDOWPROC *)1) /* placeholder for 16-bit window procs */
52 static LRESULT WINAPI ButtonWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
53 static LRESULT WINAPI ButtonWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
54 static LRESULT WINAPI ComboWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
55 static LRESULT WINAPI ComboWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
56 LRESULT WINAPI EditWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
57 static LRESULT WINAPI EditWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
58 static LRESULT WINAPI ListBoxWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
59 static LRESULT WINAPI ListBoxWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
60 static LRESULT WINAPI MDIClientWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
61 static LRESULT WINAPI MDIClientWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
62 static LRESULT WINAPI ScrollBarWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
63 static LRESULT WINAPI ScrollBarWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
64 static LRESULT WINAPI StaticWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
65 static LRESULT WINAPI StaticWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
67 static WINDOWPROC winproc_array[MAX_WINPROCS] =
69 { ButtonWndProcA, ButtonWndProcW }, /* WINPROC_BUTTON */
70 { ComboWndProcA, ComboWndProcW }, /* WINPROC_COMBO */
71 { DefWindowProcA, DefWindowProcW }, /* WINPROC_DEFWND */
72 { DefDlgProcA, DefDlgProcW }, /* WINPROC_DIALOG */
73 { EditWndProcA, EditWndProcW }, /* WINPROC_EDIT */
74 { ListBoxWndProcA, ListBoxWndProcW }, /* WINPROC_LISTBOX */
75 { MDIClientWndProcA, MDIClientWndProcW }, /* WINPROC_MDICLIENT */
76 { ScrollBarWndProcA, ScrollBarWndProcW }, /* WINPROC_SCROLLBAR */
77 { StaticWndProcA, StaticWndProcW }, /* WINPROC_STATIC */
78 { ImeWndProcA, ImeWndProcW }, /* WINPROC_IME */
79 { NULL, DesktopWndProc }, /* WINPROC_DESKTOP */
80 { NULL, IconTitleWndProc }, /* WINPROC_ICONTITLE */
81 { NULL, PopupMenuWndProc }, /* WINPROC_MENU */
82 { NULL, MessageWndProc }, /* WINPROC_MESSAGE */
85 static UINT winproc_used = NB_BUILTIN_WINPROCS;
87 static CRITICAL_SECTION winproc_cs;
88 static CRITICAL_SECTION_DEBUG critsect_debug =
90 0, 0, &winproc_cs,
91 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
92 0, 0, { (DWORD_PTR)(__FILE__ ": winproc_cs") }
94 static CRITICAL_SECTION winproc_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
96 static inline void *get_buffer( void *static_buffer, size_t size, size_t need )
98 if (size >= need) return static_buffer;
99 return HeapAlloc( GetProcessHeap(), 0, need );
102 static inline void free_buffer( void *static_buffer, void *buffer )
104 if (buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer );
107 /* find an existing winproc for a given function and type */
108 /* FIXME: probably should do something more clever than a linear search */
109 static inline WINDOWPROC *find_winproc( WNDPROC func, BOOL unicode )
111 unsigned int i;
113 for (i = 0; i < NB_BUILTIN_AW_WINPROCS; i++)
115 /* match either proc, some apps confuse A and W */
116 if (winproc_array[i].procA != func && winproc_array[i].procW != func) continue;
117 return &winproc_array[i];
119 for (i = NB_BUILTIN_AW_WINPROCS; i < winproc_used; i++)
121 if (!unicode && winproc_array[i].procA != func) continue;
122 if (unicode && winproc_array[i].procW != func) continue;
123 return &winproc_array[i];
125 return NULL;
128 /* return the window proc for a given handle, or NULL for an invalid handle,
129 * or WINPROC_PROC16 for a handle to a 16-bit proc. */
130 static inline WINDOWPROC *handle_to_proc( WNDPROC handle )
132 UINT index = LOWORD(handle);
133 if ((ULONG_PTR)handle >> 16 != WINPROC_HANDLE) return NULL;
134 if (index >= MAX_WINPROCS) return WINPROC_PROC16;
135 if (index >= winproc_used) return NULL;
136 return &winproc_array[index];
139 /* create a handle for a given window proc */
140 static inline WNDPROC proc_to_handle( WINDOWPROC *proc )
142 return (WNDPROC)(ULONG_PTR)((proc - winproc_array) | (WINPROC_HANDLE << 16));
145 /* allocate and initialize a new winproc */
146 static inline WINDOWPROC *alloc_winproc( WNDPROC func, BOOL unicode )
148 WINDOWPROC *proc;
150 /* check if the function is already a win proc */
151 if (!func) return NULL;
152 if ((proc = handle_to_proc( func ))) return proc;
154 EnterCriticalSection( &winproc_cs );
156 /* check if we already have a winproc for that function */
157 if (!(proc = find_winproc( func, unicode )))
159 if (winproc_used < MAX_WINPROCS)
161 proc = &winproc_array[winproc_used++];
162 if (unicode) proc->procW = func;
163 else proc->procA = func;
164 TRACE( "allocated %p for %c %p (%d/%d used)\n",
165 proc_to_handle(proc), unicode ? 'W' : 'A', func,
166 winproc_used, MAX_WINPROCS );
168 else WARN( "too many winprocs, cannot allocate one for %p\n", func );
170 else TRACE( "reusing %p for %p\n", proc_to_handle(proc), func );
172 LeaveCriticalSection( &winproc_cs );
173 return proc;
176 #ifdef __i386__
177 /* Some window procedures modify register they shouldn't, or are not
178 * properly declared stdcall; so we need a small assembly wrapper to
179 * call them. */
180 extern LRESULT WINPROC_wrapper( WNDPROC proc, HWND hwnd, UINT msg,
181 WPARAM wParam, LPARAM lParam );
182 __ASM_GLOBAL_FUNC( WINPROC_wrapper,
183 "pushl %ebp\n\t"
184 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
185 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
186 "movl %esp,%ebp\n\t"
187 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
188 "pushl %edi\n\t"
189 __ASM_CFI(".cfi_rel_offset %edi,-4\n\t")
190 "pushl %esi\n\t"
191 __ASM_CFI(".cfi_rel_offset %esi,-8\n\t")
192 "pushl %ebx\n\t"
193 __ASM_CFI(".cfi_rel_offset %ebx,-12\n\t")
194 "subl $12,%esp\n\t"
195 "pushl 24(%ebp)\n\t"
196 "pushl 20(%ebp)\n\t"
197 "pushl 16(%ebp)\n\t"
198 "pushl 12(%ebp)\n\t"
199 "movl 8(%ebp),%eax\n\t"
200 "call *%eax\n\t"
201 "leal -12(%ebp),%esp\n\t"
202 "popl %ebx\n\t"
203 __ASM_CFI(".cfi_same_value %ebx\n\t")
204 "popl %esi\n\t"
205 __ASM_CFI(".cfi_same_value %esi\n\t")
206 "popl %edi\n\t"
207 __ASM_CFI(".cfi_same_value %edi\n\t")
208 "leave\n\t"
209 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
210 __ASM_CFI(".cfi_same_value %ebp\n\t")
211 "ret" )
212 #else
213 static inline LRESULT WINPROC_wrapper( WNDPROC proc, HWND hwnd, UINT msg,
214 WPARAM wParam, LPARAM lParam )
216 return proc( hwnd, msg, wParam, lParam );
218 #endif /* __i386__ */
220 static WPARAM map_wparam_char_WtoA( WPARAM wParam, DWORD len )
222 WCHAR wch = wParam;
223 BYTE ch[2];
224 DWORD cp = get_input_codepage();
226 len = WideCharToMultiByte( cp, 0, &wch, 1, (LPSTR)ch, len, NULL, NULL );
227 if (len == 2)
228 return MAKEWPARAM( (ch[0] << 8) | ch[1], HIWORD(wParam) );
229 else
230 return MAKEWPARAM( ch[0], HIWORD(wParam) );
233 /* call a 32-bit window procedure */
234 static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result, void *arg )
236 DPI_AWARENESS_CONTEXT context;
237 WNDPROC proc = arg;
239 USER_CheckNotLock();
241 hwnd = WIN_GetFullHandle( hwnd );
242 TRACE_(relay)( "\1Call window proc %p (hwnd=%p,msg=%s,wp=%08lx,lp=%08lx)\n",
243 proc, hwnd, SPY_GetMsgName(msg, hwnd), wp, lp );
245 context = SetThreadDpiAwarenessContext( GetWindowDpiAwarenessContext( hwnd ));
246 *result = WINPROC_wrapper( proc, hwnd, msg, wp, lp );
247 SetThreadDpiAwarenessContext( context );
249 TRACE_(relay)( "\1Ret window proc %p (hwnd=%p,msg=%s,wp=%08lx,lp=%08lx) retval=%08lx\n",
250 proc, hwnd, SPY_GetMsgName(msg, hwnd), wp, lp, *result );
251 return *result;
254 /* call a 32-bit dialog procedure */
255 static LRESULT call_dialog_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result, void *arg )
257 DPI_AWARENESS_CONTEXT context;
258 WNDPROC proc = arg;
259 LRESULT ret;
261 USER_CheckNotLock();
263 hwnd = WIN_GetFullHandle( hwnd );
264 TRACE_(relay)( "\1Call dialog proc %p (hwnd=%p,msg=%s,wp=%08lx,lp=%08lx)\n",
265 proc, hwnd, SPY_GetMsgName(msg, hwnd), wp, lp );
267 context = SetThreadDpiAwarenessContext( GetWindowDpiAwarenessContext( hwnd ));
268 ret = WINPROC_wrapper( proc, hwnd, msg, wp, lp );
269 *result = GetWindowLongPtrW( hwnd, DWLP_MSGRESULT );
270 SetThreadDpiAwarenessContext( context );
272 TRACE_(relay)( "\1Ret dialog proc %p (hwnd=%p,msg=%s,wp=%08lx,lp=%08lx) retval=%08lx result=%08lx\n",
273 proc, hwnd, SPY_GetMsgName(msg, hwnd), wp, lp, ret, *result );
274 return ret;
278 /**********************************************************************
279 * WINPROC_GetProc
281 * Get a window procedure pointer that can be passed to the Windows program.
283 WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode )
285 WINDOWPROC *ptr = handle_to_proc( proc );
287 if (!ptr || ptr == WINPROC_PROC16) return proc;
288 if (unicode)
290 if (ptr->procW) return ptr->procW;
291 return proc;
293 else
295 if (ptr->procA) return ptr->procA;
296 return proc;
301 /**********************************************************************
302 * WINPROC_AllocProc
304 * Allocate a window procedure for a window or class.
306 * Note that allocated winprocs are never freed; the idea is that even if an app creates a
307 * lot of windows, it will usually only have a limited number of window procedures, so the
308 * array won't grow too large, and this way we avoid the need to track allocations per window.
310 WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode )
312 WINDOWPROC *proc;
314 if (!(proc = alloc_winproc( func, unicode ))) return func;
315 if (proc == WINPROC_PROC16) return func;
316 return proc_to_handle( proc );
320 /**********************************************************************
321 * WINPROC_IsUnicode
323 * Return the window procedure type, or the default value if not a winproc handle.
325 BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val )
327 WINDOWPROC *ptr = handle_to_proc( proc );
329 if (!ptr) return def_val;
330 if (ptr == WINPROC_PROC16) return FALSE; /* 16-bit is always A */
331 if (ptr->procA && ptr->procW) return def_val; /* can be both */
332 return (ptr->procW != NULL);
336 /**********************************************************************
337 * WINPROC_TestLBForStr
339 * Return TRUE if the lparam is a string
341 static inline BOOL WINPROC_TestLBForStr( HWND hwnd, UINT msg )
343 DWORD style = GetWindowLongA( hwnd, GWL_STYLE );
344 if (msg <= CB_MSGMAX)
345 return (!(style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) || (style & CBS_HASSTRINGS));
346 else
347 return (!(style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) || (style & LBS_HASSTRINGS));
352 /**********************************************************************
353 * WINPROC_CallProcAtoW
355 * Call a window procedure, translating args from Ansi to Unicode.
357 LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg, WPARAM wParam,
358 LPARAM lParam, LRESULT *result, void *arg, enum wm_char_mapping mapping )
360 LRESULT ret = 0;
362 TRACE_(msg)("(hwnd=%p,msg=%s,wp=%08lx,lp=%08lx)\n",
363 hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam);
365 switch(msg)
367 case WM_NCCREATE:
368 case WM_CREATE:
370 WCHAR *ptr, buffer[512];
371 CREATESTRUCTA *csA = (CREATESTRUCTA *)lParam;
372 CREATESTRUCTW csW = *(CREATESTRUCTW *)csA;
373 MDICREATESTRUCTW mdi_cs;
374 DWORD name_lenA = 0, name_lenW = 0, class_lenA = 0, class_lenW = 0;
376 if (!IS_INTRESOURCE(csA->lpszClass))
378 class_lenA = strlen(csA->lpszClass) + 1;
379 RtlMultiByteToUnicodeSize( &class_lenW, csA->lpszClass, class_lenA );
381 if (!IS_INTRESOURCE(csA->lpszName))
383 name_lenA = strlen(csA->lpszName) + 1;
384 RtlMultiByteToUnicodeSize( &name_lenW, csA->lpszName, name_lenA );
387 if (!(ptr = get_buffer( buffer, sizeof(buffer), class_lenW + name_lenW ))) break;
389 if (class_lenW)
391 csW.lpszClass = ptr;
392 RtlMultiByteToUnicodeN( ptr, class_lenW, NULL, csA->lpszClass, class_lenA );
394 if (name_lenW)
396 csW.lpszName = ptr + class_lenW/sizeof(WCHAR);
397 RtlMultiByteToUnicodeN( ptr + class_lenW/sizeof(WCHAR), name_lenW, NULL,
398 csA->lpszName, name_lenA );
401 if (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_MDICHILD)
403 mdi_cs = *(MDICREATESTRUCTW *)csA->lpCreateParams;
404 mdi_cs.szTitle = csW.lpszName;
405 mdi_cs.szClass = csW.lpszClass;
406 csW.lpCreateParams = &mdi_cs;
409 ret = callback( hwnd, msg, wParam, (LPARAM)&csW, result, arg );
410 free_buffer( buffer, ptr );
412 break;
414 case WM_MDICREATE:
416 WCHAR *ptr, buffer[512];
417 DWORD title_lenA = 0, title_lenW = 0, class_lenA = 0, class_lenW = 0;
418 MDICREATESTRUCTA *csA = (MDICREATESTRUCTA *)lParam;
419 MDICREATESTRUCTW csW;
421 memcpy( &csW, csA, sizeof(csW) );
423 if (!IS_INTRESOURCE(csA->szTitle))
425 title_lenA = strlen(csA->szTitle) + 1;
426 RtlMultiByteToUnicodeSize( &title_lenW, csA->szTitle, title_lenA );
428 if (!IS_INTRESOURCE(csA->szClass))
430 class_lenA = strlen(csA->szClass) + 1;
431 RtlMultiByteToUnicodeSize( &class_lenW, csA->szClass, class_lenA );
434 if (!(ptr = get_buffer( buffer, sizeof(buffer), title_lenW + class_lenW ))) break;
436 if (title_lenW)
438 csW.szTitle = ptr;
439 RtlMultiByteToUnicodeN( ptr, title_lenW, NULL, csA->szTitle, title_lenA );
441 if (class_lenW)
443 csW.szClass = ptr + title_lenW/sizeof(WCHAR);
444 RtlMultiByteToUnicodeN( ptr + title_lenW/sizeof(WCHAR), class_lenW, NULL,
445 csA->szClass, class_lenA );
447 ret = callback( hwnd, msg, wParam, (LPARAM)&csW, result, arg );
448 free_buffer( buffer, ptr );
450 break;
452 case WM_GETTEXT:
453 case WM_ASKCBFORMATNAME:
455 WCHAR *ptr, buffer[512];
456 LPSTR str = (LPSTR)lParam;
457 DWORD len = wParam * sizeof(WCHAR);
459 if (!(ptr = get_buffer( buffer, sizeof(buffer), len ))) break;
460 ret = callback( hwnd, msg, wParam, (LPARAM)ptr, result, arg );
461 if (wParam)
463 len = 0;
464 if (*result)
465 RtlUnicodeToMultiByteN( str, wParam - 1, &len, ptr, ret * sizeof(WCHAR) );
466 str[len] = 0;
467 *result = len;
469 free_buffer( buffer, ptr );
471 break;
473 case LB_ADDSTRING:
474 case LB_INSERTSTRING:
475 case LB_FINDSTRING:
476 case LB_FINDSTRINGEXACT:
477 case LB_SELECTSTRING:
478 case CB_ADDSTRING:
479 case CB_INSERTSTRING:
480 case CB_FINDSTRING:
481 case CB_FINDSTRINGEXACT:
482 case CB_SELECTSTRING:
483 if (!lParam || !WINPROC_TestLBForStr( hwnd, msg ))
485 ret = callback( hwnd, msg, wParam, lParam, result, arg );
486 break;
488 /* fall through */
489 case WM_SETTEXT:
490 case WM_WININICHANGE:
491 case WM_DEVMODECHANGE:
492 case CB_DIR:
493 case LB_DIR:
494 case LB_ADDFILE:
495 case EM_REPLACESEL:
496 if (!lParam) ret = callback( hwnd, msg, wParam, lParam, result, arg );
497 else
499 WCHAR *ptr, buffer[512];
500 LPCSTR strA = (LPCSTR)lParam;
501 DWORD lenW, lenA = strlen(strA) + 1;
503 RtlMultiByteToUnicodeSize( &lenW, strA, lenA );
504 if ((ptr = get_buffer( buffer, sizeof(buffer), lenW )))
506 RtlMultiByteToUnicodeN( ptr, lenW, NULL, strA, lenA );
507 ret = callback( hwnd, msg, wParam, (LPARAM)ptr, result, arg );
508 free_buffer( buffer, ptr );
511 break;
513 case LB_GETTEXT:
514 case CB_GETLBTEXT:
515 if (lParam && WINPROC_TestLBForStr( hwnd, msg ))
517 WCHAR buffer[512]; /* FIXME: fixed sized buffer */
519 ret = callback( hwnd, msg, wParam, (LPARAM)buffer, result, arg );
520 if (*result >= 0)
522 DWORD len;
523 RtlUnicodeToMultiByteN( (LPSTR)lParam, ~0u, &len,
524 buffer, (strlenW(buffer) + 1) * sizeof(WCHAR) );
525 *result = len - 1;
528 else ret = callback( hwnd, msg, wParam, lParam, result, arg );
529 break;
531 case EM_GETLINE:
533 WCHAR *ptr, buffer[512];
534 WORD len = *(WORD *)lParam;
536 if (!(ptr = get_buffer( buffer, sizeof(buffer), len * sizeof(WCHAR) ))) break;
537 *((WORD *)ptr) = len; /* store the length */
538 ret = callback( hwnd, msg, wParam, (LPARAM)ptr, result, arg );
539 if (*result)
541 DWORD reslen;
542 RtlUnicodeToMultiByteN( (LPSTR)lParam, len, &reslen, ptr, *result * sizeof(WCHAR) );
543 if (reslen < len) ((LPSTR)lParam)[reslen] = 0;
544 *result = reslen;
546 free_buffer( buffer, ptr );
548 break;
550 case WM_GETDLGCODE:
551 if (lParam)
553 MSG newmsg = *(MSG *)lParam;
554 if (map_wparam_AtoW( newmsg.message, &newmsg.wParam, WMCHAR_MAP_NOMAPPING ))
555 ret = callback( hwnd, msg, wParam, (LPARAM)&newmsg, result, arg );
557 else ret = callback( hwnd, msg, wParam, lParam, result, arg );
558 break;
560 case WM_CHARTOITEM:
561 case WM_MENUCHAR:
562 case WM_CHAR:
563 case WM_DEADCHAR:
564 case WM_SYSCHAR:
565 case WM_SYSDEADCHAR:
566 case EM_SETPASSWORDCHAR:
567 case WM_IME_CHAR:
568 if (map_wparam_AtoW( msg, &wParam, mapping ))
569 ret = callback( hwnd, msg, wParam, lParam, result, arg );
570 break;
572 case WM_GETTEXTLENGTH:
573 case CB_GETLBTEXTLEN:
574 case LB_GETTEXTLEN:
575 ret = callback( hwnd, msg, wParam, lParam, result, arg );
576 if (*result >= 0)
578 WCHAR *ptr, buffer[512];
579 LRESULT tmp;
580 DWORD len = *result + 1;
581 /* Determine respective GETTEXT message */
582 UINT msgGetText = (msg == WM_GETTEXTLENGTH) ? WM_GETTEXT :
583 ((msg == CB_GETLBTEXTLEN) ? CB_GETLBTEXT : LB_GETTEXT);
584 /* wParam differs between the messages */
585 WPARAM wp = (msg == WM_GETTEXTLENGTH) ? len : wParam;
587 if (!(ptr = get_buffer( buffer, sizeof(buffer), len * sizeof(WCHAR) ))) break;
589 if (callback == call_window_proc) /* FIXME: hack */
590 callback( hwnd, msgGetText, wp, (LPARAM)ptr, &tmp, arg );
591 else
592 tmp = SendMessageW( hwnd, msgGetText, wp, (LPARAM)ptr );
593 RtlUnicodeToMultiByteSize( &len, ptr, tmp * sizeof(WCHAR) );
594 *result = len;
595 free_buffer( buffer, ptr );
597 break;
599 case WM_PAINTCLIPBOARD:
600 case WM_SIZECLIPBOARD:
601 FIXME_(msg)( "message %s (0x%x) needs translation, please report\n",
602 SPY_GetMsgName(msg, hwnd), msg );
603 break;
605 default:
606 ret = callback( hwnd, msg, wParam, lParam, result, arg );
607 break;
609 return ret;
613 /**********************************************************************
614 * WINPROC_CallProcWtoA
616 * Call a window procedure, translating args from Unicode to Ansi.
618 static LRESULT WINPROC_CallProcWtoA( winproc_callback_t callback, HWND hwnd, UINT msg, WPARAM wParam,
619 LPARAM lParam, LRESULT *result, void *arg )
621 LRESULT ret = 0;
623 TRACE_(msg)("(hwnd=%p,msg=%s,wp=%08lx,lp=%08lx)\n",
624 hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam);
626 switch(msg)
628 case WM_NCCREATE:
629 case WM_CREATE:
631 char buffer[1024], *cls;
632 CREATESTRUCTW *csW = (CREATESTRUCTW *)lParam;
633 CREATESTRUCTA csA = *(CREATESTRUCTA *)csW;
634 MDICREATESTRUCTA mdi_cs;
635 DWORD name_lenA = 0, name_lenW = 0, class_lenA = 0, class_lenW = 0;
637 if (!IS_INTRESOURCE(csW->lpszClass))
639 class_lenW = (strlenW(csW->lpszClass) + 1) * sizeof(WCHAR);
640 RtlUnicodeToMultiByteSize(&class_lenA, csW->lpszClass, class_lenW);
642 if (!IS_INTRESOURCE(csW->lpszName))
644 name_lenW = (strlenW(csW->lpszName) + 1) * sizeof(WCHAR);
645 RtlUnicodeToMultiByteSize(&name_lenA, csW->lpszName, name_lenW);
648 if (!(cls = get_buffer( buffer, sizeof(buffer), class_lenA + name_lenA ))) break;
650 if (class_lenA)
652 RtlUnicodeToMultiByteN(cls, class_lenA, NULL, csW->lpszClass, class_lenW);
653 csA.lpszClass = cls;
655 if (name_lenA)
657 char *name = cls + class_lenA;
658 RtlUnicodeToMultiByteN(name, name_lenA, NULL, csW->lpszName, name_lenW);
659 csA.lpszName = name;
662 if (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_MDICHILD)
664 mdi_cs = *(MDICREATESTRUCTA *)csW->lpCreateParams;
665 mdi_cs.szTitle = csA.lpszName;
666 mdi_cs.szClass = csA.lpszClass;
667 csA.lpCreateParams = &mdi_cs;
670 ret = callback( hwnd, msg, wParam, (LPARAM)&csA, result, arg );
671 free_buffer( buffer, cls );
673 break;
675 case WM_GETTEXT:
676 case WM_ASKCBFORMATNAME:
678 char *ptr, buffer[512];
679 DWORD len = wParam * 2;
681 if (!(ptr = get_buffer( buffer, sizeof(buffer), len ))) break;
682 ret = callback( hwnd, msg, wParam, (LPARAM)ptr, result, arg );
683 if (len)
685 if (*result)
687 RtlMultiByteToUnicodeN( (LPWSTR)lParam, wParam*sizeof(WCHAR), &len, ptr, ret + 1 );
688 *result = len/sizeof(WCHAR) - 1; /* do not count terminating null */
690 ((LPWSTR)lParam)[*result] = 0;
692 free_buffer( buffer, ptr );
694 break;
696 case LB_ADDSTRING:
697 case LB_INSERTSTRING:
698 case LB_FINDSTRING:
699 case LB_FINDSTRINGEXACT:
700 case LB_SELECTSTRING:
701 case CB_ADDSTRING:
702 case CB_INSERTSTRING:
703 case CB_FINDSTRING:
704 case CB_FINDSTRINGEXACT:
705 case CB_SELECTSTRING:
706 if (!lParam || !WINPROC_TestLBForStr( hwnd, msg ))
708 ret = callback( hwnd, msg, wParam, lParam, result, arg );
709 break;
711 /* fall through */
712 case WM_SETTEXT:
713 case WM_WININICHANGE:
714 case WM_DEVMODECHANGE:
715 case CB_DIR:
716 case LB_DIR:
717 case LB_ADDFILE:
718 case EM_REPLACESEL:
719 if (!lParam) ret = callback( hwnd, msg, wParam, lParam, result, arg );
720 else
722 char *ptr, buffer[512];
723 LPCWSTR strW = (LPCWSTR)lParam;
724 DWORD lenA, lenW = (strlenW(strW) + 1) * sizeof(WCHAR);
726 RtlUnicodeToMultiByteSize( &lenA, strW, lenW );
727 if ((ptr = get_buffer( buffer, sizeof(buffer), lenA )))
729 RtlUnicodeToMultiByteN( ptr, lenA, NULL, strW, lenW );
730 ret = callback( hwnd, msg, wParam, (LPARAM)ptr, result, arg );
731 free_buffer( buffer, ptr );
734 break;
736 case WM_MDICREATE:
738 char *ptr, buffer[1024];
739 DWORD title_lenA = 0, title_lenW = 0, class_lenA = 0, class_lenW = 0;
740 MDICREATESTRUCTW *csW = (MDICREATESTRUCTW *)lParam;
741 MDICREATESTRUCTA csA;
743 memcpy( &csA, csW, sizeof(csA) );
745 if (!IS_INTRESOURCE(csW->szTitle))
747 title_lenW = (strlenW(csW->szTitle) + 1) * sizeof(WCHAR);
748 RtlUnicodeToMultiByteSize( &title_lenA, csW->szTitle, title_lenW );
750 if (!IS_INTRESOURCE(csW->szClass))
752 class_lenW = (strlenW(csW->szClass) + 1) * sizeof(WCHAR);
753 RtlUnicodeToMultiByteSize( &class_lenA, csW->szClass, class_lenW );
756 if (!(ptr = get_buffer( buffer, sizeof(buffer), title_lenA + class_lenA ))) break;
758 if (title_lenA)
760 RtlUnicodeToMultiByteN( ptr, title_lenA, NULL, csW->szTitle, title_lenW );
761 csA.szTitle = ptr;
763 if (class_lenA)
765 RtlUnicodeToMultiByteN( ptr + title_lenA, class_lenA, NULL, csW->szClass, class_lenW );
766 csA.szClass = ptr + title_lenA;
768 ret = callback( hwnd, msg, wParam, (LPARAM)&csA, result, arg );
769 free_buffer( buffer, ptr );
771 break;
773 case LB_GETTEXT:
774 case CB_GETLBTEXT:
775 if (lParam && WINPROC_TestLBForStr( hwnd, msg ))
777 char buffer[512]; /* FIXME: fixed sized buffer */
779 ret = callback( hwnd, msg, wParam, (LPARAM)buffer, result, arg );
780 if (*result >= 0)
782 DWORD len;
783 RtlMultiByteToUnicodeN( (LPWSTR)lParam, ~0u, &len, buffer, strlen(buffer) + 1 );
784 *result = len / sizeof(WCHAR) - 1;
787 else ret = callback( hwnd, msg, wParam, lParam, result, arg );
788 break;
790 case EM_GETLINE:
792 char *ptr, buffer[512];
793 WORD len = *(WORD *)lParam;
795 if (!(ptr = get_buffer( buffer, sizeof(buffer), len * 2 ))) break;
796 *((WORD *)ptr) = len * 2; /* store the length */
797 ret = callback( hwnd, msg, wParam, (LPARAM)ptr, result, arg );
798 if (*result)
800 DWORD reslen;
801 RtlMultiByteToUnicodeN( (LPWSTR)lParam, len*sizeof(WCHAR), &reslen, ptr, *result );
802 *result = reslen / sizeof(WCHAR);
803 if (*result < len) ((LPWSTR)lParam)[*result] = 0;
805 free_buffer( buffer, ptr );
807 break;
809 case WM_GETDLGCODE:
810 if (lParam)
812 MSG newmsg = *(MSG *)lParam;
813 switch(newmsg.message)
815 case WM_CHAR:
816 case WM_DEADCHAR:
817 case WM_SYSCHAR:
818 case WM_SYSDEADCHAR:
819 newmsg.wParam = map_wparam_char_WtoA( newmsg.wParam, 1 );
820 break;
821 case WM_IME_CHAR:
822 newmsg.wParam = map_wparam_char_WtoA( newmsg.wParam, 2 );
823 break;
825 ret = callback( hwnd, msg, wParam, (LPARAM)&newmsg, result, arg );
827 else ret = callback( hwnd, msg, wParam, lParam, result, arg );
828 break;
830 case WM_CHAR:
832 WCHAR wch = wParam;
833 char ch[2];
834 DWORD cp = get_input_codepage();
835 DWORD len = WideCharToMultiByte( cp, 0, &wch, 1, ch, 2, NULL, NULL );
836 ret = callback( hwnd, msg, (BYTE)ch[0], lParam, result, arg );
837 if (len == 2) ret = callback( hwnd, msg, (BYTE)ch[1], lParam, result, arg );
839 break;
841 case WM_CHARTOITEM:
842 case WM_MENUCHAR:
843 case WM_DEADCHAR:
844 case WM_SYSCHAR:
845 case WM_SYSDEADCHAR:
846 case EM_SETPASSWORDCHAR:
847 ret = callback( hwnd, msg, map_wparam_char_WtoA(wParam,1), lParam, result, arg );
848 break;
850 case WM_IME_CHAR:
851 ret = callback( hwnd, msg, map_wparam_char_WtoA(wParam,2), lParam, result, arg );
852 break;
854 case WM_PAINTCLIPBOARD:
855 case WM_SIZECLIPBOARD:
856 FIXME_(msg)( "message %s (%04x) needs translation, please report\n",
857 SPY_GetMsgName(msg, hwnd), msg );
858 break;
860 default:
861 ret = callback( hwnd, msg, wParam, lParam, result, arg );
862 break;
865 return ret;
869 /**********************************************************************
870 * WINPROC_call_window
872 * Call the window procedure of the specified window.
874 BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
875 LRESULT *result, BOOL unicode, enum wm_char_mapping mapping )
877 struct user_thread_info *thread_info = get_user_thread_info();
878 BOOL unicode_win, is_dialog;
879 WND *wndPtr;
880 WNDPROC func;
881 WINDOWPROC *proc;
883 if (!(wndPtr = WIN_GetPtr( hwnd ))) return FALSE;
884 if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE;
885 if (wndPtr->tid != GetCurrentThreadId())
887 WIN_ReleasePtr( wndPtr );
888 return FALSE;
890 func = wndPtr->winproc;
891 proc = handle_to_proc( wndPtr->winproc );
892 unicode_win = wndPtr->flags & WIN_ISUNICODE;
893 is_dialog = wndPtr->dlgInfo != NULL;
894 WIN_ReleasePtr( wndPtr );
896 if (thread_info->recursion_count > MAX_WINPROC_RECURSION) return FALSE;
897 thread_info->recursion_count++;
899 if (unicode)
901 if (proc == WINPROC_PROC16)
902 WINPROC_CallProcWtoA( wow_handlers.call_window_proc, hwnd, msg, wParam, lParam, result, func );
903 else if (is_dialog)
905 if (unicode_win)
907 if (proc && proc->procW)
908 call_window_proc( hwnd, msg, wParam, lParam, result, proc->procW );
909 else
910 call_window_proc( hwnd, msg, wParam, lParam, result, func );
912 else
914 if (proc && proc->procA)
915 WINPROC_CallProcWtoA( call_window_proc, hwnd, msg, wParam, lParam, result, proc->procA );
916 else
917 WINPROC_CallProcWtoA( call_window_proc, hwnd, msg, wParam, lParam, result, func );
920 else if (proc && proc->procW)
921 call_window_proc( hwnd, msg, wParam, lParam, result, proc->procW );
922 else if (proc)
923 WINPROC_CallProcWtoA( call_window_proc, hwnd, msg, wParam, lParam, result, proc->procA );
924 else if (unicode_win)
925 call_window_proc( hwnd, msg, wParam, lParam, result, func );
926 else
927 WINPROC_CallProcWtoA( call_window_proc, hwnd, msg, wParam, lParam, result, func );
929 else
931 if (proc == WINPROC_PROC16)
932 wow_handlers.call_window_proc( hwnd, msg, wParam, lParam, result, func );
933 else if (is_dialog)
935 if (unicode_win)
937 if (proc && proc->procW)
938 WINPROC_CallProcAtoW( call_window_proc, hwnd, msg, wParam, lParam, result, proc->procW, mapping );
939 else
940 WINPROC_CallProcAtoW( call_window_proc, hwnd, msg, wParam, lParam, result, func, mapping );
942 else
944 if (proc && proc->procA)
945 call_window_proc( hwnd, msg, wParam, lParam, result, proc->procA );
946 else
947 call_window_proc( hwnd, msg, wParam, lParam, result, func );
950 else if (proc && proc->procA)
951 call_window_proc( hwnd, msg, wParam, lParam, result, proc->procA );
952 else if (proc)
953 WINPROC_CallProcAtoW( call_window_proc, hwnd, msg, wParam, lParam, result, proc->procW, mapping );
954 else if (unicode_win)
955 WINPROC_CallProcAtoW( call_window_proc, hwnd, msg, wParam, lParam, result, func, mapping );
956 else
957 call_window_proc( hwnd, msg, wParam, lParam, result, func );
959 thread_info->recursion_count--;
960 return TRUE;
964 /**********************************************************************
965 * CallWindowProcA (USER32.@)
967 * The CallWindowProc() function invokes the windows procedure _func_,
968 * with _hwnd_ as the target window, the message specified by _msg_, and
969 * the message parameters _wParam_ and _lParam_.
971 * Some kinds of argument conversion may be done, I'm not sure what.
973 * CallWindowProc() may be used for windows subclassing. Use
974 * SetWindowLong() to set a new windows procedure for windows of the
975 * subclass, and handle subclassed messages in the new windows
976 * procedure. The new windows procedure may then use CallWindowProc()
977 * with _func_ set to the parent class's windows procedure to dispatch
978 * the message to the superclass.
980 * RETURNS
982 * The return value is message dependent.
984 * CONFORMANCE
986 * ECMA-234, Win32
988 LRESULT WINAPI CallWindowProcA(
989 WNDPROC func, /* [in] window procedure */
990 HWND hwnd, /* [in] target window */
991 UINT msg, /* [in] message */
992 WPARAM wParam, /* [in] message dependent parameter */
993 LPARAM lParam /* [in] message dependent parameter */
995 WINDOWPROC *proc;
996 LRESULT result;
998 if (!func) return 0;
1000 if (!(proc = handle_to_proc( func )))
1001 call_window_proc( hwnd, msg, wParam, lParam, &result, func );
1002 else if (proc == WINPROC_PROC16)
1003 wow_handlers.call_window_proc( hwnd, msg, wParam, lParam, &result, func );
1004 else if (proc->procA)
1005 call_window_proc( hwnd, msg, wParam, lParam, &result, proc->procA );
1006 else
1007 WINPROC_CallProcAtoW( call_window_proc, hwnd, msg, wParam, lParam, &result,
1008 proc->procW, WMCHAR_MAP_CALLWINDOWPROC );
1009 return result;
1013 /**********************************************************************
1014 * CallWindowProcW (USER32.@)
1016 * See CallWindowProcA.
1018 LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg,
1019 WPARAM wParam, LPARAM lParam )
1021 WINDOWPROC *proc;
1022 LRESULT result;
1024 if (!func) return 0;
1026 if (!(proc = handle_to_proc( func )))
1027 call_window_proc( hwnd, msg, wParam, lParam, &result, func );
1028 else if (proc == WINPROC_PROC16)
1029 WINPROC_CallProcWtoA( wow_handlers.call_window_proc, hwnd, msg, wParam, lParam, &result, func );
1030 else if (proc->procW)
1031 call_window_proc( hwnd, msg, wParam, lParam, &result, proc->procW );
1032 else
1033 WINPROC_CallProcWtoA( call_window_proc, hwnd, msg, wParam, lParam, &result, proc->procA );
1034 return result;
1038 /**********************************************************************
1039 * WINPROC_CallDlgProcA
1041 INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1043 WINDOWPROC *proc;
1044 LRESULT result;
1045 INT_PTR ret;
1047 if (!func) return 0;
1049 if (!(proc = handle_to_proc( func )))
1050 ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, func );
1051 else if (proc == WINPROC_PROC16)
1053 ret = wow_handlers.call_dialog_proc( hwnd, msg, wParam, lParam, &result, func );
1054 SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result );
1056 else
1057 ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc->procW ? proc->procW : proc->procA );
1059 return ret;
1063 /**********************************************************************
1064 * WINPROC_CallDlgProcW
1066 INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1068 WINDOWPROC *proc;
1069 LRESULT result;
1070 INT_PTR ret;
1072 if (!func) return 0;
1074 if (!(proc = handle_to_proc( func )))
1075 ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, func );
1076 else if (proc == WINPROC_PROC16)
1078 ret = WINPROC_CallProcWtoA( wow_handlers.call_dialog_proc, hwnd, msg, wParam, lParam, &result, func );
1079 SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result );
1081 else
1082 ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc->procW ? proc->procW : proc->procA );
1084 return ret;
1088 /***********************************************************************
1089 * Window procedures for builtin classes
1092 static LRESULT WINAPI ButtonWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1094 return wow_handlers.button_proc( hwnd, msg, wParam, lParam, FALSE );
1097 static LRESULT WINAPI ButtonWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1099 return wow_handlers.button_proc( hwnd, msg, wParam, lParam, TRUE );
1102 static LRESULT WINAPI ComboWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
1104 return wow_handlers.combo_proc( hwnd, message, wParam, lParam, FALSE );
1107 static LRESULT WINAPI ComboWndProcW( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
1109 return wow_handlers.combo_proc( hwnd, message, wParam, lParam, TRUE );
1112 LRESULT WINAPI EditWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1114 return wow_handlers.edit_proc( hwnd, msg, wParam, lParam, FALSE );
1117 static LRESULT WINAPI EditWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1119 return wow_handlers.edit_proc( hwnd, msg, wParam, lParam, TRUE );
1122 static LRESULT WINAPI ListBoxWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1124 return wow_handlers.listbox_proc( hwnd, msg, wParam, lParam, FALSE );
1127 static LRESULT WINAPI ListBoxWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1129 return wow_handlers.listbox_proc( hwnd, msg, wParam, lParam, TRUE );
1132 static LRESULT WINAPI MDIClientWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1134 return wow_handlers.mdiclient_proc( hwnd, msg, wParam, lParam, FALSE );
1137 static LRESULT WINAPI MDIClientWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1139 return wow_handlers.mdiclient_proc( hwnd, msg, wParam, lParam, TRUE );
1142 static LRESULT WINAPI ScrollBarWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1144 return wow_handlers.scrollbar_proc( hwnd, msg, wParam, lParam, FALSE );
1147 static LRESULT WINAPI ScrollBarWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1149 return wow_handlers.scrollbar_proc( hwnd, msg, wParam, lParam, TRUE );
1152 static LRESULT WINAPI StaticWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1154 return wow_handlers.static_proc( hwnd, msg, wParam, lParam, FALSE );
1157 static LRESULT WINAPI StaticWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1159 return wow_handlers.static_proc( hwnd, msg, wParam, lParam, TRUE );
1162 static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags )
1164 DWORD ret = USER_Driver->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags );
1165 if (ret == WAIT_TIMEOUT && !count && !timeout) NtYieldExecution();
1166 if ((mask & QS_INPUT) == QS_INPUT) get_user_thread_info()->message_count = 0;
1167 return ret;
1170 /**********************************************************************
1171 * UserRegisterWowHandlers (USER32.@)
1173 * NOTE: no attempt has been made to be compatible here,
1174 * the Windows function is most likely completely different.
1176 void WINAPI UserRegisterWowHandlers( const struct wow_handlers16 *new, struct wow_handlers32 *orig )
1178 orig->button_proc = ButtonWndProc_common;
1179 orig->combo_proc = ComboWndProc_common;
1180 orig->edit_proc = EditWndProc_common;
1181 orig->listbox_proc = ListBoxWndProc_common;
1182 orig->mdiclient_proc = MDIClientWndProc_common;
1183 orig->scrollbar_proc = ScrollBarWndProc_common;
1184 orig->static_proc = StaticWndProc_common;
1185 orig->wait_message = wait_message;
1186 orig->create_window = WIN_CreateWindowEx;
1187 orig->get_win_handle = WIN_GetFullHandle;
1188 orig->alloc_winproc = WINPROC_AllocProc;
1189 orig->get_dialog_info = DIALOG_get_info;
1190 orig->dialog_box_loop = DIALOG_DoDialogBox;
1191 orig->get_icon_param = get_icon_param;
1192 orig->set_icon_param = set_icon_param;
1194 wow_handlers = *new;
1197 struct wow_handlers16 wow_handlers =
1199 ButtonWndProc_common,
1200 ComboWndProc_common,
1201 EditWndProc_common,
1202 ListBoxWndProc_common,
1203 MDIClientWndProc_common,
1204 ScrollBarWndProc_common,
1205 StaticWndProc_common,
1206 wait_message,
1207 WIN_CreateWindowEx,
1208 NULL, /* call_window_proc */
1209 NULL, /* call_dialog_proc */
1210 NULL, /* free_icon_param */