Message translation for WM_WININICHANGE.
[wine/multimedia.git] / windows / winproc.c
blobd26886c53aefa5c888c1a39a7b53e05a0ec074c4
1 /*
2 * Window procedure callbacks
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1996 Alexandre Julliard
6 */
8 #include "wine/winbase16.h"
9 #include "winuser.h"
10 #include "callback.h"
11 #include "heap.h"
12 #include "selectors.h"
13 #include "struct32.h"
14 #include "win.h"
15 #include "winproc.h"
16 #include "debug.h"
17 #include "spy.h"
18 #include "commctrl.h"
19 #include "task.h"
20 #include "thread.h"
22 /* Window procedure 16-to-32-bit thunk,
23 * see BuildSpec16Files() in tools/build.c */
25 typedef struct
27 BYTE popl_eax; /* popl %eax (return address) */
28 BYTE pushl_func; /* pushl $proc */
29 WNDPROC proc WINE_PACKED;
30 BYTE pushl_eax; /* pushl %eax */
31 WORD pushw_bp WINE_PACKED; /* pushw %bp */
32 BYTE pushl_thunk; /* pushl $thunkfrom16 */
33 void (*thunk32)() WINE_PACKED;
34 BYTE lcall; /* lcall cs:relay */
35 void (*relay)() WINE_PACKED; /* WINPROC_CallProc16To32A/W() */
36 WORD cs WINE_PACKED;
37 } WINPROC_THUNK_FROM16;
39 /* Window procedure 32-to-16-bit thunk,
40 * see BuildSpec32Files() in tools/build.c */
42 typedef struct
44 BYTE popl_eax; /* popl %eax (return address) */
45 BYTE pushl_func; /* pushl $proc */
46 WNDPROC16 proc WINE_PACKED;
47 BYTE pushl_eax; /* pushl %eax */
48 BYTE jmp; /* jmp relay (relative jump)*/
49 void (*relay)() WINE_PACKED; /* WINPROC_CallProc32ATo16() */
50 } WINPROC_THUNK_FROM32;
52 /* Simple jmp to call 32-bit procedure directly */
53 typedef struct
55 BYTE jmp; /* jmp proc (relative jump) */
56 WNDPROC proc WINE_PACKED;
57 } WINPROC_JUMP;
59 typedef union
61 WINPROC_THUNK_FROM16 t_from16;
62 WINPROC_THUNK_FROM32 t_from32;
63 } WINPROC_THUNK;
65 typedef struct tagWINDOWPROC
67 WINPROC_THUNK thunk; /* Thunk */
68 WINPROC_JUMP jmp; /* Jump */
69 struct tagWINDOWPROC *next; /* Next window proc */
70 UINT magic; /* Magic number */
71 WINDOWPROCTYPE type; /* Function type */
72 WINDOWPROCUSER user; /* Function user */
73 } WINDOWPROC;
75 #define WINPROC_MAGIC ('W' | ('P' << 8) | ('R' << 16) | ('C' << 24))
77 #define WINPROC_THUNKPROC(pproc) \
78 (((pproc)->type == WIN_PROC_16) ? \
79 (WNDPROC16)((pproc)->thunk.t_from32.proc) : \
80 (WNDPROC16)((pproc)->thunk.t_from16.proc))
82 static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND hwnd,
83 UINT msg, WPARAM wParam,
84 LPARAM lParam );
85 static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND hwnd,
86 UINT msg, WPARAM wParam,
87 LPARAM lParam );
88 static LRESULT WINPROC_CallProc16To32A( HWND16 hwnd, UINT16 msg,
89 WPARAM16 wParam, LPARAM lParam,
90 WNDPROC func );
91 static LRESULT WINPROC_CallProc16To32W( HWND16 hwnd, UINT16 msg,
92 WPARAM16 wParam, LPARAM lParam,
93 WNDPROC func );
95 static HANDLE WinProcHeap;
98 /**********************************************************************
99 * WINPROC_Init
101 BOOL WINPROC_Init(void)
103 WinProcHeap = HeapCreate( HEAP_WINE_SEGPTR | HEAP_WINE_CODESEG, 0, 0 );
104 if (!WinProcHeap)
106 WARN(relay, "Unable to create winproc heap\n" );
107 return FALSE;
109 return TRUE;
113 /**********************************************************************
114 * WINPROC_CallWndProc32
116 * Call a 32-bit WndProc.
118 static LRESULT WINPROC_CallWndProc( WNDPROC proc, HWND hwnd, UINT msg,
119 WPARAM wParam, LPARAM lParam )
121 TRACE(relay, "(wndproc=%p,hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n",
122 proc, hwnd, SPY_GetMsgName(msg), wParam, lParam );
123 return proc( hwnd, msg, wParam, lParam );
127 /**********************************************************************
128 * WINPROC_GetPtr
130 * Return a pointer to the win proc.
132 static WINDOWPROC *WINPROC_GetPtr( WNDPROC16 handle )
134 BYTE *ptr;
135 WINDOWPROC *proc;
137 /* Check for a linear pointer */
139 if (HEAP_IsInsideHeap( WinProcHeap, 0, (LPVOID)handle ))
141 ptr = (BYTE *)handle;
142 /* First check if it is the jmp address */
143 if (*ptr == 0xe9 /* jmp */) ptr -= (int)&((WINDOWPROC *)0)->jmp -
144 (int)&((WINDOWPROC *)0)->thunk;
145 /* Now it must be the thunk address */
146 if (*ptr == 0x58 /* popl eax */) ptr -= (int)&((WINDOWPROC *)0)->thunk;
147 /* Now we have a pointer to the WINDOWPROC struct */
148 if (((WINDOWPROC *)ptr)->magic == WINPROC_MAGIC)
149 return (WINDOWPROC *)ptr;
152 /* Check for a segmented pointer */
154 if (!IsBadReadPtr16((SEGPTR)handle,sizeof(WINDOWPROC)-sizeof(proc->thunk)))
156 ptr = (BYTE *)PTR_SEG_TO_LIN(handle);
157 if (!HEAP_IsInsideHeap( WinProcHeap, 0, ptr )) return NULL;
158 /* It must be the thunk address */
159 if (*ptr == 0x58 /* popl eax */) ptr -= (int)&((WINDOWPROC *)0)->thunk;
160 /* Now we have a pointer to the WINDOWPROC struct */
161 if (((WINDOWPROC *)ptr)->magic == WINPROC_MAGIC)
162 return (WINDOWPROC *)ptr;
165 return NULL;
169 /**********************************************************************
170 * WINPROC_AllocWinProc
172 * Allocate a new window procedure.
174 static WINDOWPROC *WINPROC_AllocWinProc( WNDPROC16 func, WINDOWPROCTYPE type,
175 WINDOWPROCUSER user )
177 WINDOWPROC *proc, *oldproc;
179 /* Allocate a window procedure */
181 if (!(proc = HeapAlloc( WinProcHeap, 0, sizeof(WINDOWPROC) ))) return 0;
183 /* Check if the function is already a win proc */
185 if ((oldproc = WINPROC_GetPtr( func )))
187 *proc = *oldproc;
189 else
191 switch(type)
193 case WIN_PROC_16:
194 proc->thunk.t_from32.popl_eax = 0x58; /* popl %eax */
195 proc->thunk.t_from32.pushl_func = 0x68; /* pushl $proc */
196 proc->thunk.t_from32.proc = func;
197 proc->thunk.t_from32.pushl_eax = 0x50; /* pushl %eax */
198 proc->thunk.t_from32.jmp = 0xe9; /* jmp relay*/
199 proc->thunk.t_from32.relay = /* relative jump */
200 (void(*)())((DWORD)WINPROC_CallProc32ATo16 -
201 (DWORD)(&proc->thunk.t_from32.relay + 1));
202 break;
203 case WIN_PROC_32A:
204 case WIN_PROC_32W:
205 proc->thunk.t_from16.popl_eax = 0x58; /* popl %eax */
206 proc->thunk.t_from16.pushl_func = 0x68; /* pushl $proc */
207 proc->thunk.t_from16.proc = (FARPROC)func;
208 proc->thunk.t_from16.pushl_eax = 0x50; /* pushl %eax */
209 proc->thunk.t_from16.pushw_bp = 0x5566; /* pushw %bp */
210 proc->thunk.t_from16.pushl_thunk = 0x68; /* pushl $thunkfrom16 */
211 proc->thunk.t_from16.thunk32 = (type == WIN_PROC_32A) ?
212 (void(*)())WINPROC_CallProc16To32A :
213 (void(*)())WINPROC_CallProc16To32W;
214 proc->thunk.t_from16.lcall = 0x9a; /* lcall cs:relay */
215 proc->thunk.t_from16.relay = (void*)Callbacks->CallFrom16WndProc;
216 GET_CS(proc->thunk.t_from16.cs);
217 proc->jmp.jmp = 0xe9;
218 /* Fixup relative jump */
219 proc->jmp.proc = (WNDPROC)((DWORD)func -
220 (DWORD)(&proc->jmp.proc + 1));
221 break;
222 default:
223 /* Should not happen */
224 break;
226 proc->magic = WINPROC_MAGIC;
227 proc->type = type;
228 proc->user = user;
230 proc->next = NULL;
231 TRACE(win, "(%08x,%d): returning %08x\n",
232 (UINT)func, type, (UINT)proc );
233 return proc;
237 /**********************************************************************
238 * WINPROC_GetProc
240 * Get a window procedure pointer that can be passed to the Windows program.
242 WNDPROC16 WINPROC_GetProc( HWINDOWPROC proc, WINDOWPROCTYPE type )
244 if (!proc) return NULL;
245 if (type == WIN_PROC_16) /* We want a 16:16 address */
247 if (((WINDOWPROC *)proc)->type == WIN_PROC_16)
248 return ((WINDOWPROC *)proc)->thunk.t_from32.proc;
249 else
250 return (WNDPROC16)HEAP_GetSegptr( WinProcHeap, 0,
251 &((WINDOWPROC *)proc)->thunk );
253 else /* We want a 32-bit address */
255 if (((WINDOWPROC *)proc)->type == WIN_PROC_16)
256 return (WNDPROC16)&((WINDOWPROC *)proc)->thunk;
257 else if (type != ((WINDOWPROC *)proc)->type)
258 /* Have to return the jmp address if types don't match */
259 return (WNDPROC16)&((WINDOWPROC *)proc)->jmp;
260 else
261 /* Some Win16 programs want to get back the proc they set */
262 return (WNDPROC16)((WINDOWPROC *)proc)->thunk.t_from16.proc;
267 /**********************************************************************
268 * WINPROC_SetProc
270 * Set the window procedure for a window or class. There are
271 * three tree classes of winproc callbacks:
273 * 1) class -> wp - not subclassed
274 * class -> wp -> wp -> wp -> wp - SetClassLong()
275 * / /
276 * 2) window -' / - not subclassed
277 * window -> wp -> wp ' - SetWindowLong()
279 * 3) timer -> wp - SetTimer()
281 * Initially, winproc of the window points to the current winproc
282 * thunk of its class. Subclassing prepends a new thunk to the
283 * window winproc chain at the head of the list. Thus, window thunk
284 * list includes class thunks and the latter are preserved when the
285 * window is destroyed.
288 BOOL WINPROC_SetProc( HWINDOWPROC *pFirst, WNDPROC16 func,
289 WINDOWPROCTYPE type, WINDOWPROCUSER user )
291 BOOL bRecycle = FALSE;
292 WINDOWPROC *proc, **ppPrev;
294 /* Check if function is already in the list */
296 ppPrev = (WINDOWPROC **)pFirst;
297 proc = WINPROC_GetPtr( func );
298 while (*ppPrev)
300 if (proc)
302 if (*ppPrev == proc)
304 if ((*ppPrev)->user != user)
306 /* terminal thunk is being restored */
308 WINPROC_FreeProc( *pFirst, (*ppPrev)->user );
309 *(WINDOWPROC **)pFirst = *ppPrev;
310 return TRUE;
312 bRecycle = TRUE;
313 break;
316 else
318 if (((*ppPrev)->type == type) &&
319 (func == WINPROC_THUNKPROC(*ppPrev)))
321 bRecycle = TRUE;
322 break;
326 /* WPF_CLASS thunk terminates window thunk list */
327 if ((*ppPrev)->user != user) break;
328 ppPrev = &(*ppPrev)->next;
331 if (bRecycle)
333 /* Extract this thunk from the list */
334 proc = *ppPrev;
335 *ppPrev = proc->next;
337 else /* Allocate a new one */
339 if (proc) /* Was already a win proc */
341 type = proc->type;
342 func = WINPROC_THUNKPROC(proc);
344 proc = WINPROC_AllocWinProc( func, type, user );
345 if (!proc) return FALSE;
348 /* Add the win proc at the head of the list */
350 TRACE(win, "(%08x,%08x,%d): res=%08x\n",
351 (UINT)*pFirst, (UINT)func, type, (UINT)proc );
352 proc->next = *(WINDOWPROC **)pFirst;
353 *(WINDOWPROC **)pFirst = proc;
354 return TRUE;
358 /**********************************************************************
359 * WINPROC_FreeProc
361 * Free a list of win procs.
363 void WINPROC_FreeProc( HWINDOWPROC proc, WINDOWPROCUSER user )
365 while (proc)
367 WINDOWPROC *next = ((WINDOWPROC *)proc)->next;
368 if (((WINDOWPROC *)proc)->user != user) break;
369 TRACE(win, "freeing %08x\n", (UINT)proc);
370 HeapFree( WinProcHeap, 0, proc );
371 proc = next;
376 /**********************************************************************
377 * WINPROC_GetProcType
379 * Return the window procedure type.
381 WINDOWPROCTYPE WINPROC_GetProcType( HWINDOWPROC proc )
383 if (!proc ||
384 (((WINDOWPROC *)proc)->magic != WINPROC_MAGIC))
385 return WIN_PROC_INVALID;
386 return ((WINDOWPROC *)proc)->type;
388 /**********************************************************************
389 * WINPROC_TestCBForStr
391 * Return TRUE if the lparam is a string
393 BOOL WINPROC_TestCBForStr ( HWND hwnd )
394 { WND * wnd = WIN_FindWndPtr(hwnd);
395 return ( !(LOWORD(wnd->dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
396 (LOWORD(wnd->dwStyle) & CBS_HASSTRINGS) );
398 /**********************************************************************
399 * WINPROC_TestLBForStr
401 * Return TRUE if the lparam is a string
403 BOOL WINPROC_TestLBForStr ( HWND hwnd )
404 { WND * wnd = WIN_FindWndPtr(hwnd);
405 return ( !(LOWORD(wnd->dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
406 (LOWORD(wnd->dwStyle) & LBS_HASSTRINGS) );
408 /**********************************************************************
409 * WINPROC_MapMsg32ATo32W
411 * Map a message from Ansi to Unicode.
412 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
414 * FIXME:
415 * WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR
417 * FIXME:
418 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
419 * the first four bytes are the handle of the icon
420 * when the WM_SETTEXT message has been used to set the icon
422 INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam )
424 switch(msg)
426 case WM_GETTEXT:
428 LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0,
429 wParam * sizeof(WCHAR) + sizeof(LPARAM) );
430 if (!ptr) return -1;
431 *ptr++ = *plparam; /* Store previous lParam */
432 *plparam = (LPARAM)ptr;
434 return 1;
435 /* lparam is string (0-terminated) */
436 case WM_SETTEXT:
437 case WM_WININICHANGE:
438 case CB_DIR:
439 case CB_FINDSTRING:
440 case CB_FINDSTRINGEXACT:
441 case CB_SELECTSTRING:
442 case LB_DIR:
443 case LB_ADDFILE:
444 case LB_FINDSTRING:
445 case LB_SELECTSTRING:
446 case EM_REPLACESEL:
447 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
448 return (*plparam ? 1 : -1);
450 case WM_NCCREATE:
451 case WM_CREATE:
453 CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( SystemHeap, 0,
454 sizeof(*cs) );
455 if (!cs) return -1;
456 *cs = *(CREATESTRUCTW *)*plparam;
457 if (HIWORD(cs->lpszName))
458 cs->lpszName = HEAP_strdupAtoW( SystemHeap, 0,
459 (LPCSTR)cs->lpszName );
460 if (HIWORD(cs->lpszClass))
461 cs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0,
462 (LPCSTR)cs->lpszClass );
463 *plparam = (LPARAM)cs;
465 return 1;
466 case WM_MDICREATE:
468 MDICREATESTRUCTW *cs =
469 (MDICREATESTRUCTW *)HeapAlloc( SystemHeap, 0, sizeof(*cs) );
470 if (!cs) return -1;
471 *cs = *(MDICREATESTRUCTW *)*plparam;
472 if (HIWORD(cs->szClass))
473 cs->szClass = HEAP_strdupAtoW( SystemHeap, 0,
474 (LPCSTR)cs->szClass );
475 if (HIWORD(cs->szTitle))
476 cs->szTitle = HEAP_strdupAtoW( SystemHeap, 0,
477 (LPCSTR)cs->szTitle );
478 *plparam = (LPARAM)cs;
480 return 1;
482 /* Listbox */
483 case LB_ADDSTRING:
484 case LB_INSERTSTRING:
485 if ( WINPROC_TestLBForStr( hwnd ))
486 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
487 return (*plparam ? 1 : -1);
489 case LB_GETTEXT: /* fixme: fixed sized buffer */
490 { if ( WINPROC_TestLBForStr( hwnd ))
491 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
492 if (!ptr) return -1;
493 *ptr++ = *plparam; /* Store previous lParam */
494 *plparam = (LPARAM)ptr;
497 return 1;
499 /* Combobox */
500 case CB_ADDSTRING:
501 case CB_INSERTSTRING:
502 if ( WINPROC_TestCBForStr( hwnd ))
503 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
504 return (*plparam ? 1 : -1);
506 case CB_GETLBTEXT: /* fixme: fixed sized buffer */
507 { if ( WINPROC_TestCBForStr( hwnd ))
508 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
509 if (!ptr) return -1;
510 *ptr++ = *plparam; /* Store previous lParam */
511 *plparam = (LPARAM)ptr;
514 return 1;
516 /* Multiline edit */
517 case EM_GETLINE:
518 { WORD len = (WORD)*plparam;
519 LPARAM *ptr = (LPARAM *) HEAP_xalloc( SystemHeap, 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
520 if (!ptr) return -1;
521 *ptr++ = *plparam; /* Store previous lParam */
522 (WORD)*ptr = len; /* Store the lenght */
523 *plparam = (LPARAM)ptr;
525 return 1;
527 case WM_ASKCBFORMATNAME:
528 case WM_DEVMODECHANGE:
529 case WM_PAINTCLIPBOARD:
530 case WM_SIZECLIPBOARD:
531 case EM_SETPASSWORDCHAR:
532 FIXME(msg, "message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg );
533 return -1;
534 default: /* No translation needed */
535 return 0;
540 /**********************************************************************
541 * WINPROC_UnmapMsg32ATo32W
543 * Unmap a message that was mapped from Ansi to Unicode.
545 void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
547 switch(msg)
549 case WM_GETTEXT:
551 LPARAM *ptr = (LPARAM *)lParam - 1;
552 lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam );
553 HeapFree( SystemHeap, 0, ptr );
555 break;
557 case WM_NCCREATE:
558 case WM_CREATE:
560 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
561 if (HIWORD(cs->lpszName))
562 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
563 if (HIWORD(cs->lpszClass))
564 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
565 HeapFree( SystemHeap, 0, cs );
567 break;
569 case WM_MDICREATE:
571 MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
572 if (HIWORD(cs->szTitle))
573 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
574 if (HIWORD(cs->szClass))
575 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
576 HeapFree( SystemHeap, 0, cs );
578 break;
580 case WM_SETTEXT:
581 case WM_WININICHANGE:
582 case CB_DIR:
583 case CB_FINDSTRING:
584 case CB_FINDSTRINGEXACT:
585 case CB_SELECTSTRING:
586 case LB_DIR:
587 case LB_ADDFILE:
588 case LB_FINDSTRING:
589 case LB_SELECTSTRING:
590 case EM_REPLACESEL:
591 HeapFree( SystemHeap, 0, (void *)lParam );
592 break;
594 /* Listbox */
595 case LB_ADDSTRING:
596 case LB_INSERTSTRING:
597 if ( WINPROC_TestLBForStr( hwnd ))
598 HeapFree( SystemHeap, 0, (void *)lParam );
599 break;
601 case LB_GETTEXT:
602 { if ( WINPROC_TestLBForStr( hwnd ))
603 { LPARAM *ptr = (LPARAM *)lParam - 1;
604 lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
605 HeapFree( SystemHeap, 0, ptr );
608 break;
610 /* Combobox */
611 case CB_ADDSTRING:
612 case CB_INSERTSTRING:
613 if ( WINPROC_TestCBForStr( hwnd ))
614 HeapFree( SystemHeap, 0, (void *)lParam );
615 break;
617 case CB_GETLBTEXT:
618 { if ( WINPROC_TestCBForStr( hwnd ))
619 { LPARAM *ptr = (LPARAM *)lParam - 1;
620 lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
621 HeapFree( SystemHeap, 0, ptr );
624 break;
626 /* Multiline edit */
627 case EM_GETLINE:
628 { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lParam */
629 WORD len = *(WORD *) lParam;
630 lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len );
631 HeapFree( SystemHeap, 0, ptr );
633 break;
638 /**********************************************************************
639 * WINPROC_MapMsg32WTo32A
641 * Map a message from Unicode to Ansi.
642 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
644 INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam )
645 { switch(msg)
647 case WM_GETTEXT:
649 LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0,
650 wParam + sizeof(LPARAM) );
651 if (!ptr) return -1;
652 *ptr++ = *plparam; /* Store previous lParam */
653 *plparam = (LPARAM)ptr;
655 return 1;
657 case WM_SETTEXT:
658 case WM_WININICHANGE:
659 case CB_DIR:
660 case CB_FINDSTRING:
661 case CB_FINDSTRINGEXACT:
662 case CB_SELECTSTRING:
663 case LB_DIR:
664 case LB_ADDFILE:
665 case LB_FINDSTRING:
666 case LB_SELECTSTRING:
667 case EM_REPLACESEL:
668 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
669 return (*plparam ? 1 : -1);
671 case WM_NCCREATE:
672 case WM_CREATE:
674 CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( SystemHeap, 0,
675 sizeof(*cs) );
676 if (!cs) return -1;
677 *cs = *(CREATESTRUCTA *)*plparam;
678 if (HIWORD(cs->lpszName))
679 cs->lpszName = HEAP_strdupWtoA( SystemHeap, 0,
680 (LPCWSTR)cs->lpszName );
681 if (HIWORD(cs->lpszClass))
682 cs->lpszClass = HEAP_strdupWtoA( SystemHeap, 0,
683 (LPCWSTR)cs->lpszClass);
684 *plparam = (LPARAM)cs;
686 return 1;
687 case WM_MDICREATE:
689 MDICREATESTRUCTA *cs =
690 (MDICREATESTRUCTA *)HeapAlloc( SystemHeap, 0, sizeof(*cs) );
691 if (!cs) return -1;
692 *cs = *(MDICREATESTRUCTA *)*plparam;
693 if (HIWORD(cs->szTitle))
694 cs->szTitle = HEAP_strdupWtoA( SystemHeap, 0,
695 (LPCWSTR)cs->szTitle );
696 if (HIWORD(cs->szClass))
697 cs->szClass = HEAP_strdupWtoA( SystemHeap, 0,
698 (LPCWSTR)cs->szClass );
699 *plparam = (LPARAM)cs;
701 return 1;
703 /* Listbox */
704 case LB_ADDSTRING:
705 case LB_INSERTSTRING:
706 if ( WINPROC_TestLBForStr( hwnd ))
707 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
708 return (*plparam ? 1 : -1);
710 case LB_GETTEXT: /* fixme: fixed sized buffer */
711 { if ( WINPROC_TestLBForStr( hwnd ))
712 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 + sizeof(LPARAM) );
713 if (!ptr) return -1;
714 *ptr++ = *plparam; /* Store previous lParam */
715 *plparam = (LPARAM)ptr;
718 return 1;
720 /* Combobox */
721 case CB_ADDSTRING:
722 case CB_INSERTSTRING:
723 if ( WINPROC_TestCBForStr( hwnd ))
724 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
725 return (*plparam ? 1 : -1);
727 case CB_GETLBTEXT: /* fixme: fixed sized buffer */
728 { if ( WINPROC_TestCBForStr( hwnd ))
729 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 + sizeof(LPARAM) );
730 if (!ptr) return -1;
731 *ptr++ = *plparam; /* Store previous lParam */
732 *plparam = (LPARAM)ptr;
735 return 1;
737 /* Multiline edit */
738 case EM_GETLINE:
739 { WORD len = (WORD)*plparam;
740 LPARAM *ptr = (LPARAM *) HEAP_xalloc( SystemHeap, 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
741 if (!ptr) return -1;
742 *ptr++ = *plparam; /* Store previous lParam */
743 (WORD)*ptr = len; /* Store the lenght */
744 *plparam = (LPARAM)ptr;
746 return 1;
748 case WM_ASKCBFORMATNAME:
749 case WM_DEVMODECHANGE:
750 case WM_PAINTCLIPBOARD:
751 case WM_SIZECLIPBOARD:
752 case EM_SETPASSWORDCHAR:
753 FIXME(msg, "message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg );
754 return -1;
755 default: /* No translation needed */
756 return 0;
761 /**********************************************************************
762 * WINPROC_UnmapMsg32WTo32A
764 * Unmap a message that was mapped from Unicode to Ansi.
766 void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
768 switch(msg)
770 case WM_GETTEXT:
772 LPARAM *ptr = (LPARAM *)lParam - 1;
773 lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam );
774 HeapFree( SystemHeap, 0, ptr );
776 break;
778 case WM_SETTEXT:
779 case WM_WININICHANGE:
780 case CB_DIR:
781 case CB_FINDSTRING:
782 case CB_FINDSTRINGEXACT:
783 case CB_SELECTSTRING:
784 case LB_DIR:
785 case LB_ADDFILE:
786 case LB_FINDSTRING:
787 case LB_SELECTSTRING:
788 case EM_REPLACESEL:
789 HeapFree( SystemHeap, 0, (void *)lParam );
790 break;
792 case WM_NCCREATE:
793 case WM_CREATE:
795 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
796 if (HIWORD(cs->lpszName))
797 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
798 if (HIWORD(cs->lpszClass))
799 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
800 HeapFree( SystemHeap, 0, cs );
802 break;
804 case WM_MDICREATE:
806 MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
807 if (HIWORD(cs->szTitle))
808 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
809 if (HIWORD(cs->szClass))
810 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
811 HeapFree( SystemHeap, 0, cs );
813 break;
815 /* Listbox */
816 case LB_ADDSTRING:
817 case LB_INSERTSTRING:
818 if ( WINPROC_TestLBForStr( hwnd ))
819 HeapFree( SystemHeap, 0, (void *)lParam );
820 break;
822 case LB_GETTEXT:
823 { if ( WINPROC_TestLBForStr( hwnd ))
824 { LPARAM *ptr = (LPARAM *)lParam - 1;
825 lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
826 HeapFree( SystemHeap, 0, ptr );
829 break;
831 /* Combobox */
832 case CB_ADDSTRING:
833 case CB_INSERTSTRING:
834 if ( WINPROC_TestCBForStr( hwnd ))
835 HeapFree( SystemHeap, 0, (void *)lParam );
836 break;
838 case CB_GETLBTEXT:
839 { if ( WINPROC_TestCBForStr( hwnd ))
840 { LPARAM *ptr = (LPARAM *)lParam - 1;
841 lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
842 HeapFree( SystemHeap, 0, ptr );
845 break;
847 /* Multiline edit */
848 case EM_GETLINE:
849 { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lparam */
850 WORD len = *(WORD *)ptr;
851 lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
852 HeapFree( SystemHeap, 0, ptr );
854 break;
859 /**********************************************************************
860 * WINPROC_MapMsg16To32A
862 * Map a message from 16- to 32-bit Ansi.
863 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
865 INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
866 WPARAM *pwparam32, LPARAM *plparam )
868 *pmsg32 = (UINT)msg16;
869 *pwparam32 = (WPARAM)wParam16;
870 switch(msg16)
872 case WM_ACTIVATE:
873 case WM_CHARTOITEM:
874 case WM_COMMAND:
875 case WM_VKEYTOITEM:
876 *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
877 *plparam = (LPARAM)(HWND)LOWORD(*plparam);
878 return 0;
879 case WM_HSCROLL:
880 case WM_VSCROLL:
881 *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
882 *plparam = (LPARAM)(HWND)HIWORD(*plparam);
883 return 0;
884 case WM_CTLCOLOR:
885 if ( HIWORD(*plparam) > CTLCOLOR_STATIC ) return -1;
886 *pmsg32 = WM_CTLCOLORMSGBOX + HIWORD(*plparam);
887 *pwparam32 = (WPARAM)(HDC)wParam16;
888 *plparam = (LPARAM)(HWND)LOWORD(*plparam);
889 return 0;
890 case WM_COMPAREITEM:
892 COMPAREITEMSTRUCT16* cis16 = (COMPAREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
893 COMPAREITEMSTRUCT *cis = (COMPAREITEMSTRUCT *)
894 HeapAlloc(SystemHeap, 0, sizeof(*cis));
895 if (!cis) return -1;
896 cis->CtlType = cis16->CtlType;
897 cis->CtlID = cis16->CtlID;
898 cis->hwndItem = cis16->hwndItem;
899 cis->itemID1 = cis16->itemID1;
900 cis->itemData1 = cis16->itemData1;
901 cis->itemID2 = cis16->itemID2;
902 cis->itemData2 = cis16->itemData2;
903 cis->dwLocaleId = 0; /* FIXME */
904 *plparam = (LPARAM)cis;
906 return 1;
907 case WM_DELETEITEM:
909 DELETEITEMSTRUCT16* dis16 = (DELETEITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
910 DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)
911 HeapAlloc(SystemHeap, 0, sizeof(*dis));
912 if (!dis) return -1;
913 dis->CtlType = dis16->CtlType;
914 dis->CtlID = dis16->CtlID;
915 dis->hwndItem = dis16->hwndItem;
916 dis->itemData = dis16->itemData;
917 *plparam = (LPARAM)dis;
919 return 1;
920 case WM_MEASUREITEM:
922 MEASUREITEMSTRUCT16* mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
923 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)
924 HeapAlloc(SystemHeap, 0,
925 sizeof(*mis) + sizeof(LPARAM));
926 if (!mis) return -1;
927 mis->CtlType = mis16->CtlType;
928 mis->CtlID = mis16->CtlID;
929 mis->itemID = mis16->itemID;
930 mis->itemWidth = mis16->itemWidth;
931 mis->itemHeight = mis16->itemHeight;
932 mis->itemData = mis16->itemData;
933 *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */
934 *plparam = (LPARAM)mis;
936 return 1;
937 case WM_DRAWITEM:
939 DRAWITEMSTRUCT16* dis16 = (DRAWITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
940 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)HeapAlloc(SystemHeap, 0,
941 sizeof(*dis));
942 if (!dis) return -1;
943 dis->CtlType = dis16->CtlType;
944 dis->CtlID = dis16->CtlID;
945 dis->itemID = dis16->itemID;
946 dis->itemAction = dis16->itemAction;
947 dis->itemState = dis16->itemState;
948 dis->hwndItem = dis16->hwndItem;
949 dis->hDC = dis16->hDC;
950 dis->itemData = dis16->itemData;
951 CONV_RECT16TO32( &dis16->rcItem, &dis->rcItem );
952 *plparam = (LPARAM)dis;
954 return 1;
955 case WM_GETMINMAXINFO:
957 MINMAXINFO *mmi = (MINMAXINFO *)HeapAlloc( SystemHeap, 0,
958 sizeof(*mmi) + sizeof(LPARAM));
959 if (!mmi) return -1;
960 STRUCT32_MINMAXINFO16to32( (MINMAXINFO16*)PTR_SEG_TO_LIN(*plparam),
961 mmi );
962 *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */
963 *plparam = (LPARAM)mmi;
965 return 1;
966 case WM_GETTEXT:
967 case WM_SETTEXT:
968 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
969 return 0;
970 case WM_MDICREATE:
972 MDICREATESTRUCT16 *cs16 =
973 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
974 MDICREATESTRUCTA *cs =
975 (MDICREATESTRUCTA *)HeapAlloc( SystemHeap, 0,
976 sizeof(*cs) + sizeof(LPARAM) );
977 if (!cs) return -1;
978 STRUCT32_MDICREATESTRUCT16to32A( cs16, cs );
979 cs->szTitle = (LPCSTR)PTR_SEG_TO_LIN(cs16->szTitle);
980 cs->szClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->szClass);
981 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
982 *plparam = (LPARAM)cs;
984 return 1;
985 case WM_MDIGETACTIVE:
986 *plparam = (LPARAM)HeapAlloc( SystemHeap, 0, sizeof(BOOL) );
987 *(BOOL*)(*plparam) = 0;
988 return 1;
989 case WM_MDISETMENU:
990 if(wParam16==TRUE)
991 *pmsg32=WM_MDIREFRESHMENU;
992 *pwparam32 = (WPARAM)(HMENU)LOWORD(*plparam);
993 *plparam = (LPARAM)(HMENU)HIWORD(*plparam);
994 return 0;
995 case WM_MENUCHAR:
996 case WM_MENUSELECT:
997 *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
998 *plparam = (LPARAM)(HMENU)HIWORD(*plparam);
999 return 0;
1000 case WM_MDIACTIVATE:
1001 if( *plparam )
1003 *pwparam32 = (WPARAM)(HWND)HIWORD(*plparam);
1004 *plparam = (LPARAM)(HWND)LOWORD(*plparam);
1006 else /* message sent to MDI client */
1007 *pwparam32 = wParam16;
1008 return 0;
1009 case WM_NCCALCSIZE:
1011 NCCALCSIZE_PARAMS16 *nc16;
1012 NCCALCSIZE_PARAMS *nc;
1014 nc = (NCCALCSIZE_PARAMS *)HeapAlloc( SystemHeap, 0,
1015 sizeof(*nc) + sizeof(LPARAM) );
1016 if (!nc) return -1;
1017 nc16 = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(*plparam);
1018 CONV_RECT16TO32( &nc16->rgrc[0], &nc->rgrc[0] );
1019 if (wParam16)
1021 nc->lppos = (WINDOWPOS *)HeapAlloc( SystemHeap, 0,
1022 sizeof(*nc->lppos) );
1023 CONV_RECT16TO32( &nc16->rgrc[1], &nc->rgrc[1] );
1024 CONV_RECT16TO32( &nc16->rgrc[2], &nc->rgrc[2] );
1025 if (nc->lppos) STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc16->lppos), nc->lppos );
1027 *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */
1028 *plparam = (LPARAM)nc;
1030 return 1;
1031 case WM_NCCREATE:
1032 case WM_CREATE:
1034 CREATESTRUCT16 *cs16 = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1035 CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( SystemHeap, 0,
1036 sizeof(*cs) + sizeof(LPARAM) );
1037 if (!cs) return -1;
1038 STRUCT32_CREATESTRUCT16to32A( cs16, cs );
1039 cs->lpszName = (LPCSTR)PTR_SEG_TO_LIN(cs16->lpszName);
1040 cs->lpszClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->lpszClass);
1041 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1042 *plparam = (LPARAM)cs;
1044 return 1;
1045 case WM_PARENTNOTIFY:
1046 if ((wParam16 == WM_CREATE) || (wParam16 == WM_DESTROY))
1048 *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
1049 *plparam = (LPARAM)(HWND)LOWORD(*plparam);
1051 return 0;
1052 case WM_WINDOWPOSCHANGING:
1053 case WM_WINDOWPOSCHANGED:
1055 WINDOWPOS *wp = (WINDOWPOS *)HeapAlloc( SystemHeap, 0,
1056 sizeof(*wp) + sizeof(LPARAM) );
1057 if (!wp) return -1;
1058 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(*plparam),
1059 wp );
1060 *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */
1061 *plparam = (LPARAM)wp;
1063 return 1;
1064 case WM_GETDLGCODE:
1065 if (*plparam)
1067 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(*plparam);
1068 LPMSG msg32 = (LPMSG)HeapAlloc( SystemHeap, 0, sizeof(MSG) );
1070 if (!msg32) return -1;
1071 msg32->hwnd = msg16->hwnd;
1072 msg32->lParam = msg16->lParam;
1073 msg32->time = msg16->time;
1074 CONV_POINT16TO32(&msg16->pt,&msg32->pt);
1075 /* this is right, right? */
1076 if (WINPROC_MapMsg16To32A(msg16->message,msg16->wParam,
1077 &msg32->message,&msg32->wParam,
1078 &msg32->lParam)<0) {
1079 HeapFree( SystemHeap, 0, msg32 );
1080 return -1;
1082 *plparam = (LPARAM)msg32;
1083 return 1;
1085 else return 0;
1086 case WM_NOTIFY:
1087 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
1088 return 1;
1089 case WM_ACTIVATEAPP:
1090 if (*plparam)
1091 { /* We need this when SetActiveWindow sends a Sendmessage16() to
1092 a 32bit window. Might be superflous with 32bit interprocess
1093 message queues.
1095 HTASK16 htask = (HTASK16) *plparam;
1096 DWORD idThread = (DWORD)((TDB*)GlobalLock16(htask))->thdb->server_tid;
1097 *plparam = (LPARAM) idThread;
1099 return 1;
1100 case WM_ASKCBFORMATNAME:
1101 case WM_DEVMODECHANGE:
1102 case WM_PAINTCLIPBOARD:
1103 case WM_SIZECLIPBOARD:
1104 case WM_WININICHANGE:
1105 FIXME( msg, "message %04x needs translation\n",msg16 );
1106 return -1;
1108 default: /* No translation needed */
1109 return 0;
1114 /**********************************************************************
1115 * WINPROC_UnmapMsg16To32A
1117 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1119 LRESULT WINPROC_UnmapMsg16To32A( HWND16 hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
1120 LRESULT result )
1122 switch(msg)
1124 case WM_COMPAREITEM:
1125 case WM_DELETEITEM:
1126 case WM_DRAWITEM:
1127 HeapFree( SystemHeap, 0, (LPVOID)lParam );
1128 break;
1129 case WM_MEASUREITEM:
1131 MEASUREITEMSTRUCT16 *mis16;
1132 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam;
1133 lParam = *(LPARAM *)(mis + 1);
1134 mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(lParam);
1135 mis16->itemWidth = (UINT16)mis->itemWidth;
1136 mis16->itemHeight = (UINT16)mis->itemHeight;
1137 HeapFree( SystemHeap, 0, mis );
1139 break;
1140 case WM_GETMINMAXINFO:
1142 MINMAXINFO *mmi = (MINMAXINFO *)lParam;
1143 lParam = *(LPARAM *)(mmi + 1);
1144 STRUCT32_MINMAXINFO32to16( mmi,
1145 (MINMAXINFO16 *)PTR_SEG_TO_LIN(lParam));
1146 HeapFree( SystemHeap, 0, mmi );
1148 break;
1149 case WM_MDICREATE:
1151 MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
1152 lParam = *(LPARAM *)(cs + 1);
1153 STRUCT32_MDICREATESTRUCT32Ato16( cs,
1154 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1155 HeapFree( SystemHeap, 0, cs );
1157 break;
1158 case WM_MDIGETACTIVE:
1159 result = MAKELONG( LOWORD(result), (BOOL16)(*(BOOL *)lParam) );
1160 HeapFree( SystemHeap, 0, (BOOL *)lParam );
1161 break;
1162 case WM_NCCALCSIZE:
1164 NCCALCSIZE_PARAMS16 *nc16;
1165 NCCALCSIZE_PARAMS *nc = (NCCALCSIZE_PARAMS *)lParam;
1166 lParam = *(LPARAM *)(nc + 1);
1167 nc16 = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(lParam);
1168 CONV_RECT32TO16( &nc->rgrc[0], &nc16->rgrc[0] );
1169 if (wParam)
1171 CONV_RECT32TO16( &nc->rgrc[1], &nc16->rgrc[1] );
1172 CONV_RECT32TO16( &nc->rgrc[2], &nc16->rgrc[2] );
1173 if (nc->lppos)
1175 STRUCT32_WINDOWPOS32to16( nc->lppos,
1176 (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc16->lppos));
1177 HeapFree( SystemHeap, 0, nc->lppos );
1180 HeapFree( SystemHeap, 0, nc );
1182 break;
1183 case WM_NCCREATE:
1184 case WM_CREATE:
1186 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
1187 lParam = *(LPARAM *)(cs + 1);
1188 STRUCT32_CREATESTRUCT32Ato16( cs,
1189 (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1190 HeapFree( SystemHeap, 0, cs );
1192 break;
1193 case WM_WINDOWPOSCHANGING:
1194 case WM_WINDOWPOSCHANGED:
1196 WINDOWPOS *wp = (WINDOWPOS *)lParam;
1197 lParam = *(LPARAM *)(wp + 1);
1198 STRUCT32_WINDOWPOS32to16(wp,(WINDOWPOS16 *)PTR_SEG_TO_LIN(lParam));
1199 HeapFree( SystemHeap, 0, wp );
1201 break;
1202 case WM_GETDLGCODE:
1203 if (lParam)
1205 LPMSG msg32 = (LPMSG)lParam;
1207 WINPROC_UnmapMsg16To32A( hwnd, msg32->message, msg32->wParam, msg32->lParam,
1208 result);
1209 HeapFree( SystemHeap, 0, msg32 );
1211 break;
1213 return result;
1217 /**********************************************************************
1218 * WINPROC_MapMsg16To32W
1220 * Map a message from 16- to 32-bit Unicode.
1221 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1223 INT WINPROC_MapMsg16To32W( HWND16 hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
1224 WPARAM *pwparam32, LPARAM *plparam )
1226 switch(msg16)
1228 case WM_GETTEXT:
1229 case WM_SETTEXT:
1230 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
1231 return WINPROC_MapMsg32ATo32W( hwnd, *pmsg32, *pwparam32, plparam );
1232 case WM_NCCREATE:
1233 case WM_CREATE:
1235 CREATESTRUCT16 *cs16 = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1236 CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( SystemHeap, 0,
1237 sizeof(*cs) + sizeof(LPARAM) );
1238 if (!cs) return -1;
1239 STRUCT32_CREATESTRUCT16to32A( cs16, (CREATESTRUCTA *)cs );
1240 cs->lpszName = (LPCWSTR)PTR_SEG_TO_LIN(cs16->lpszName);
1241 cs->lpszClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->lpszClass);
1242 if (HIWORD(cs->lpszName))
1243 cs->lpszName = HEAP_strdupAtoW( SystemHeap, 0,
1244 (LPCSTR)cs->lpszName );
1245 if (HIWORD(cs->lpszClass))
1246 cs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0,
1247 (LPCSTR)cs->lpszClass );
1248 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1249 *plparam = (LPARAM)cs;
1251 return 1;
1252 case WM_MDICREATE:
1254 MDICREATESTRUCT16 *cs16 =
1255 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1256 MDICREATESTRUCTW *cs =
1257 (MDICREATESTRUCTW *)HeapAlloc( SystemHeap, 0,
1258 sizeof(*cs) + sizeof(LPARAM) );
1259 if (!cs) return -1;
1260 STRUCT32_MDICREATESTRUCT16to32A( cs16, (MDICREATESTRUCTA *)cs );
1261 cs->szTitle = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szTitle);
1262 cs->szClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szClass);
1263 if (HIWORD(cs->szTitle))
1264 cs->szTitle = HEAP_strdupAtoW( SystemHeap, 0,
1265 (LPCSTR)cs->szTitle );
1266 if (HIWORD(cs->szClass))
1267 cs->szClass = HEAP_strdupAtoW( SystemHeap, 0,
1268 (LPCSTR)cs->szClass );
1269 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1270 *plparam = (LPARAM)cs;
1272 return 1;
1273 case WM_GETDLGCODE:
1274 if (*plparam)
1276 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(*plparam);
1277 LPMSG msg32 = (LPMSG)HeapAlloc( SystemHeap, 0, sizeof(MSG) );
1279 if (!msg32) return -1;
1280 msg32->hwnd = msg16->hwnd;
1281 msg32->lParam = msg16->lParam;
1282 msg32->time = msg16->time;
1283 CONV_POINT16TO32(&msg16->pt,&msg32->pt);
1284 /* this is right, right? */
1285 if (WINPROC_MapMsg16To32W(hwnd, msg16->message,msg16->wParam,
1286 &msg32->message,&msg32->wParam,
1287 &msg32->lParam)<0) {
1288 HeapFree( SystemHeap, 0, msg32 );
1289 return -1;
1291 *plparam = (LPARAM)msg32;
1292 return 1;
1294 else return 0;
1295 default: /* No Unicode translation needed */
1296 return WINPROC_MapMsg16To32A( msg16, wParam16, pmsg32,
1297 pwparam32, plparam );
1302 /**********************************************************************
1303 * WINPROC_UnmapMsg16To32W
1305 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1307 LRESULT WINPROC_UnmapMsg16To32W( HWND16 hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
1308 LRESULT result )
1310 switch(msg)
1312 case WM_GETTEXT:
1313 case WM_SETTEXT:
1314 WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
1315 break;
1316 case WM_NCCREATE:
1317 case WM_CREATE:
1319 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
1320 lParam = *(LPARAM *)(cs + 1);
1321 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA *)cs,
1322 (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1323 if (HIWORD(cs->lpszName))
1324 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
1325 if (HIWORD(cs->lpszClass))
1326 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
1327 HeapFree( SystemHeap, 0, cs );
1329 break;
1330 case WM_MDICREATE:
1332 MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
1333 lParam = *(LPARAM *)(cs + 1);
1334 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA *)cs,
1335 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1336 if (HIWORD(cs->szTitle))
1337 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
1338 if (HIWORD(cs->szClass))
1339 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
1340 HeapFree( SystemHeap, 0, cs );
1342 break;
1343 case WM_GETDLGCODE:
1344 if (lParam)
1346 LPMSG msg32 = (LPMSG)lParam;
1348 WINPROC_UnmapMsg16To32W( hwnd, msg32->message, msg32->wParam, msg32->lParam,
1349 result);
1350 HeapFree( SystemHeap, 0, msg32 );
1352 break;
1353 default:
1354 return WINPROC_UnmapMsg16To32A( hwnd, msg, wParam, lParam, result );
1356 return result;
1360 /**********************************************************************
1361 * WINPROC_MapMsg32ATo16
1363 * Map a message from 32-bit Ansi to 16-bit.
1364 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1366 INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32,
1367 UINT16 *pmsg16, WPARAM16 *pwparam16,
1368 LPARAM *plparam )
1370 *pmsg16 = (UINT16)msg32;
1371 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1372 switch(msg32)
1374 case BM_GETCHECK:
1375 case BM_SETCHECK:
1376 case BM_GETSTATE:
1377 case BM_SETSTATE:
1378 case BM_SETSTYLE:
1379 *pmsg16 = (UINT16)msg32 + (BM_GETCHECK16 - BM_GETCHECK);
1380 return 0;
1382 case EM_GETSEL:
1383 case EM_GETRECT:
1384 case EM_SETRECT:
1385 case EM_SETRECTNP:
1386 case EM_SCROLL:
1387 case EM_LINESCROLL:
1388 case EM_SCROLLCARET:
1389 case EM_GETMODIFY:
1390 case EM_SETMODIFY:
1391 case EM_GETLINECOUNT:
1392 case EM_LINEINDEX:
1393 case EM_SETHANDLE:
1394 case EM_GETHANDLE:
1395 case EM_GETTHUMB:
1396 case EM_LINELENGTH:
1397 case EM_REPLACESEL:
1398 case EM_GETLINE:
1399 case EM_LIMITTEXT:
1400 case EM_CANUNDO:
1401 case EM_UNDO:
1402 case EM_FMTLINES:
1403 case EM_LINEFROMCHAR:
1404 case EM_SETTABSTOPS:
1405 case EM_SETPASSWORDCHAR:
1406 case EM_EMPTYUNDOBUFFER:
1407 case EM_GETFIRSTVISIBLELINE:
1408 case EM_SETREADONLY:
1409 case EM_SETWORDBREAKPROC:
1410 case EM_GETWORDBREAKPROC:
1411 case EM_GETPASSWORDCHAR:
1412 *pmsg16 = (UINT16)msg32 + (EM_GETSEL16 - EM_GETSEL);
1413 return 0;
1415 case LB_CARETOFF:
1416 case LB_CARETON:
1417 case LB_DELETESTRING:
1418 case LB_GETANCHORINDEX:
1419 case LB_GETCARETINDEX:
1420 case LB_GETCOUNT:
1421 case LB_GETCURSEL:
1422 case LB_GETHORIZONTALEXTENT:
1423 case LB_GETITEMDATA:
1424 case LB_GETITEMHEIGHT:
1425 case LB_GETSEL:
1426 case LB_GETSELCOUNT:
1427 case LB_GETTEXTLEN:
1428 case LB_GETTOPINDEX:
1429 case LB_RESETCONTENT:
1430 case LB_SELITEMRANGE:
1431 case LB_SELITEMRANGEEX:
1432 case LB_SETANCHORINDEX:
1433 case LB_SETCARETINDEX:
1434 case LB_SETCOLUMNWIDTH:
1435 case LB_SETCURSEL:
1436 case LB_SETHORIZONTALEXTENT:
1437 case LB_SETITEMDATA:
1438 case LB_SETITEMHEIGHT:
1439 case LB_SETSEL:
1440 case LB_SETTOPINDEX:
1441 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
1442 return 0;
1443 case CB_DELETESTRING:
1444 case CB_GETCOUNT:
1445 case CB_GETLBTEXTLEN:
1446 case CB_LIMITTEXT:
1447 case CB_RESETCONTENT:
1448 case CB_SETEDITSEL:
1449 case CB_GETCURSEL:
1450 case CB_SETCURSEL:
1451 case CB_SHOWDROPDOWN:
1452 case CB_SETITEMDATA:
1453 case CB_SETITEMHEIGHT:
1454 case CB_GETITEMHEIGHT:
1455 case CB_SETEXTENDEDUI:
1456 case CB_GETEXTENDEDUI:
1457 case CB_GETDROPPEDSTATE:
1458 *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL);
1459 return 0;
1460 case CB_GETEDITSEL:
1461 *pmsg16 = CB_GETEDITSEL16;
1462 return 1;
1464 case LB_ADDSTRING:
1465 case LB_FINDSTRING:
1466 case LB_FINDSTRINGEXACT:
1467 case LB_INSERTSTRING:
1468 case LB_SELECTSTRING:
1469 case LB_DIR:
1470 case LB_ADDFILE:
1472 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1473 if (!str) return -1;
1474 *plparam = (LPARAM)SEGPTR_GET(str);
1476 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
1477 return 1;
1479 case CB_ADDSTRING:
1480 case CB_FINDSTRING:
1481 case CB_FINDSTRINGEXACT:
1482 case CB_INSERTSTRING:
1483 case CB_SELECTSTRING:
1484 case CB_DIR:
1486 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1487 if (!str) return -1;
1488 *plparam = (LPARAM)SEGPTR_GET(str);
1490 *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL);
1491 return 1;
1493 case LB_GETITEMRECT:
1495 RECT16 *rect;
1496 rect = (RECT16 *)SEGPTR_ALLOC( sizeof(RECT16) + sizeof(LPARAM) );
1497 if (!rect) return -1;
1498 *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */
1499 *plparam = (LPARAM)SEGPTR_GET(rect);
1501 *pmsg16 = LB_GETITEMRECT16;
1502 return 1;
1503 case LB_GETSELITEMS:
1505 LPINT16 items;
1506 *pwparam16 = (WPARAM16)MIN( wParam32, 0x7f80 ); /* Must be < 64K */
1507 if (!(items = SEGPTR_ALLOC( *pwparam16 * sizeof(INT16)
1508 + sizeof(LPARAM)))) return -1;
1509 *((LPARAM *)items)++ = *plparam; /* Store the previous lParam */
1510 *plparam = (LPARAM)SEGPTR_GET(items);
1512 *pmsg16 = LB_GETSELITEMS16;
1513 return 1;
1514 case LB_SETTABSTOPS:
1515 if (wParam32)
1517 INT i;
1518 LPINT16 stops;
1519 *pwparam16 = (WPARAM16)MIN( wParam32, 0x7f80 ); /* Must be < 64K */
1520 if (!(stops = SEGPTR_ALLOC( *pwparam16 * sizeof(INT16)
1521 + sizeof(LPARAM)))) return -1;
1522 for (i = 0; i < *pwparam16; i++) stops[i] = *((LPINT)*plparam+i);
1523 *plparam = (LPARAM)SEGPTR_GET(stops);
1524 return 1;
1526 *pmsg16 = LB_SETTABSTOPS16;
1527 return 0;
1529 case CB_GETDROPPEDCONTROLRECT:
1531 RECT16 *rect;
1532 rect = (RECT16 *)SEGPTR_ALLOC( sizeof(RECT16) + sizeof(LPARAM) );
1533 if (!rect) return -1;
1534 *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */
1535 *plparam = (LPARAM)SEGPTR_GET(rect);
1537 *pmsg16 = CB_GETDROPPEDCONTROLRECT16;
1538 return 1;
1540 case LB_GETTEXT:
1541 *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) );
1542 *pmsg16 = LB_GETTEXT16;
1543 return 1;
1545 case CB_GETLBTEXT:
1546 *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) );
1547 *pmsg16 = CB_GETLBTEXT16;
1548 return 1;
1550 case EM_SETSEL:
1551 *pwparam16 = 0;
1552 *plparam = MAKELONG( (INT16)(INT)wParam32, (INT16)*plparam );
1553 *pmsg16 = EM_SETSEL16;
1554 return 0;
1556 case WM_ACTIVATE:
1557 case WM_CHARTOITEM:
1558 case WM_COMMAND:
1559 case WM_VKEYTOITEM:
1560 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32) );
1561 return 0;
1562 case WM_HSCROLL:
1563 case WM_VSCROLL:
1564 *plparam = MAKELPARAM( HIWORD(wParam32), (HWND16)*plparam );
1565 return 0;
1566 case WM_CTLCOLORMSGBOX:
1567 case WM_CTLCOLOREDIT:
1568 case WM_CTLCOLORLISTBOX:
1569 case WM_CTLCOLORBTN:
1570 case WM_CTLCOLORDLG:
1571 case WM_CTLCOLORSCROLLBAR:
1572 case WM_CTLCOLORSTATIC:
1573 *pmsg16 = WM_CTLCOLOR;
1574 *plparam = MAKELPARAM( (HWND16)*plparam,
1575 (WORD)msg32 - WM_CTLCOLORMSGBOX );
1576 return 0;
1577 case WM_COMPAREITEM:
1579 COMPAREITEMSTRUCT *cis32 = (COMPAREITEMSTRUCT *)*plparam;
1580 COMPAREITEMSTRUCT16 *cis = SEGPTR_NEW(COMPAREITEMSTRUCT16);
1581 if (!cis) return -1;
1582 cis->CtlType = (UINT16)cis32->CtlType;
1583 cis->CtlID = (UINT16)cis32->CtlID;
1584 cis->hwndItem = (HWND16)cis32->hwndItem;
1585 cis->itemID1 = (UINT16)cis32->itemID1;
1586 cis->itemData1 = cis32->itemData1;
1587 cis->itemID2 = (UINT16)cis32->itemID2;
1588 cis->itemData2 = cis32->itemData2;
1589 *plparam = (LPARAM)SEGPTR_GET(cis);
1591 return 1;
1592 case WM_DELETEITEM:
1594 DELETEITEMSTRUCT *dis32 = (DELETEITEMSTRUCT *)*plparam;
1595 DELETEITEMSTRUCT16 *dis = SEGPTR_NEW(DELETEITEMSTRUCT16);
1596 if (!dis) return -1;
1597 dis->CtlType = (UINT16)dis32->CtlType;
1598 dis->CtlID = (UINT16)dis32->CtlID;
1599 dis->itemID = (UINT16)dis32->itemID;
1600 dis->hwndItem = (HWND16)dis32->hwndItem;
1601 dis->itemData = dis32->itemData;
1602 *plparam = (LPARAM)SEGPTR_GET(dis);
1604 return 1;
1605 case WM_DRAWITEM:
1607 DRAWITEMSTRUCT *dis32 = (DRAWITEMSTRUCT *)*plparam;
1608 DRAWITEMSTRUCT16 *dis = SEGPTR_NEW(DRAWITEMSTRUCT16);
1609 if (!dis) return -1;
1610 dis->CtlType = (UINT16)dis32->CtlType;
1611 dis->CtlID = (UINT16)dis32->CtlID;
1612 dis->itemID = (UINT16)dis32->itemID;
1613 dis->itemAction = (UINT16)dis32->itemAction;
1614 dis->itemState = (UINT16)dis32->itemState;
1615 dis->hwndItem = (HWND16)dis32->hwndItem;
1616 dis->hDC = (HDC16)dis32->hDC;
1617 dis->itemData = dis32->itemData;
1618 CONV_RECT32TO16( &dis32->rcItem, &dis->rcItem );
1619 *plparam = (LPARAM)SEGPTR_GET(dis);
1621 return 1;
1622 case WM_MEASUREITEM:
1624 MEASUREITEMSTRUCT *mis32 = (MEASUREITEMSTRUCT *)*plparam;
1625 MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)
1626 SEGPTR_ALLOC(sizeof(*mis)+sizeof(LPARAM));
1627 if (!mis) return -1;
1628 mis->CtlType = (UINT16)mis32->CtlType;
1629 mis->CtlID = (UINT16)mis32->CtlID;
1630 mis->itemID = (UINT16)mis32->itemID;
1631 mis->itemWidth = (UINT16)mis32->itemWidth;
1632 mis->itemHeight = (UINT16)mis32->itemHeight;
1633 mis->itemData = mis32->itemData;
1634 *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */
1635 *plparam = (LPARAM)SEGPTR_GET(mis);
1637 return 1;
1638 case WM_GETMINMAXINFO:
1640 MINMAXINFO16 *mmi = (MINMAXINFO16 *)SEGPTR_ALLOC( sizeof(*mmi) +
1641 sizeof(LPARAM) );
1642 if (!mmi) return -1;
1643 STRUCT32_MINMAXINFO32to16( (MINMAXINFO *)*plparam, mmi );
1644 *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */
1645 *plparam = (LPARAM)SEGPTR_GET(mmi);
1647 return 1;
1648 case WM_GETTEXT:
1650 LPSTR str;
1651 *pwparam16 = (WPARAM16)MIN( wParam32, 0xff80 ); /* Must be < 64K */
1652 if (!(str = SEGPTR_ALLOC(*pwparam16 + sizeof(LPARAM)))) return -1;
1653 *((LPARAM *)str)++ = *plparam; /* Store the previous lParam */
1654 *plparam = (LPARAM)SEGPTR_GET(str);
1656 return 1;
1657 case WM_MDICREATE:
1659 MDICREATESTRUCT16 *cs;
1660 MDICREATESTRUCTA *cs32 = (MDICREATESTRUCTA *)*plparam;
1661 LPSTR name, cls;
1663 if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1;
1664 STRUCT32_MDICREATESTRUCT32Ato16( cs32, cs );
1665 name = SEGPTR_STRDUP( cs32->szTitle );
1666 cls = SEGPTR_STRDUP( cs32->szClass );
1667 cs->szTitle = SEGPTR_GET(name);
1668 cs->szClass = SEGPTR_GET(cls);
1669 *plparam = (LPARAM)SEGPTR_GET(cs);
1671 return 1;
1672 case WM_MDIGETACTIVE:
1673 return 1;
1674 case WM_MDISETMENU:
1675 *plparam = MAKELPARAM( (HMENU16)LOWORD(wParam32),
1676 (HMENU16)LOWORD(*plparam) );
1677 *pwparam16 = (*plparam == 0);
1678 return 0;
1679 case WM_MENUCHAR:
1680 case WM_MENUSELECT:
1681 *plparam = MAKELPARAM( HIWORD(wParam32), (HMENU16)*plparam );
1682 return 0;
1683 case WM_MDIACTIVATE:
1684 if( WIDGETS_IsControl(WIN_FindWndPtr(hwnd), BIC32_MDICLIENT) )
1686 *pwparam16 = (HWND)wParam32;
1687 *plparam = 0;
1689 else
1691 *pwparam16 = ((HWND)*plparam == hwnd);
1692 *plparam = MAKELPARAM( (HWND16)LOWORD(*plparam),
1693 (HWND16)LOWORD(wParam32) );
1695 return 0;
1696 case WM_NCCALCSIZE:
1698 NCCALCSIZE_PARAMS *nc32 = (NCCALCSIZE_PARAMS *)*plparam;
1699 NCCALCSIZE_PARAMS16 *nc = (NCCALCSIZE_PARAMS16 *)SEGPTR_ALLOC( sizeof(*nc) + sizeof(LPARAM) );
1700 if (!nc) return -1;
1702 CONV_RECT32TO16( &nc32->rgrc[0], &nc->rgrc[0] );
1703 if (wParam32)
1705 WINDOWPOS16 *wp;
1706 CONV_RECT32TO16( &nc32->rgrc[1], &nc->rgrc[1] );
1707 CONV_RECT32TO16( &nc32->rgrc[2], &nc->rgrc[2] );
1708 if (!(wp = SEGPTR_NEW(WINDOWPOS16)))
1710 SEGPTR_FREE(nc);
1711 return -1;
1713 STRUCT32_WINDOWPOS32to16( nc32->lppos, wp );
1714 nc->lppos = SEGPTR_GET(wp);
1716 *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */
1717 *plparam = (LPARAM)SEGPTR_GET(nc);
1719 return 1;
1720 case WM_NCCREATE:
1721 case WM_CREATE:
1723 CREATESTRUCT16 *cs;
1724 CREATESTRUCTA *cs32 = (CREATESTRUCTA *)*plparam;
1725 LPSTR name, cls;
1727 if (!(cs = SEGPTR_NEW(CREATESTRUCT16))) return -1;
1728 STRUCT32_CREATESTRUCT32Ato16( cs32, cs );
1729 name = SEGPTR_STRDUP( cs32->lpszName );
1730 cls = SEGPTR_STRDUP( cs32->lpszClass );
1731 cs->lpszName = SEGPTR_GET(name);
1732 cs->lpszClass = SEGPTR_GET(cls);
1733 *plparam = (LPARAM)SEGPTR_GET(cs);
1735 return 1;
1736 case WM_PARENTNOTIFY:
1737 if ((LOWORD(wParam32)==WM_CREATE) || (LOWORD(wParam32)==WM_DESTROY))
1738 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32));
1739 /* else nothing to do */
1740 return 0;
1741 case WM_NOTIFY:
1742 *plparam = MapLS( (NMHDR *)*plparam ); /* NMHDR is already 32-bit */
1743 return 1;
1744 case WM_SETTEXT:
1746 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1747 if (!str) return -1;
1748 *plparam = (LPARAM)SEGPTR_GET(str);
1750 return 1;
1751 case WM_WINDOWPOSCHANGING:
1752 case WM_WINDOWPOSCHANGED:
1754 WINDOWPOS16 *wp = (WINDOWPOS16 *)SEGPTR_ALLOC( sizeof(*wp) +
1755 sizeof(LPARAM) );
1756 if (!wp) return -1;
1757 STRUCT32_WINDOWPOS32to16( (WINDOWPOS *)*plparam, wp );
1758 *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */
1759 *plparam = (LPARAM)SEGPTR_GET(wp);
1761 return 1;
1762 case WM_GETDLGCODE:
1763 if (*plparam) {
1764 LPMSG msg32 = (LPMSG) *plparam;
1765 LPMSG16 msg16 = (LPMSG16) SEGPTR_NEW( MSG16 );
1767 if (!msg16) return -1;
1768 msg16->hwnd = msg32->hwnd;
1769 msg16->lParam = msg32->lParam;
1770 msg16->time = msg32->time;
1771 CONV_POINT32TO16(&msg32->pt,&msg16->pt);
1772 /* this is right, right? */
1773 if (WINPROC_MapMsg32ATo16(msg32->hwnd,msg32->message,msg32->wParam,
1774 &msg16->message,&msg16->wParam, &msg16->lParam)<0) {
1775 SEGPTR_FREE( msg16 );
1776 return -1;
1778 *plparam = (LPARAM)SEGPTR_GET(msg16);
1779 return 1;
1781 return 0;
1783 case WM_ACTIVATEAPP:
1784 if (*plparam) {
1785 *plparam = (LPARAM)THREAD_IdToTHDB((DWORD) *plparam)->teb.htask16;
1787 return 1;
1788 case WM_ASKCBFORMATNAME:
1789 case WM_DEVMODECHANGE:
1790 case WM_PAINTCLIPBOARD:
1791 case WM_SIZECLIPBOARD:
1792 case WM_WININICHANGE:
1793 FIXME( msg, "message %04x needs translation\n", msg32 );
1794 return -1;
1795 default: /* No translation needed */
1796 return 0;
1801 /**********************************************************************
1802 * WINPROC_UnmapMsg32ATo16
1804 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
1806 void WINPROC_UnmapMsg32ATo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
1807 MSGPARAM16* p16 )
1809 switch(msg)
1811 case LB_ADDFILE:
1812 case LB_ADDSTRING:
1813 case LB_DIR:
1814 case LB_FINDSTRING:
1815 case LB_FINDSTRINGEXACT:
1816 case LB_INSERTSTRING:
1817 case LB_SELECTSTRING:
1818 case LB_SETTABSTOPS:
1819 case CB_ADDSTRING:
1820 case CB_FINDSTRING:
1821 case CB_FINDSTRINGEXACT:
1822 case CB_INSERTSTRING:
1823 case CB_SELECTSTRING:
1824 case CB_DIR:
1825 case WM_COMPAREITEM:
1826 case WM_DELETEITEM:
1827 case WM_DRAWITEM:
1828 case WM_SETTEXT:
1829 SEGPTR_FREE( PTR_SEG_TO_LIN(p16->lParam) );
1830 break;
1832 case CB_GETDROPPEDCONTROLRECT:
1833 case LB_GETITEMRECT:
1835 RECT16 *rect = (RECT16 *)PTR_SEG_TO_LIN(p16->lParam);
1836 p16->lParam = *(LPARAM *)(rect + 1);
1837 CONV_RECT16TO32( rect, (RECT *)(p16->lParam));
1838 SEGPTR_FREE( rect );
1840 break;
1841 case LB_GETSELITEMS:
1843 INT i;
1844 LPINT16 items = (LPINT16)PTR_SEG_TO_LIN(lParam);
1845 p16->lParam = *((LPARAM *)items - 1);
1846 for (i = 0; i < p16->wParam; i++) *((LPINT)(p16->lParam) + i) = items[i];
1847 SEGPTR_FREE( (LPARAM *)items - 1 );
1849 break;
1851 case CB_GETEDITSEL:
1852 if( wParam )
1853 *((LPUINT)(wParam)) = LOWORD(p16->lResult);
1854 if( lParam )
1855 *((LPUINT)(lParam)) = HIWORD(p16->lResult); /* FIXME: substract 1? */
1856 break;
1858 case LB_GETTEXT:
1859 case CB_GETLBTEXT:
1860 UnMapLS( (SEGPTR)(p16->lParam) );
1861 break;
1863 case WM_MEASUREITEM:
1865 MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(p16->lParam);
1866 MEASUREITEMSTRUCT *mis32 = *(MEASUREITEMSTRUCT **)(mis + 1);
1867 mis32->itemWidth = mis->itemWidth;
1868 mis32->itemHeight = mis->itemHeight;
1869 SEGPTR_FREE(mis);
1871 break;
1872 case WM_GETMINMAXINFO:
1874 MINMAXINFO16 *mmi = (MINMAXINFO16 *)PTR_SEG_TO_LIN(p16->lParam);
1875 p16->lParam = *(LPARAM *)(mmi + 1);
1876 STRUCT32_MINMAXINFO16to32( mmi, (MINMAXINFO *)(p16->lParam) );
1877 SEGPTR_FREE(mmi);
1879 break;
1880 case WM_GETTEXT:
1882 LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam);
1883 p16->lParam = *((LPARAM *)str - 1);
1884 lstrcpynA( (LPSTR)(p16->lParam), str, p16->wParam );
1885 SEGPTR_FREE( (LPARAM *)str - 1 );
1887 break;
1888 case WM_MDICREATE:
1890 MDICREATESTRUCT16 *cs = (MDICREATESTRUCT16*)PTR_SEG_TO_LIN(p16->lParam);
1891 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szTitle) );
1892 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szClass) );
1893 SEGPTR_FREE( cs );
1895 break;
1896 case WM_MDIGETACTIVE:
1897 if (lParam) *(BOOL *)lParam = (BOOL16)HIWORD(p16->lResult);
1898 p16->lResult = (HWND)LOWORD(p16->lResult);
1899 break;
1900 case WM_NCCALCSIZE:
1902 NCCALCSIZE_PARAMS *nc32;
1903 NCCALCSIZE_PARAMS16 *nc = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(p16->lParam);
1904 p16->lParam = *(LPARAM *)(nc + 1);
1905 nc32 = (NCCALCSIZE_PARAMS *)(p16->lParam);
1906 CONV_RECT16TO32( &nc->rgrc[0], &nc32->rgrc[0] );
1907 if (p16->wParam)
1909 CONV_RECT16TO32( &nc->rgrc[1], &nc32->rgrc[1] );
1910 CONV_RECT16TO32( &nc->rgrc[2], &nc32->rgrc[2] );
1911 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc->lppos),
1912 nc32->lppos );
1913 SEGPTR_FREE( PTR_SEG_TO_LIN(nc->lppos) );
1915 SEGPTR_FREE(nc);
1917 break;
1918 case WM_NCCREATE:
1919 case WM_CREATE:
1921 CREATESTRUCT16 *cs = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(p16->lParam);
1922 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->lpszName) );
1923 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->lpszClass) );
1924 SEGPTR_FREE( cs );
1926 break;
1927 case WM_WINDOWPOSCHANGING:
1928 case WM_WINDOWPOSCHANGED:
1930 WINDOWPOS16 *wp = (WINDOWPOS16 *)PTR_SEG_TO_LIN(p16->lParam);
1931 p16->lParam = *(LPARAM *)(wp + 1);
1932 STRUCT32_WINDOWPOS16to32( wp, (WINDOWPOS *)p16->lParam );
1933 SEGPTR_FREE(wp);
1935 break;
1936 case WM_NOTIFY:
1937 UnMapLS(p16->lParam);
1938 break;
1939 case WM_GETDLGCODE:
1940 if (p16->lParam)
1942 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(p16->lParam);
1943 MSGPARAM16 msgp16;
1944 msgp16.wParam=msg16->wParam;
1945 msgp16.lParam=msg16->lParam;
1946 WINPROC_UnmapMsg32ATo16(((LPMSG)lParam)->hwnd, ((LPMSG)lParam)->message,
1947 ((LPMSG)lParam)->wParam, ((LPMSG)lParam)->lParam,
1948 &msgp16 );
1949 SEGPTR_FREE(msg16);
1951 break;
1956 /**********************************************************************
1957 * WINPROC_MapMsg32WTo16
1959 * Map a message from 32-bit Unicode to 16-bit.
1960 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1962 INT WINPROC_MapMsg32WTo16( HWND hwnd, UINT msg32, WPARAM wParam32,
1963 UINT16 *pmsg16, WPARAM16 *pwparam16,
1964 LPARAM *plparam )
1966 switch(msg32)
1968 case LB_ADDSTRING:
1969 case LB_FINDSTRING:
1970 case LB_FINDSTRINGEXACT:
1971 case LB_INSERTSTRING:
1972 case LB_SELECTSTRING:
1973 case LB_DIR:
1974 case LB_ADDFILE:
1976 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
1977 if (!str) return -1;
1978 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1979 *plparam = (LPARAM)SEGPTR_GET(str);
1981 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
1982 return 1;
1984 case CB_ADDSTRING:
1985 case CB_FINDSTRING:
1986 case CB_FINDSTRINGEXACT:
1987 case CB_INSERTSTRING:
1988 case CB_SELECTSTRING:
1989 case CB_DIR:
1991 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
1992 if (!str) return -1;
1993 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1994 *plparam = (LPARAM)SEGPTR_GET(str);
1996 *pmsg16 = (UINT16)msg32 + (CB_ADDSTRING16 - CB_ADDSTRING);
1997 return 1;
1999 case WM_NCCREATE:
2000 case WM_CREATE:
2002 CREATESTRUCT16 *cs;
2003 CREATESTRUCTW *cs32 = (CREATESTRUCTW *)*plparam;
2004 LPSTR name, cls;
2006 if (!(cs = SEGPTR_NEW(CREATESTRUCT16))) return -1;
2007 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA *)cs32, cs );
2008 name = SEGPTR_STRDUP_WtoA( cs32->lpszName );
2009 cls = SEGPTR_STRDUP_WtoA( cs32->lpszClass );
2010 cs->lpszName = SEGPTR_GET(name);
2011 cs->lpszClass = SEGPTR_GET(cls);
2012 *pmsg16 = (UINT16)msg32;
2013 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2014 *plparam = (LPARAM)SEGPTR_GET(cs);
2016 return 1;
2017 case WM_MDICREATE:
2019 MDICREATESTRUCT16 *cs;
2020 MDICREATESTRUCTW *cs32 = (MDICREATESTRUCTW *)*plparam;
2021 LPSTR name, cls;
2023 if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1;
2024 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA *)cs32, cs );
2025 name = SEGPTR_STRDUP_WtoA( cs32->szTitle );
2026 cls = SEGPTR_STRDUP_WtoA( cs32->szClass );
2027 cs->szTitle = SEGPTR_GET(name);
2028 cs->szClass = SEGPTR_GET(cls);
2029 *pmsg16 = (UINT16)msg32;
2030 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2031 *plparam = (LPARAM)SEGPTR_GET(cs);
2033 return 1;
2034 case WM_SETTEXT:
2036 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
2037 if (!str) return -1;
2038 *pmsg16 = (UINT16)msg32;
2039 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2040 *plparam = (LPARAM)SEGPTR_GET(str);
2042 return 1;
2043 default: /* No Unicode translation needed */
2044 return WINPROC_MapMsg32ATo16( hwnd, msg32, wParam32, pmsg16,
2045 pwparam16, plparam );
2050 /**********************************************************************
2051 * WINPROC_UnmapMsg32WTo16
2053 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2055 void WINPROC_UnmapMsg32WTo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
2056 MSGPARAM16* p16 )
2058 switch(msg)
2060 case WM_GETTEXT:
2062 LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam);
2063 p16->lParam = *((LPARAM *)str - 1);
2064 lstrcpyAtoW( (LPWSTR)(p16->lParam), str );
2065 SEGPTR_FREE( (LPARAM *)str - 1 );
2067 break;
2068 default:
2069 WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, p16 );
2070 break;
2075 /**********************************************************************
2076 * WINPROC_CallProc32ATo32W
2078 * Call a window procedure, translating args from Ansi to Unicode.
2080 static LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd,
2081 UINT msg, WPARAM wParam,
2082 LPARAM lParam )
2084 LRESULT result;
2086 if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0;
2087 result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2088 WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
2089 return result;
2093 /**********************************************************************
2094 * WINPROC_CallProc32WTo32A
2096 * Call a window procedure, translating args from Unicode to Ansi.
2098 static LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd,
2099 UINT msg, WPARAM wParam,
2100 LPARAM lParam )
2102 LRESULT result;
2104 if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0;
2105 result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2106 WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
2107 return result;
2111 /**********************************************************************
2112 * WINPROC_CallProc16To32A
2114 * Call a 32-bit window procedure, translating the 16-bit args.
2116 LRESULT WINPROC_CallProc16To32A( HWND16 hwnd, UINT16 msg,
2117 WPARAM16 wParam, LPARAM lParam,
2118 WNDPROC func )
2120 LRESULT result;
2121 UINT msg32;
2122 WPARAM wParam32;
2124 if (WINPROC_MapMsg16To32A( msg, wParam, &msg32, &wParam32, &lParam ) == -1)
2125 return 0;
2126 result = WINPROC_CallWndProc( func, hwnd, msg32, wParam32, lParam );
2127 return WINPROC_UnmapMsg16To32A( hwnd, msg32, wParam32, lParam, result );
2131 /**********************************************************************
2132 * WINPROC_CallProc16To32W
2134 * Call a 32-bit window procedure, translating the 16-bit args.
2136 LRESULT WINPROC_CallProc16To32W( HWND16 hwnd, UINT16 msg,
2137 WPARAM16 wParam, LPARAM lParam,
2138 WNDPROC func )
2140 LRESULT result;
2141 UINT msg32;
2142 WPARAM wParam32;
2144 if (WINPROC_MapMsg16To32W( hwnd, msg, wParam, &msg32, &wParam32, &lParam ) == -1)
2145 return 0;
2146 result = WINPROC_CallWndProc( func, hwnd, msg32, wParam32, lParam );
2147 return WINPROC_UnmapMsg16To32W( hwnd, msg32, wParam32, lParam, result );
2151 /**********************************************************************
2152 * WINPROC_CallProc32ATo16
2154 * Call a 16-bit window procedure, translating the 32-bit args.
2156 static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND hwnd,
2157 UINT msg, WPARAM wParam,
2158 LPARAM lParam )
2160 UINT16 msg16;
2161 MSGPARAM16 mp16;
2163 mp16.lParam = lParam;
2164 if (WINPROC_MapMsg32ATo16( hwnd, msg, wParam,
2165 &msg16, &mp16.wParam, &mp16.lParam ) == -1)
2166 return 0;
2167 mp16.lResult = Callbacks->CallWndProc( func, hwnd, msg16,
2168 mp16.wParam, mp16.lParam );
2169 WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, &mp16 );
2170 return mp16.lResult;
2174 /**********************************************************************
2175 * WINPROC_CallProc32WTo16
2177 * Call a 16-bit window procedure, translating the 32-bit args.
2179 static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND hwnd,
2180 UINT msg, WPARAM wParam,
2181 LPARAM lParam )
2183 UINT16 msg16;
2184 MSGPARAM16 mp16;
2186 mp16.lParam = lParam;
2187 if (WINPROC_MapMsg32WTo16( hwnd, msg, wParam, &msg16, &mp16.wParam,
2188 &mp16.lParam ) == -1)
2189 return 0;
2190 mp16.lResult = Callbacks->CallWndProc( func, hwnd, msg16,
2191 mp16.wParam, mp16.lParam );
2192 WINPROC_UnmapMsg32WTo16( hwnd, msg, wParam, lParam, &mp16 );
2193 return mp16.lResult;
2197 /**********************************************************************
2198 * CallWindowProc16 (USER.122)
2200 LRESULT WINAPI CallWindowProc16( WNDPROC16 func, HWND16 hwnd, UINT16 msg,
2201 WPARAM16 wParam, LPARAM lParam )
2203 WINDOWPROC *proc = WINPROC_GetPtr( func );
2205 if (!proc)
2206 return Callbacks->CallWndProc( func, hwnd, msg, wParam, lParam );
2208 #if testing
2209 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_16 );
2210 return Callbacks->CallWndProc( func, hwnd, msg, wParam, lParam );
2211 #endif
2213 switch(proc->type)
2215 case WIN_PROC_16:
2216 if (!proc->thunk.t_from32.proc) return 0;
2217 return Callbacks->CallWndProc( proc->thunk.t_from32.proc,
2218 hwnd, msg, wParam, lParam );
2219 case WIN_PROC_32A:
2220 if (!proc->thunk.t_from16.proc) return 0;
2221 return WINPROC_CallProc16To32A( hwnd, msg, wParam, lParam,
2222 proc->thunk.t_from16.proc );
2223 case WIN_PROC_32W:
2224 if (!proc->thunk.t_from16.proc) return 0;
2225 return WINPROC_CallProc16To32W( hwnd, msg, wParam, lParam,
2226 proc->thunk.t_from16.proc );
2227 default:
2228 WARN( relay, "Invalid proc %p\n", proc );
2229 return 0;
2234 /**********************************************************************
2235 * CallWindowProc32A (USER32.18)
2237 * The CallWindowProc() function invokes the windows procedure _func_,
2238 * with _hwnd_ as the target window, the message specified by _msg_, and
2239 * the message parameters _wParam_ and _lParam_.
2241 * Some kinds of argument conversion may be done, I'm not sure what.
2243 * CallWindowProc() may be used for windows subclassing. Use
2244 * SetWindowLong() to set a new windows procedure for windows of the
2245 * subclass, and handle subclassed messages in the new windows
2246 * procedure. The new windows procedure may then use CallWindowProc()
2247 * with _func_ set to the parent class's windows procedure to dispatch
2248 * the message to the superclass.
2250 * RETURNS
2252 * The return value is message dependent.
2254 * CONFORMANCE
2256 * ECMA-234, Win32
2258 LRESULT WINAPI CallWindowProcA(
2259 WNDPROC func, /* window procedure */
2260 HWND hwnd, /* target window */
2261 UINT msg, /* message */
2262 WPARAM wParam, /* message dependent parameter */
2263 LPARAM lParam /* message dependent parameter */
2265 WINDOWPROC *proc = WINPROC_GetPtr( (WNDPROC16)func );
2267 if (!proc) return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2269 #if testing
2270 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_32A );
2271 return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2272 #endif
2274 switch(proc->type)
2276 case WIN_PROC_16:
2277 if (!proc->thunk.t_from32.proc) return 0;
2278 return WINPROC_CallProc32ATo16( proc->thunk.t_from32.proc,
2279 hwnd, msg, wParam, lParam );
2280 case WIN_PROC_32A:
2281 if (!proc->thunk.t_from16.proc) return 0;
2282 return WINPROC_CallWndProc( proc->thunk.t_from16.proc,
2283 hwnd, msg, wParam, lParam );
2284 case WIN_PROC_32W:
2285 if (!proc->thunk.t_from16.proc) return 0;
2286 return WINPROC_CallProc32ATo32W( proc->thunk.t_from16.proc,
2287 hwnd, msg, wParam, lParam );
2288 default:
2289 WARN( relay, "Invalid proc %p\n", proc );
2290 return 0;
2295 /**********************************************************************
2296 * CallWindowProc32W (USER32.19)
2298 LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg,
2299 WPARAM wParam, LPARAM lParam )
2301 WINDOWPROC *proc = WINPROC_GetPtr( (WNDPROC16)func );
2303 if (!proc) return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2305 #if testing
2306 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_32W );
2307 return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2308 #endif
2310 switch(proc->type)
2312 case WIN_PROC_16:
2313 if (!proc->thunk.t_from32.proc) return 0;
2314 return WINPROC_CallProc32WTo16( proc->thunk.t_from32.proc,
2315 hwnd, msg, wParam, lParam );
2316 case WIN_PROC_32A:
2317 if (!proc->thunk.t_from16.proc) return 0;
2318 return WINPROC_CallProc32WTo32A( proc->thunk.t_from16.proc,
2319 hwnd, msg, wParam, lParam );
2320 case WIN_PROC_32W:
2321 if (!proc->thunk.t_from16.proc) return 0;
2322 return WINPROC_CallWndProc( proc->thunk.t_from16.proc,
2323 hwnd, msg, wParam, lParam );
2324 default:
2325 WARN( relay, "Invalid proc %p\n", proc );
2326 return 0;