Handle suspend/resume_thread requests in phase STARTING correctly.
[wine/hacks.git] / windows / winproc.c
blob2541d22ffe4b4170b8c937f488673dd52caee320
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 )
395 BOOL retvalue;
396 WND * wnd = WIN_FindWndPtr(hwnd);
397 retvalue = ( !(LOWORD(wnd->dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
398 (LOWORD(wnd->dwStyle) & CBS_HASSTRINGS) );
399 WIN_ReleaseWndPtr(wnd);
400 return retvalue;
402 /**********************************************************************
403 * WINPROC_TestLBForStr
405 * Return TRUE if the lparam is a string
407 BOOL WINPROC_TestLBForStr ( HWND hwnd )
409 BOOL retvalue;
410 WND * wnd = WIN_FindWndPtr(hwnd);
411 retvalue = ( !(LOWORD(wnd->dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
412 (LOWORD(wnd->dwStyle) & LBS_HASSTRINGS) );
413 WIN_ReleaseWndPtr(wnd);
414 return retvalue;
417 /**********************************************************************
418 * WINPROC_MapMsg32ATo32W
420 * Map a message from Ansi to Unicode.
421 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
423 * FIXME:
424 * WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR
426 * FIXME:
427 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
428 * the first four bytes are the handle of the icon
429 * when the WM_SETTEXT message has been used to set the icon
431 INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam )
433 switch(msg)
435 case WM_GETTEXT:
437 LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0,
438 wParam * sizeof(WCHAR) + sizeof(LPARAM) );
439 if (!ptr) return -1;
440 *ptr++ = *plparam; /* Store previous lParam */
441 *plparam = (LPARAM)ptr;
443 return 1;
444 /* lparam is string (0-terminated) */
445 case WM_SETTEXT:
446 case WM_WININICHANGE:
447 case CB_DIR:
448 case CB_FINDSTRING:
449 case CB_FINDSTRINGEXACT:
450 case CB_SELECTSTRING:
451 case LB_DIR:
452 case LB_ADDFILE:
453 case LB_FINDSTRING:
454 case LB_SELECTSTRING:
455 case EM_REPLACESEL:
456 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
457 return (*plparam ? 1 : -1);
459 case WM_NCCREATE:
460 case WM_CREATE:
462 CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( SystemHeap, 0,
463 sizeof(*cs) );
464 if (!cs) return -1;
465 *cs = *(CREATESTRUCTW *)*plparam;
466 if (HIWORD(cs->lpszName))
467 cs->lpszName = HEAP_strdupAtoW( SystemHeap, 0,
468 (LPCSTR)cs->lpszName );
469 if (HIWORD(cs->lpszClass))
470 cs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0,
471 (LPCSTR)cs->lpszClass );
472 *plparam = (LPARAM)cs;
474 return 1;
475 case WM_MDICREATE:
477 MDICREATESTRUCTW *cs =
478 (MDICREATESTRUCTW *)HeapAlloc( SystemHeap, 0, sizeof(*cs) );
479 if (!cs) return -1;
480 *cs = *(MDICREATESTRUCTW *)*plparam;
481 if (HIWORD(cs->szClass))
482 cs->szClass = HEAP_strdupAtoW( SystemHeap, 0,
483 (LPCSTR)cs->szClass );
484 if (HIWORD(cs->szTitle))
485 cs->szTitle = HEAP_strdupAtoW( SystemHeap, 0,
486 (LPCSTR)cs->szTitle );
487 *plparam = (LPARAM)cs;
489 return 1;
491 /* Listbox */
492 case LB_ADDSTRING:
493 case LB_INSERTSTRING:
494 if ( WINPROC_TestLBForStr( hwnd ))
495 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
496 return (*plparam ? 1 : -1);
498 case LB_GETTEXT: /* fixme: fixed sized buffer */
499 { if ( WINPROC_TestLBForStr( hwnd ))
500 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
501 if (!ptr) return -1;
502 *ptr++ = *plparam; /* Store previous lParam */
503 *plparam = (LPARAM)ptr;
506 return 1;
508 /* Combobox */
509 case CB_ADDSTRING:
510 case CB_INSERTSTRING:
511 if ( WINPROC_TestCBForStr( hwnd ))
512 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
513 return (*plparam ? 1 : -1);
515 case CB_GETLBTEXT: /* fixme: fixed sized buffer */
516 { if ( WINPROC_TestCBForStr( hwnd ))
517 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
518 if (!ptr) return -1;
519 *ptr++ = *plparam; /* Store previous lParam */
520 *plparam = (LPARAM)ptr;
523 return 1;
525 /* Multiline edit */
526 case EM_GETLINE:
527 { WORD len = (WORD)*plparam;
528 LPARAM *ptr = (LPARAM *) HEAP_xalloc( SystemHeap, 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
529 if (!ptr) return -1;
530 *ptr++ = *plparam; /* Store previous lParam */
531 (WORD)*ptr = len; /* Store the lenght */
532 *plparam = (LPARAM)ptr;
534 return 1;
536 case WM_ASKCBFORMATNAME:
537 case WM_DEVMODECHANGE:
538 case WM_PAINTCLIPBOARD:
539 case WM_SIZECLIPBOARD:
540 case EM_SETPASSWORDCHAR:
541 FIXME(msg, "message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg );
542 return -1;
543 default: /* No translation needed */
544 return 0;
549 /**********************************************************************
550 * WINPROC_UnmapMsg32ATo32W
552 * Unmap a message that was mapped from Ansi to Unicode.
554 void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
556 switch(msg)
558 case WM_GETTEXT:
560 LPARAM *ptr = (LPARAM *)lParam - 1;
561 lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam );
562 HeapFree( SystemHeap, 0, ptr );
564 break;
566 case WM_NCCREATE:
567 case WM_CREATE:
569 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
570 if (HIWORD(cs->lpszName))
571 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
572 if (HIWORD(cs->lpszClass))
573 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
574 HeapFree( SystemHeap, 0, cs );
576 break;
578 case WM_MDICREATE:
580 MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
581 if (HIWORD(cs->szTitle))
582 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
583 if (HIWORD(cs->szClass))
584 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
585 HeapFree( SystemHeap, 0, cs );
587 break;
589 case WM_SETTEXT:
590 case WM_WININICHANGE:
591 case CB_DIR:
592 case CB_FINDSTRING:
593 case CB_FINDSTRINGEXACT:
594 case CB_SELECTSTRING:
595 case LB_DIR:
596 case LB_ADDFILE:
597 case LB_FINDSTRING:
598 case LB_SELECTSTRING:
599 case EM_REPLACESEL:
600 HeapFree( SystemHeap, 0, (void *)lParam );
601 break;
603 /* Listbox */
604 case LB_ADDSTRING:
605 case LB_INSERTSTRING:
606 if ( WINPROC_TestLBForStr( hwnd ))
607 HeapFree( SystemHeap, 0, (void *)lParam );
608 break;
610 case LB_GETTEXT:
611 { if ( WINPROC_TestLBForStr( hwnd ))
612 { LPARAM *ptr = (LPARAM *)lParam - 1;
613 lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
614 HeapFree( SystemHeap, 0, ptr );
617 break;
619 /* Combobox */
620 case CB_ADDSTRING:
621 case CB_INSERTSTRING:
622 if ( WINPROC_TestCBForStr( hwnd ))
623 HeapFree( SystemHeap, 0, (void *)lParam );
624 break;
626 case CB_GETLBTEXT:
627 { if ( WINPROC_TestCBForStr( hwnd ))
628 { LPARAM *ptr = (LPARAM *)lParam - 1;
629 lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
630 HeapFree( SystemHeap, 0, ptr );
633 break;
635 /* Multiline edit */
636 case EM_GETLINE:
637 { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lParam */
638 WORD len = *(WORD *) lParam;
639 lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len );
640 HeapFree( SystemHeap, 0, ptr );
642 break;
647 /**********************************************************************
648 * WINPROC_MapMsg32WTo32A
650 * Map a message from Unicode to Ansi.
651 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
653 INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam )
654 { switch(msg)
656 case WM_GETTEXT:
658 LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0,
659 wParam + sizeof(LPARAM) );
660 if (!ptr) return -1;
661 *ptr++ = *plparam; /* Store previous lParam */
662 *plparam = (LPARAM)ptr;
664 return 1;
666 case WM_SETTEXT:
667 case WM_WININICHANGE:
668 case CB_DIR:
669 case CB_FINDSTRING:
670 case CB_FINDSTRINGEXACT:
671 case CB_SELECTSTRING:
672 case LB_DIR:
673 case LB_ADDFILE:
674 case LB_FINDSTRING:
675 case LB_SELECTSTRING:
676 case EM_REPLACESEL:
677 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
678 return (*plparam ? 1 : -1);
680 case WM_NCCREATE:
681 case WM_CREATE:
683 CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( SystemHeap, 0,
684 sizeof(*cs) );
685 if (!cs) return -1;
686 *cs = *(CREATESTRUCTA *)*plparam;
687 if (HIWORD(cs->lpszName))
688 cs->lpszName = HEAP_strdupWtoA( SystemHeap, 0,
689 (LPCWSTR)cs->lpszName );
690 if (HIWORD(cs->lpszClass))
691 cs->lpszClass = HEAP_strdupWtoA( SystemHeap, 0,
692 (LPCWSTR)cs->lpszClass);
693 *plparam = (LPARAM)cs;
695 return 1;
696 case WM_MDICREATE:
698 MDICREATESTRUCTA *cs =
699 (MDICREATESTRUCTA *)HeapAlloc( SystemHeap, 0, sizeof(*cs) );
700 if (!cs) return -1;
701 *cs = *(MDICREATESTRUCTA *)*plparam;
702 if (HIWORD(cs->szTitle))
703 cs->szTitle = HEAP_strdupWtoA( SystemHeap, 0,
704 (LPCWSTR)cs->szTitle );
705 if (HIWORD(cs->szClass))
706 cs->szClass = HEAP_strdupWtoA( SystemHeap, 0,
707 (LPCWSTR)cs->szClass );
708 *plparam = (LPARAM)cs;
710 return 1;
712 /* Listbox */
713 case LB_ADDSTRING:
714 case LB_INSERTSTRING:
715 if ( WINPROC_TestLBForStr( hwnd ))
716 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
717 return (*plparam ? 1 : -1);
719 case LB_GETTEXT: /* fixme: fixed sized buffer */
720 { if ( WINPROC_TestLBForStr( hwnd ))
721 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 + sizeof(LPARAM) );
722 if (!ptr) return -1;
723 *ptr++ = *plparam; /* Store previous lParam */
724 *plparam = (LPARAM)ptr;
727 return 1;
729 /* Combobox */
730 case CB_ADDSTRING:
731 case CB_INSERTSTRING:
732 if ( WINPROC_TestCBForStr( hwnd ))
733 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
734 return (*plparam ? 1 : -1);
736 case CB_GETLBTEXT: /* fixme: fixed sized buffer */
737 { if ( WINPROC_TestCBForStr( hwnd ))
738 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 + sizeof(LPARAM) );
739 if (!ptr) return -1;
740 *ptr++ = *plparam; /* Store previous lParam */
741 *plparam = (LPARAM)ptr;
744 return 1;
746 /* Multiline edit */
747 case EM_GETLINE:
748 { WORD len = (WORD)*plparam;
749 LPARAM *ptr = (LPARAM *) HEAP_xalloc( SystemHeap, 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
750 if (!ptr) return -1;
751 *ptr++ = *plparam; /* Store previous lParam */
752 (WORD)*ptr = len; /* Store the lenght */
753 *plparam = (LPARAM)ptr;
755 return 1;
757 case WM_ASKCBFORMATNAME:
758 case WM_DEVMODECHANGE:
759 case WM_PAINTCLIPBOARD:
760 case WM_SIZECLIPBOARD:
761 case EM_SETPASSWORDCHAR:
762 FIXME(msg, "message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg );
763 return -1;
764 default: /* No translation needed */
765 return 0;
770 /**********************************************************************
771 * WINPROC_UnmapMsg32WTo32A
773 * Unmap a message that was mapped from Unicode to Ansi.
775 void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
777 switch(msg)
779 case WM_GETTEXT:
781 LPARAM *ptr = (LPARAM *)lParam - 1;
782 lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam );
783 HeapFree( SystemHeap, 0, ptr );
785 break;
787 case WM_SETTEXT:
788 case WM_WININICHANGE:
789 case CB_DIR:
790 case CB_FINDSTRING:
791 case CB_FINDSTRINGEXACT:
792 case CB_SELECTSTRING:
793 case LB_DIR:
794 case LB_ADDFILE:
795 case LB_FINDSTRING:
796 case LB_SELECTSTRING:
797 case EM_REPLACESEL:
798 HeapFree( SystemHeap, 0, (void *)lParam );
799 break;
801 case WM_NCCREATE:
802 case WM_CREATE:
804 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
805 if (HIWORD(cs->lpszName))
806 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
807 if (HIWORD(cs->lpszClass))
808 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
809 HeapFree( SystemHeap, 0, cs );
811 break;
813 case WM_MDICREATE:
815 MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
816 if (HIWORD(cs->szTitle))
817 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
818 if (HIWORD(cs->szClass))
819 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
820 HeapFree( SystemHeap, 0, cs );
822 break;
824 /* Listbox */
825 case LB_ADDSTRING:
826 case LB_INSERTSTRING:
827 if ( WINPROC_TestLBForStr( hwnd ))
828 HeapFree( SystemHeap, 0, (void *)lParam );
829 break;
831 case LB_GETTEXT:
832 { if ( WINPROC_TestLBForStr( hwnd ))
833 { LPARAM *ptr = (LPARAM *)lParam - 1;
834 lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
835 HeapFree( SystemHeap, 0, ptr );
838 break;
840 /* Combobox */
841 case CB_ADDSTRING:
842 case CB_INSERTSTRING:
843 if ( WINPROC_TestCBForStr( hwnd ))
844 HeapFree( SystemHeap, 0, (void *)lParam );
845 break;
847 case CB_GETLBTEXT:
848 { if ( WINPROC_TestCBForStr( hwnd ))
849 { LPARAM *ptr = (LPARAM *)lParam - 1;
850 lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
851 HeapFree( SystemHeap, 0, ptr );
854 break;
856 /* Multiline edit */
857 case EM_GETLINE:
858 { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lparam */
859 WORD len = *(WORD *)ptr;
860 lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
861 HeapFree( SystemHeap, 0, ptr );
863 break;
868 /**********************************************************************
869 * WINPROC_MapMsg16To32A
871 * Map a message from 16- to 32-bit Ansi.
872 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
874 INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
875 WPARAM *pwparam32, LPARAM *plparam )
877 *pmsg32 = (UINT)msg16;
878 *pwparam32 = (WPARAM)wParam16;
879 switch(msg16)
881 case WM_ACTIVATE:
882 case WM_CHARTOITEM:
883 case WM_COMMAND:
884 case WM_VKEYTOITEM:
885 *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
886 *plparam = (LPARAM)(HWND)LOWORD(*plparam);
887 return 0;
888 case WM_HSCROLL:
889 case WM_VSCROLL:
890 *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
891 *plparam = (LPARAM)(HWND)HIWORD(*plparam);
892 return 0;
893 case WM_CTLCOLOR:
894 if ( HIWORD(*plparam) > CTLCOLOR_STATIC ) return -1;
895 *pmsg32 = WM_CTLCOLORMSGBOX + HIWORD(*plparam);
896 *pwparam32 = (WPARAM)(HDC)wParam16;
897 *plparam = (LPARAM)(HWND)LOWORD(*plparam);
898 return 0;
899 case WM_COMPAREITEM:
901 COMPAREITEMSTRUCT16* cis16 = (COMPAREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
902 COMPAREITEMSTRUCT *cis = (COMPAREITEMSTRUCT *)
903 HeapAlloc(SystemHeap, 0, sizeof(*cis));
904 if (!cis) return -1;
905 cis->CtlType = cis16->CtlType;
906 cis->CtlID = cis16->CtlID;
907 cis->hwndItem = cis16->hwndItem;
908 cis->itemID1 = cis16->itemID1;
909 cis->itemData1 = cis16->itemData1;
910 cis->itemID2 = cis16->itemID2;
911 cis->itemData2 = cis16->itemData2;
912 cis->dwLocaleId = 0; /* FIXME */
913 *plparam = (LPARAM)cis;
915 return 1;
916 case WM_DELETEITEM:
918 DELETEITEMSTRUCT16* dis16 = (DELETEITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
919 DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)
920 HeapAlloc(SystemHeap, 0, sizeof(*dis));
921 if (!dis) return -1;
922 dis->CtlType = dis16->CtlType;
923 dis->CtlID = dis16->CtlID;
924 dis->hwndItem = dis16->hwndItem;
925 dis->itemData = dis16->itemData;
926 *plparam = (LPARAM)dis;
928 return 1;
929 case WM_MEASUREITEM:
931 MEASUREITEMSTRUCT16* mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
932 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)
933 HeapAlloc(SystemHeap, 0,
934 sizeof(*mis) + sizeof(LPARAM));
935 if (!mis) return -1;
936 mis->CtlType = mis16->CtlType;
937 mis->CtlID = mis16->CtlID;
938 mis->itemID = mis16->itemID;
939 mis->itemWidth = mis16->itemWidth;
940 mis->itemHeight = mis16->itemHeight;
941 mis->itemData = mis16->itemData;
942 *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */
943 *plparam = (LPARAM)mis;
945 return 1;
946 case WM_DRAWITEM:
948 DRAWITEMSTRUCT16* dis16 = (DRAWITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
949 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)HeapAlloc(SystemHeap, 0,
950 sizeof(*dis));
951 if (!dis) return -1;
952 dis->CtlType = dis16->CtlType;
953 dis->CtlID = dis16->CtlID;
954 dis->itemID = dis16->itemID;
955 dis->itemAction = dis16->itemAction;
956 dis->itemState = dis16->itemState;
957 dis->hwndItem = dis16->hwndItem;
958 dis->hDC = dis16->hDC;
959 dis->itemData = dis16->itemData;
960 CONV_RECT16TO32( &dis16->rcItem, &dis->rcItem );
961 *plparam = (LPARAM)dis;
963 return 1;
964 case WM_GETMINMAXINFO:
966 MINMAXINFO *mmi = (MINMAXINFO *)HeapAlloc( SystemHeap, 0,
967 sizeof(*mmi) + sizeof(LPARAM));
968 if (!mmi) return -1;
969 STRUCT32_MINMAXINFO16to32( (MINMAXINFO16*)PTR_SEG_TO_LIN(*plparam),
970 mmi );
971 *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */
972 *plparam = (LPARAM)mmi;
974 return 1;
975 case WM_GETTEXT:
976 case WM_SETTEXT:
977 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
978 return 0;
979 case WM_MDICREATE:
981 MDICREATESTRUCT16 *cs16 =
982 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
983 MDICREATESTRUCTA *cs =
984 (MDICREATESTRUCTA *)HeapAlloc( SystemHeap, 0,
985 sizeof(*cs) + sizeof(LPARAM) );
986 if (!cs) return -1;
987 STRUCT32_MDICREATESTRUCT16to32A( cs16, cs );
988 cs->szTitle = (LPCSTR)PTR_SEG_TO_LIN(cs16->szTitle);
989 cs->szClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->szClass);
990 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
991 *plparam = (LPARAM)cs;
993 return 1;
994 case WM_MDIGETACTIVE:
995 *plparam = (LPARAM)HeapAlloc( SystemHeap, 0, sizeof(BOOL) );
996 *(BOOL*)(*plparam) = 0;
997 return 1;
998 case WM_MDISETMENU:
999 if(wParam16==TRUE)
1000 *pmsg32=WM_MDIREFRESHMENU;
1001 *pwparam32 = (WPARAM)(HMENU)LOWORD(*plparam);
1002 *plparam = (LPARAM)(HMENU)HIWORD(*plparam);
1003 return 0;
1004 case WM_MENUCHAR:
1005 case WM_MENUSELECT:
1006 *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
1007 *plparam = (LPARAM)(HMENU)HIWORD(*plparam);
1008 return 0;
1009 case WM_MDIACTIVATE:
1010 if( *plparam )
1012 *pwparam32 = (WPARAM)(HWND)HIWORD(*plparam);
1013 *plparam = (LPARAM)(HWND)LOWORD(*plparam);
1015 else /* message sent to MDI client */
1016 *pwparam32 = wParam16;
1017 return 0;
1018 case WM_NCCALCSIZE:
1020 NCCALCSIZE_PARAMS16 *nc16;
1021 NCCALCSIZE_PARAMS *nc;
1023 nc = (NCCALCSIZE_PARAMS *)HeapAlloc( SystemHeap, 0,
1024 sizeof(*nc) + sizeof(LPARAM) );
1025 if (!nc) return -1;
1026 nc16 = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(*plparam);
1027 CONV_RECT16TO32( &nc16->rgrc[0], &nc->rgrc[0] );
1028 if (wParam16)
1030 nc->lppos = (WINDOWPOS *)HeapAlloc( SystemHeap, 0,
1031 sizeof(*nc->lppos) );
1032 CONV_RECT16TO32( &nc16->rgrc[1], &nc->rgrc[1] );
1033 CONV_RECT16TO32( &nc16->rgrc[2], &nc->rgrc[2] );
1034 if (nc->lppos) STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc16->lppos), nc->lppos );
1036 *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */
1037 *plparam = (LPARAM)nc;
1039 return 1;
1040 case WM_NCCREATE:
1041 case WM_CREATE:
1043 CREATESTRUCT16 *cs16 = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1044 CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( SystemHeap, 0,
1045 sizeof(*cs) + sizeof(LPARAM) );
1046 if (!cs) return -1;
1047 STRUCT32_CREATESTRUCT16to32A( cs16, cs );
1048 cs->lpszName = (LPCSTR)PTR_SEG_TO_LIN(cs16->lpszName);
1049 cs->lpszClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->lpszClass);
1050 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1051 *plparam = (LPARAM)cs;
1053 return 1;
1054 case WM_PARENTNOTIFY:
1055 if ((wParam16 == WM_CREATE) || (wParam16 == WM_DESTROY))
1057 *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
1058 *plparam = (LPARAM)(HWND)LOWORD(*plparam);
1060 return 0;
1061 case WM_WINDOWPOSCHANGING:
1062 case WM_WINDOWPOSCHANGED:
1064 WINDOWPOS *wp = (WINDOWPOS *)HeapAlloc( SystemHeap, 0,
1065 sizeof(*wp) + sizeof(LPARAM) );
1066 if (!wp) return -1;
1067 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(*plparam),
1068 wp );
1069 *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */
1070 *plparam = (LPARAM)wp;
1072 return 1;
1073 case WM_GETDLGCODE:
1074 if (*plparam)
1076 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(*plparam);
1077 LPMSG msg32 = (LPMSG)HeapAlloc( SystemHeap, 0, sizeof(MSG) );
1079 if (!msg32) return -1;
1080 msg32->hwnd = msg16->hwnd;
1081 msg32->lParam = msg16->lParam;
1082 msg32->time = msg16->time;
1083 CONV_POINT16TO32(&msg16->pt,&msg32->pt);
1084 /* this is right, right? */
1085 if (WINPROC_MapMsg16To32A(msg16->message,msg16->wParam,
1086 &msg32->message,&msg32->wParam,
1087 &msg32->lParam)<0) {
1088 HeapFree( SystemHeap, 0, msg32 );
1089 return -1;
1091 *plparam = (LPARAM)msg32;
1092 return 1;
1094 else return 0;
1095 case WM_NOTIFY:
1096 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
1097 return 1;
1098 case WM_ACTIVATEAPP:
1099 if (*plparam)
1100 { /* We need this when SetActiveWindow sends a Sendmessage16() to
1101 a 32bit window. Might be superflous with 32bit interprocess
1102 message queues.
1104 HTASK16 htask = (HTASK16) *plparam;
1105 DWORD idThread = (DWORD)((TDB*)GlobalLock16(htask))->thdb->server_tid;
1106 *plparam = (LPARAM) idThread;
1108 return 1;
1109 case WM_ASKCBFORMATNAME:
1110 case WM_DEVMODECHANGE:
1111 case WM_PAINTCLIPBOARD:
1112 case WM_SIZECLIPBOARD:
1113 case WM_WININICHANGE:
1114 FIXME( msg, "message %04x needs translation\n",msg16 );
1115 return -1;
1117 default: /* No translation needed */
1118 return 0;
1123 /**********************************************************************
1124 * WINPROC_UnmapMsg16To32A
1126 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1128 LRESULT WINPROC_UnmapMsg16To32A( HWND16 hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
1129 LRESULT result )
1131 switch(msg)
1133 case WM_COMPAREITEM:
1134 case WM_DELETEITEM:
1135 case WM_DRAWITEM:
1136 HeapFree( SystemHeap, 0, (LPVOID)lParam );
1137 break;
1138 case WM_MEASUREITEM:
1140 MEASUREITEMSTRUCT16 *mis16;
1141 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam;
1142 lParam = *(LPARAM *)(mis + 1);
1143 mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(lParam);
1144 mis16->itemWidth = (UINT16)mis->itemWidth;
1145 mis16->itemHeight = (UINT16)mis->itemHeight;
1146 HeapFree( SystemHeap, 0, mis );
1148 break;
1149 case WM_GETMINMAXINFO:
1151 MINMAXINFO *mmi = (MINMAXINFO *)lParam;
1152 lParam = *(LPARAM *)(mmi + 1);
1153 STRUCT32_MINMAXINFO32to16( mmi,
1154 (MINMAXINFO16 *)PTR_SEG_TO_LIN(lParam));
1155 HeapFree( SystemHeap, 0, mmi );
1157 break;
1158 case WM_MDICREATE:
1160 MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
1161 lParam = *(LPARAM *)(cs + 1);
1162 STRUCT32_MDICREATESTRUCT32Ato16( cs,
1163 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1164 HeapFree( SystemHeap, 0, cs );
1166 break;
1167 case WM_MDIGETACTIVE:
1168 result = MAKELONG( LOWORD(result), (BOOL16)(*(BOOL *)lParam) );
1169 HeapFree( SystemHeap, 0, (BOOL *)lParam );
1170 break;
1171 case WM_NCCALCSIZE:
1173 NCCALCSIZE_PARAMS16 *nc16;
1174 NCCALCSIZE_PARAMS *nc = (NCCALCSIZE_PARAMS *)lParam;
1175 lParam = *(LPARAM *)(nc + 1);
1176 nc16 = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(lParam);
1177 CONV_RECT32TO16( &nc->rgrc[0], &nc16->rgrc[0] );
1178 if (wParam)
1180 CONV_RECT32TO16( &nc->rgrc[1], &nc16->rgrc[1] );
1181 CONV_RECT32TO16( &nc->rgrc[2], &nc16->rgrc[2] );
1182 if (nc->lppos)
1184 STRUCT32_WINDOWPOS32to16( nc->lppos,
1185 (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc16->lppos));
1186 HeapFree( SystemHeap, 0, nc->lppos );
1189 HeapFree( SystemHeap, 0, nc );
1191 break;
1192 case WM_NCCREATE:
1193 case WM_CREATE:
1195 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
1196 lParam = *(LPARAM *)(cs + 1);
1197 STRUCT32_CREATESTRUCT32Ato16( cs,
1198 (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1199 HeapFree( SystemHeap, 0, cs );
1201 break;
1202 case WM_WINDOWPOSCHANGING:
1203 case WM_WINDOWPOSCHANGED:
1205 WINDOWPOS *wp = (WINDOWPOS *)lParam;
1206 lParam = *(LPARAM *)(wp + 1);
1207 STRUCT32_WINDOWPOS32to16(wp,(WINDOWPOS16 *)PTR_SEG_TO_LIN(lParam));
1208 HeapFree( SystemHeap, 0, wp );
1210 break;
1211 case WM_GETDLGCODE:
1212 if (lParam)
1214 LPMSG msg32 = (LPMSG)lParam;
1216 WINPROC_UnmapMsg16To32A( hwnd, msg32->message, msg32->wParam, msg32->lParam,
1217 result);
1218 HeapFree( SystemHeap, 0, msg32 );
1220 break;
1222 return result;
1226 /**********************************************************************
1227 * WINPROC_MapMsg16To32W
1229 * Map a message from 16- to 32-bit Unicode.
1230 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1232 INT WINPROC_MapMsg16To32W( HWND16 hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
1233 WPARAM *pwparam32, LPARAM *plparam )
1235 switch(msg16)
1237 case WM_GETTEXT:
1238 case WM_SETTEXT:
1239 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
1240 return WINPROC_MapMsg32ATo32W( hwnd, *pmsg32, *pwparam32, plparam );
1241 case WM_NCCREATE:
1242 case WM_CREATE:
1244 CREATESTRUCT16 *cs16 = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1245 CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( SystemHeap, 0,
1246 sizeof(*cs) + sizeof(LPARAM) );
1247 if (!cs) return -1;
1248 STRUCT32_CREATESTRUCT16to32A( cs16, (CREATESTRUCTA *)cs );
1249 cs->lpszName = (LPCWSTR)PTR_SEG_TO_LIN(cs16->lpszName);
1250 cs->lpszClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->lpszClass);
1251 if (HIWORD(cs->lpszName))
1252 cs->lpszName = HEAP_strdupAtoW( SystemHeap, 0,
1253 (LPCSTR)cs->lpszName );
1254 if (HIWORD(cs->lpszClass))
1255 cs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0,
1256 (LPCSTR)cs->lpszClass );
1257 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1258 *plparam = (LPARAM)cs;
1260 return 1;
1261 case WM_MDICREATE:
1263 MDICREATESTRUCT16 *cs16 =
1264 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1265 MDICREATESTRUCTW *cs =
1266 (MDICREATESTRUCTW *)HeapAlloc( SystemHeap, 0,
1267 sizeof(*cs) + sizeof(LPARAM) );
1268 if (!cs) return -1;
1269 STRUCT32_MDICREATESTRUCT16to32A( cs16, (MDICREATESTRUCTA *)cs );
1270 cs->szTitle = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szTitle);
1271 cs->szClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szClass);
1272 if (HIWORD(cs->szTitle))
1273 cs->szTitle = HEAP_strdupAtoW( SystemHeap, 0,
1274 (LPCSTR)cs->szTitle );
1275 if (HIWORD(cs->szClass))
1276 cs->szClass = HEAP_strdupAtoW( SystemHeap, 0,
1277 (LPCSTR)cs->szClass );
1278 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1279 *plparam = (LPARAM)cs;
1281 return 1;
1282 case WM_GETDLGCODE:
1283 if (*plparam)
1285 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(*plparam);
1286 LPMSG msg32 = (LPMSG)HeapAlloc( SystemHeap, 0, sizeof(MSG) );
1288 if (!msg32) return -1;
1289 msg32->hwnd = msg16->hwnd;
1290 msg32->lParam = msg16->lParam;
1291 msg32->time = msg16->time;
1292 CONV_POINT16TO32(&msg16->pt,&msg32->pt);
1293 /* this is right, right? */
1294 if (WINPROC_MapMsg16To32W(hwnd, msg16->message,msg16->wParam,
1295 &msg32->message,&msg32->wParam,
1296 &msg32->lParam)<0) {
1297 HeapFree( SystemHeap, 0, msg32 );
1298 return -1;
1300 *plparam = (LPARAM)msg32;
1301 return 1;
1303 else return 0;
1304 default: /* No Unicode translation needed */
1305 return WINPROC_MapMsg16To32A( msg16, wParam16, pmsg32,
1306 pwparam32, plparam );
1311 /**********************************************************************
1312 * WINPROC_UnmapMsg16To32W
1314 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1316 LRESULT WINPROC_UnmapMsg16To32W( HWND16 hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
1317 LRESULT result )
1319 switch(msg)
1321 case WM_GETTEXT:
1322 case WM_SETTEXT:
1323 WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
1324 break;
1325 case WM_NCCREATE:
1326 case WM_CREATE:
1328 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
1329 lParam = *(LPARAM *)(cs + 1);
1330 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA *)cs,
1331 (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1332 if (HIWORD(cs->lpszName))
1333 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
1334 if (HIWORD(cs->lpszClass))
1335 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
1336 HeapFree( SystemHeap, 0, cs );
1338 break;
1339 case WM_MDICREATE:
1341 MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
1342 lParam = *(LPARAM *)(cs + 1);
1343 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA *)cs,
1344 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1345 if (HIWORD(cs->szTitle))
1346 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
1347 if (HIWORD(cs->szClass))
1348 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
1349 HeapFree( SystemHeap, 0, cs );
1351 break;
1352 case WM_GETDLGCODE:
1353 if (lParam)
1355 LPMSG msg32 = (LPMSG)lParam;
1357 WINPROC_UnmapMsg16To32W( hwnd, msg32->message, msg32->wParam, msg32->lParam,
1358 result);
1359 HeapFree( SystemHeap, 0, msg32 );
1361 break;
1362 default:
1363 return WINPROC_UnmapMsg16To32A( hwnd, msg, wParam, lParam, result );
1365 return result;
1369 /**********************************************************************
1370 * WINPROC_MapMsg32ATo16
1372 * Map a message from 32-bit Ansi to 16-bit.
1373 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1375 INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32,
1376 UINT16 *pmsg16, WPARAM16 *pwparam16,
1377 LPARAM *plparam )
1379 *pmsg16 = (UINT16)msg32;
1380 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1381 switch(msg32)
1383 case BM_GETCHECK:
1384 case BM_SETCHECK:
1385 case BM_GETSTATE:
1386 case BM_SETSTATE:
1387 case BM_SETSTYLE:
1388 *pmsg16 = (UINT16)msg32 + (BM_GETCHECK16 - BM_GETCHECK);
1389 return 0;
1391 case EM_GETSEL:
1392 case EM_GETRECT:
1393 case EM_SETRECT:
1394 case EM_SETRECTNP:
1395 case EM_SCROLL:
1396 case EM_LINESCROLL:
1397 case EM_SCROLLCARET:
1398 case EM_GETMODIFY:
1399 case EM_SETMODIFY:
1400 case EM_GETLINECOUNT:
1401 case EM_LINEINDEX:
1402 case EM_SETHANDLE:
1403 case EM_GETHANDLE:
1404 case EM_GETTHUMB:
1405 case EM_LINELENGTH:
1406 case EM_REPLACESEL:
1407 case EM_GETLINE:
1408 case EM_LIMITTEXT:
1409 case EM_CANUNDO:
1410 case EM_UNDO:
1411 case EM_FMTLINES:
1412 case EM_LINEFROMCHAR:
1413 case EM_SETTABSTOPS:
1414 case EM_SETPASSWORDCHAR:
1415 case EM_EMPTYUNDOBUFFER:
1416 case EM_GETFIRSTVISIBLELINE:
1417 case EM_SETREADONLY:
1418 case EM_SETWORDBREAKPROC:
1419 case EM_GETWORDBREAKPROC:
1420 case EM_GETPASSWORDCHAR:
1421 *pmsg16 = (UINT16)msg32 + (EM_GETSEL16 - EM_GETSEL);
1422 return 0;
1424 case LB_CARETOFF:
1425 case LB_CARETON:
1426 case LB_DELETESTRING:
1427 case LB_GETANCHORINDEX:
1428 case LB_GETCARETINDEX:
1429 case LB_GETCOUNT:
1430 case LB_GETCURSEL:
1431 case LB_GETHORIZONTALEXTENT:
1432 case LB_GETITEMDATA:
1433 case LB_GETITEMHEIGHT:
1434 case LB_GETSEL:
1435 case LB_GETSELCOUNT:
1436 case LB_GETTEXTLEN:
1437 case LB_GETTOPINDEX:
1438 case LB_RESETCONTENT:
1439 case LB_SELITEMRANGE:
1440 case LB_SELITEMRANGEEX:
1441 case LB_SETANCHORINDEX:
1442 case LB_SETCARETINDEX:
1443 case LB_SETCOLUMNWIDTH:
1444 case LB_SETCURSEL:
1445 case LB_SETHORIZONTALEXTENT:
1446 case LB_SETITEMDATA:
1447 case LB_SETITEMHEIGHT:
1448 case LB_SETSEL:
1449 case LB_SETTOPINDEX:
1450 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
1451 return 0;
1452 case CB_DELETESTRING:
1453 case CB_GETCOUNT:
1454 case CB_GETLBTEXTLEN:
1455 case CB_LIMITTEXT:
1456 case CB_RESETCONTENT:
1457 case CB_SETEDITSEL:
1458 case CB_GETCURSEL:
1459 case CB_SETCURSEL:
1460 case CB_SHOWDROPDOWN:
1461 case CB_SETITEMDATA:
1462 case CB_SETITEMHEIGHT:
1463 case CB_GETITEMHEIGHT:
1464 case CB_SETEXTENDEDUI:
1465 case CB_GETEXTENDEDUI:
1466 case CB_GETDROPPEDSTATE:
1467 *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL);
1468 return 0;
1469 case CB_GETEDITSEL:
1470 *pmsg16 = CB_GETEDITSEL16;
1471 return 1;
1473 case LB_ADDSTRING:
1474 case LB_FINDSTRING:
1475 case LB_FINDSTRINGEXACT:
1476 case LB_INSERTSTRING:
1477 case LB_SELECTSTRING:
1478 case LB_DIR:
1479 case LB_ADDFILE:
1481 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1482 if (!str) return -1;
1483 *plparam = (LPARAM)SEGPTR_GET(str);
1485 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
1486 return 1;
1488 case CB_ADDSTRING:
1489 case CB_FINDSTRING:
1490 case CB_FINDSTRINGEXACT:
1491 case CB_INSERTSTRING:
1492 case CB_SELECTSTRING:
1493 case CB_DIR:
1495 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1496 if (!str) return -1;
1497 *plparam = (LPARAM)SEGPTR_GET(str);
1499 *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL);
1500 return 1;
1502 case LB_GETITEMRECT:
1504 RECT16 *rect;
1505 rect = (RECT16 *)SEGPTR_ALLOC( sizeof(RECT16) + sizeof(LPARAM) );
1506 if (!rect) return -1;
1507 *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */
1508 *plparam = (LPARAM)SEGPTR_GET(rect);
1510 *pmsg16 = LB_GETITEMRECT16;
1511 return 1;
1512 case LB_GETSELITEMS:
1514 LPINT16 items;
1515 *pwparam16 = (WPARAM16)MIN( wParam32, 0x7f80 ); /* Must be < 64K */
1516 if (!(items = SEGPTR_ALLOC( *pwparam16 * sizeof(INT16)
1517 + sizeof(LPARAM)))) return -1;
1518 *((LPARAM *)items)++ = *plparam; /* Store the previous lParam */
1519 *plparam = (LPARAM)SEGPTR_GET(items);
1521 *pmsg16 = LB_GETSELITEMS16;
1522 return 1;
1523 case LB_SETTABSTOPS:
1524 if (wParam32)
1526 INT i;
1527 LPINT16 stops;
1528 *pwparam16 = (WPARAM16)MIN( wParam32, 0x7f80 ); /* Must be < 64K */
1529 if (!(stops = SEGPTR_ALLOC( *pwparam16 * sizeof(INT16)
1530 + sizeof(LPARAM)))) return -1;
1531 for (i = 0; i < *pwparam16; i++) stops[i] = *((LPINT)*plparam+i);
1532 *plparam = (LPARAM)SEGPTR_GET(stops);
1533 return 1;
1535 *pmsg16 = LB_SETTABSTOPS16;
1536 return 0;
1538 case CB_GETDROPPEDCONTROLRECT:
1540 RECT16 *rect;
1541 rect = (RECT16 *)SEGPTR_ALLOC( sizeof(RECT16) + sizeof(LPARAM) );
1542 if (!rect) return -1;
1543 *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */
1544 *plparam = (LPARAM)SEGPTR_GET(rect);
1546 *pmsg16 = CB_GETDROPPEDCONTROLRECT16;
1547 return 1;
1549 case LB_GETTEXT:
1550 *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) );
1551 *pmsg16 = LB_GETTEXT16;
1552 return 1;
1554 case CB_GETLBTEXT:
1555 *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) );
1556 *pmsg16 = CB_GETLBTEXT16;
1557 return 1;
1559 case EM_SETSEL:
1560 *pwparam16 = 0;
1561 *plparam = MAKELONG( (INT16)(INT)wParam32, (INT16)*plparam );
1562 *pmsg16 = EM_SETSEL16;
1563 return 0;
1565 case WM_ACTIVATE:
1566 case WM_CHARTOITEM:
1567 case WM_COMMAND:
1568 case WM_VKEYTOITEM:
1569 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32) );
1570 return 0;
1571 case WM_HSCROLL:
1572 case WM_VSCROLL:
1573 *plparam = MAKELPARAM( HIWORD(wParam32), (HWND16)*plparam );
1574 return 0;
1575 case WM_CTLCOLORMSGBOX:
1576 case WM_CTLCOLOREDIT:
1577 case WM_CTLCOLORLISTBOX:
1578 case WM_CTLCOLORBTN:
1579 case WM_CTLCOLORDLG:
1580 case WM_CTLCOLORSCROLLBAR:
1581 case WM_CTLCOLORSTATIC:
1582 *pmsg16 = WM_CTLCOLOR;
1583 *plparam = MAKELPARAM( (HWND16)*plparam,
1584 (WORD)msg32 - WM_CTLCOLORMSGBOX );
1585 return 0;
1586 case WM_COMPAREITEM:
1588 COMPAREITEMSTRUCT *cis32 = (COMPAREITEMSTRUCT *)*plparam;
1589 COMPAREITEMSTRUCT16 *cis = SEGPTR_NEW(COMPAREITEMSTRUCT16);
1590 if (!cis) return -1;
1591 cis->CtlType = (UINT16)cis32->CtlType;
1592 cis->CtlID = (UINT16)cis32->CtlID;
1593 cis->hwndItem = (HWND16)cis32->hwndItem;
1594 cis->itemID1 = (UINT16)cis32->itemID1;
1595 cis->itemData1 = cis32->itemData1;
1596 cis->itemID2 = (UINT16)cis32->itemID2;
1597 cis->itemData2 = cis32->itemData2;
1598 *plparam = (LPARAM)SEGPTR_GET(cis);
1600 return 1;
1601 case WM_DELETEITEM:
1603 DELETEITEMSTRUCT *dis32 = (DELETEITEMSTRUCT *)*plparam;
1604 DELETEITEMSTRUCT16 *dis = SEGPTR_NEW(DELETEITEMSTRUCT16);
1605 if (!dis) return -1;
1606 dis->CtlType = (UINT16)dis32->CtlType;
1607 dis->CtlID = (UINT16)dis32->CtlID;
1608 dis->itemID = (UINT16)dis32->itemID;
1609 dis->hwndItem = (HWND16)dis32->hwndItem;
1610 dis->itemData = dis32->itemData;
1611 *plparam = (LPARAM)SEGPTR_GET(dis);
1613 return 1;
1614 case WM_DRAWITEM:
1616 DRAWITEMSTRUCT *dis32 = (DRAWITEMSTRUCT *)*plparam;
1617 DRAWITEMSTRUCT16 *dis = SEGPTR_NEW(DRAWITEMSTRUCT16);
1618 if (!dis) return -1;
1619 dis->CtlType = (UINT16)dis32->CtlType;
1620 dis->CtlID = (UINT16)dis32->CtlID;
1621 dis->itemID = (UINT16)dis32->itemID;
1622 dis->itemAction = (UINT16)dis32->itemAction;
1623 dis->itemState = (UINT16)dis32->itemState;
1624 dis->hwndItem = (HWND16)dis32->hwndItem;
1625 dis->hDC = (HDC16)dis32->hDC;
1626 dis->itemData = dis32->itemData;
1627 CONV_RECT32TO16( &dis32->rcItem, &dis->rcItem );
1628 *plparam = (LPARAM)SEGPTR_GET(dis);
1630 return 1;
1631 case WM_MEASUREITEM:
1633 MEASUREITEMSTRUCT *mis32 = (MEASUREITEMSTRUCT *)*plparam;
1634 MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)
1635 SEGPTR_ALLOC(sizeof(*mis)+sizeof(LPARAM));
1636 if (!mis) return -1;
1637 mis->CtlType = (UINT16)mis32->CtlType;
1638 mis->CtlID = (UINT16)mis32->CtlID;
1639 mis->itemID = (UINT16)mis32->itemID;
1640 mis->itemWidth = (UINT16)mis32->itemWidth;
1641 mis->itemHeight = (UINT16)mis32->itemHeight;
1642 mis->itemData = mis32->itemData;
1643 *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */
1644 *plparam = (LPARAM)SEGPTR_GET(mis);
1646 return 1;
1647 case WM_GETMINMAXINFO:
1649 MINMAXINFO16 *mmi = (MINMAXINFO16 *)SEGPTR_ALLOC( sizeof(*mmi) +
1650 sizeof(LPARAM) );
1651 if (!mmi) return -1;
1652 STRUCT32_MINMAXINFO32to16( (MINMAXINFO *)*plparam, mmi );
1653 *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */
1654 *plparam = (LPARAM)SEGPTR_GET(mmi);
1656 return 1;
1657 case WM_GETTEXT:
1659 LPSTR str;
1660 *pwparam16 = (WPARAM16)MIN( wParam32, 0xff80 ); /* Must be < 64K */
1661 if (!(str = SEGPTR_ALLOC(*pwparam16 + sizeof(LPARAM)))) return -1;
1662 *((LPARAM *)str)++ = *plparam; /* Store the previous lParam */
1663 *plparam = (LPARAM)SEGPTR_GET(str);
1665 return 1;
1666 case WM_MDICREATE:
1668 MDICREATESTRUCT16 *cs;
1669 MDICREATESTRUCTA *cs32 = (MDICREATESTRUCTA *)*plparam;
1670 LPSTR name, cls;
1672 if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1;
1673 STRUCT32_MDICREATESTRUCT32Ato16( cs32, cs );
1674 name = SEGPTR_STRDUP( cs32->szTitle );
1675 cls = SEGPTR_STRDUP( cs32->szClass );
1676 cs->szTitle = SEGPTR_GET(name);
1677 cs->szClass = SEGPTR_GET(cls);
1678 *plparam = (LPARAM)SEGPTR_GET(cs);
1680 return 1;
1681 case WM_MDIGETACTIVE:
1682 return 1;
1683 case WM_MDISETMENU:
1684 *plparam = MAKELPARAM( (HMENU16)LOWORD(wParam32),
1685 (HMENU16)LOWORD(*plparam) );
1686 *pwparam16 = (*plparam == 0);
1687 return 0;
1688 case WM_MENUCHAR:
1689 case WM_MENUSELECT:
1690 *plparam = MAKELPARAM( HIWORD(wParam32), (HMENU16)*plparam );
1691 return 0;
1692 case WM_MDIACTIVATE:
1694 WND *tempWnd = WIN_FindWndPtr(hwnd);
1695 if( WIDGETS_IsControl(tempWnd, BIC32_MDICLIENT) )
1697 *pwparam16 = (HWND)wParam32;
1698 *plparam = 0;
1700 else
1702 *pwparam16 = ((HWND)*plparam == hwnd);
1703 *plparam = MAKELPARAM( (HWND16)LOWORD(*plparam),
1704 (HWND16)LOWORD(wParam32) );
1706 WIN_ReleaseWndPtr(tempWnd);
1708 return 0;
1709 case WM_NCCALCSIZE:
1711 NCCALCSIZE_PARAMS *nc32 = (NCCALCSIZE_PARAMS *)*plparam;
1712 NCCALCSIZE_PARAMS16 *nc = (NCCALCSIZE_PARAMS16 *)SEGPTR_ALLOC( sizeof(*nc) + sizeof(LPARAM) );
1713 if (!nc) return -1;
1715 CONV_RECT32TO16( &nc32->rgrc[0], &nc->rgrc[0] );
1716 if (wParam32)
1718 WINDOWPOS16 *wp;
1719 CONV_RECT32TO16( &nc32->rgrc[1], &nc->rgrc[1] );
1720 CONV_RECT32TO16( &nc32->rgrc[2], &nc->rgrc[2] );
1721 if (!(wp = SEGPTR_NEW(WINDOWPOS16)))
1723 SEGPTR_FREE(nc);
1724 return -1;
1726 STRUCT32_WINDOWPOS32to16( nc32->lppos, wp );
1727 nc->lppos = SEGPTR_GET(wp);
1729 *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */
1730 *plparam = (LPARAM)SEGPTR_GET(nc);
1732 return 1;
1733 case WM_NCCREATE:
1734 case WM_CREATE:
1736 CREATESTRUCT16 *cs;
1737 CREATESTRUCTA *cs32 = (CREATESTRUCTA *)*plparam;
1738 LPSTR name, cls;
1740 if (!(cs = SEGPTR_NEW(CREATESTRUCT16))) return -1;
1741 STRUCT32_CREATESTRUCT32Ato16( cs32, cs );
1742 name = SEGPTR_STRDUP( cs32->lpszName );
1743 cls = SEGPTR_STRDUP( cs32->lpszClass );
1744 cs->lpszName = SEGPTR_GET(name);
1745 cs->lpszClass = SEGPTR_GET(cls);
1746 *plparam = (LPARAM)SEGPTR_GET(cs);
1748 return 1;
1749 case WM_PARENTNOTIFY:
1750 if ((LOWORD(wParam32)==WM_CREATE) || (LOWORD(wParam32)==WM_DESTROY))
1751 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32));
1752 /* else nothing to do */
1753 return 0;
1754 case WM_NOTIFY:
1755 *plparam = MapLS( (NMHDR *)*plparam ); /* NMHDR is already 32-bit */
1756 return 1;
1757 case WM_SETTEXT:
1759 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1760 if (!str) return -1;
1761 *plparam = (LPARAM)SEGPTR_GET(str);
1763 return 1;
1764 case WM_WINDOWPOSCHANGING:
1765 case WM_WINDOWPOSCHANGED:
1767 WINDOWPOS16 *wp = (WINDOWPOS16 *)SEGPTR_ALLOC( sizeof(*wp) +
1768 sizeof(LPARAM) );
1769 if (!wp) return -1;
1770 STRUCT32_WINDOWPOS32to16( (WINDOWPOS *)*plparam, wp );
1771 *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */
1772 *plparam = (LPARAM)SEGPTR_GET(wp);
1774 return 1;
1775 case WM_GETDLGCODE:
1776 if (*plparam) {
1777 LPMSG msg32 = (LPMSG) *plparam;
1778 LPMSG16 msg16 = (LPMSG16) SEGPTR_NEW( MSG16 );
1780 if (!msg16) return -1;
1781 msg16->hwnd = msg32->hwnd;
1782 msg16->lParam = msg32->lParam;
1783 msg16->time = msg32->time;
1784 CONV_POINT32TO16(&msg32->pt,&msg16->pt);
1785 /* this is right, right? */
1786 if (WINPROC_MapMsg32ATo16(msg32->hwnd,msg32->message,msg32->wParam,
1787 &msg16->message,&msg16->wParam, &msg16->lParam)<0) {
1788 SEGPTR_FREE( msg16 );
1789 return -1;
1791 *plparam = (LPARAM)SEGPTR_GET(msg16);
1792 return 1;
1794 return 0;
1796 case WM_ACTIVATEAPP:
1797 if (*plparam) {
1798 *plparam = (LPARAM)THREAD_IdToTHDB((DWORD) *plparam)->teb.htask16;
1800 return 1;
1801 case WM_ASKCBFORMATNAME:
1802 case WM_DEVMODECHANGE:
1803 case WM_PAINTCLIPBOARD:
1804 case WM_SIZECLIPBOARD:
1805 case WM_WININICHANGE:
1806 FIXME( msg, "message %04x needs translation\n", msg32 );
1807 return -1;
1808 default: /* No translation needed */
1809 return 0;
1814 /**********************************************************************
1815 * WINPROC_UnmapMsg32ATo16
1817 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
1819 void WINPROC_UnmapMsg32ATo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
1820 MSGPARAM16* p16 )
1822 switch(msg)
1824 case LB_ADDFILE:
1825 case LB_ADDSTRING:
1826 case LB_DIR:
1827 case LB_FINDSTRING:
1828 case LB_FINDSTRINGEXACT:
1829 case LB_INSERTSTRING:
1830 case LB_SELECTSTRING:
1831 case LB_SETTABSTOPS:
1832 case CB_ADDSTRING:
1833 case CB_FINDSTRING:
1834 case CB_FINDSTRINGEXACT:
1835 case CB_INSERTSTRING:
1836 case CB_SELECTSTRING:
1837 case CB_DIR:
1838 case WM_COMPAREITEM:
1839 case WM_DELETEITEM:
1840 case WM_DRAWITEM:
1841 case WM_SETTEXT:
1842 SEGPTR_FREE( PTR_SEG_TO_LIN(p16->lParam) );
1843 break;
1845 case CB_GETDROPPEDCONTROLRECT:
1846 case LB_GETITEMRECT:
1848 RECT16 *rect = (RECT16 *)PTR_SEG_TO_LIN(p16->lParam);
1849 p16->lParam = *(LPARAM *)(rect + 1);
1850 CONV_RECT16TO32( rect, (RECT *)(p16->lParam));
1851 SEGPTR_FREE( rect );
1853 break;
1854 case LB_GETSELITEMS:
1856 INT i;
1857 LPINT16 items = (LPINT16)PTR_SEG_TO_LIN(lParam);
1858 p16->lParam = *((LPARAM *)items - 1);
1859 for (i = 0; i < p16->wParam; i++) *((LPINT)(p16->lParam) + i) = items[i];
1860 SEGPTR_FREE( (LPARAM *)items - 1 );
1862 break;
1864 case CB_GETEDITSEL:
1865 if( wParam )
1866 *((LPUINT)(wParam)) = LOWORD(p16->lResult);
1867 if( lParam )
1868 *((LPUINT)(lParam)) = HIWORD(p16->lResult); /* FIXME: substract 1? */
1869 break;
1871 case LB_GETTEXT:
1872 case CB_GETLBTEXT:
1873 UnMapLS( (SEGPTR)(p16->lParam) );
1874 break;
1876 case WM_MEASUREITEM:
1878 MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(p16->lParam);
1879 MEASUREITEMSTRUCT *mis32 = *(MEASUREITEMSTRUCT **)(mis + 1);
1880 mis32->itemWidth = mis->itemWidth;
1881 mis32->itemHeight = mis->itemHeight;
1882 SEGPTR_FREE(mis);
1884 break;
1885 case WM_GETMINMAXINFO:
1887 MINMAXINFO16 *mmi = (MINMAXINFO16 *)PTR_SEG_TO_LIN(p16->lParam);
1888 p16->lParam = *(LPARAM *)(mmi + 1);
1889 STRUCT32_MINMAXINFO16to32( mmi, (MINMAXINFO *)(p16->lParam) );
1890 SEGPTR_FREE(mmi);
1892 break;
1893 case WM_GETTEXT:
1895 LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam);
1896 p16->lParam = *((LPARAM *)str - 1);
1897 lstrcpynA( (LPSTR)(p16->lParam), str, p16->wParam );
1898 SEGPTR_FREE( (LPARAM *)str - 1 );
1900 break;
1901 case WM_MDICREATE:
1903 MDICREATESTRUCT16 *cs = (MDICREATESTRUCT16*)PTR_SEG_TO_LIN(p16->lParam);
1904 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szTitle) );
1905 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szClass) );
1906 SEGPTR_FREE( cs );
1908 break;
1909 case WM_MDIGETACTIVE:
1910 if (lParam) *(BOOL *)lParam = (BOOL16)HIWORD(p16->lResult);
1911 p16->lResult = (HWND)LOWORD(p16->lResult);
1912 break;
1913 case WM_NCCALCSIZE:
1915 NCCALCSIZE_PARAMS *nc32;
1916 NCCALCSIZE_PARAMS16 *nc = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(p16->lParam);
1917 p16->lParam = *(LPARAM *)(nc + 1);
1918 nc32 = (NCCALCSIZE_PARAMS *)(p16->lParam);
1919 CONV_RECT16TO32( &nc->rgrc[0], &nc32->rgrc[0] );
1920 if (p16->wParam)
1922 CONV_RECT16TO32( &nc->rgrc[1], &nc32->rgrc[1] );
1923 CONV_RECT16TO32( &nc->rgrc[2], &nc32->rgrc[2] );
1924 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc->lppos),
1925 nc32->lppos );
1926 SEGPTR_FREE( PTR_SEG_TO_LIN(nc->lppos) );
1928 SEGPTR_FREE(nc);
1930 break;
1931 case WM_NCCREATE:
1932 case WM_CREATE:
1934 CREATESTRUCT16 *cs = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(p16->lParam);
1935 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->lpszName) );
1936 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->lpszClass) );
1937 SEGPTR_FREE( cs );
1939 break;
1940 case WM_WINDOWPOSCHANGING:
1941 case WM_WINDOWPOSCHANGED:
1943 WINDOWPOS16 *wp = (WINDOWPOS16 *)PTR_SEG_TO_LIN(p16->lParam);
1944 p16->lParam = *(LPARAM *)(wp + 1);
1945 STRUCT32_WINDOWPOS16to32( wp, (WINDOWPOS *)p16->lParam );
1946 SEGPTR_FREE(wp);
1948 break;
1949 case WM_NOTIFY:
1950 UnMapLS(p16->lParam);
1951 break;
1952 case WM_GETDLGCODE:
1953 if (p16->lParam)
1955 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(p16->lParam);
1956 MSGPARAM16 msgp16;
1957 msgp16.wParam=msg16->wParam;
1958 msgp16.lParam=msg16->lParam;
1959 WINPROC_UnmapMsg32ATo16(((LPMSG)lParam)->hwnd, ((LPMSG)lParam)->message,
1960 ((LPMSG)lParam)->wParam, ((LPMSG)lParam)->lParam,
1961 &msgp16 );
1962 SEGPTR_FREE(msg16);
1964 break;
1969 /**********************************************************************
1970 * WINPROC_MapMsg32WTo16
1972 * Map a message from 32-bit Unicode to 16-bit.
1973 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1975 INT WINPROC_MapMsg32WTo16( HWND hwnd, UINT msg32, WPARAM wParam32,
1976 UINT16 *pmsg16, WPARAM16 *pwparam16,
1977 LPARAM *plparam )
1979 switch(msg32)
1981 case LB_ADDSTRING:
1982 case LB_FINDSTRING:
1983 case LB_FINDSTRINGEXACT:
1984 case LB_INSERTSTRING:
1985 case LB_SELECTSTRING:
1986 case LB_DIR:
1987 case LB_ADDFILE:
1989 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
1990 if (!str) return -1;
1991 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1992 *plparam = (LPARAM)SEGPTR_GET(str);
1994 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
1995 return 1;
1997 case CB_ADDSTRING:
1998 case CB_FINDSTRING:
1999 case CB_FINDSTRINGEXACT:
2000 case CB_INSERTSTRING:
2001 case CB_SELECTSTRING:
2002 case CB_DIR:
2004 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
2005 if (!str) return -1;
2006 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2007 *plparam = (LPARAM)SEGPTR_GET(str);
2009 *pmsg16 = (UINT16)msg32 + (CB_ADDSTRING16 - CB_ADDSTRING);
2010 return 1;
2012 case WM_NCCREATE:
2013 case WM_CREATE:
2015 CREATESTRUCT16 *cs;
2016 CREATESTRUCTW *cs32 = (CREATESTRUCTW *)*plparam;
2017 LPSTR name, cls;
2019 if (!(cs = SEGPTR_NEW(CREATESTRUCT16))) return -1;
2020 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA *)cs32, cs );
2021 name = SEGPTR_STRDUP_WtoA( cs32->lpszName );
2022 cls = SEGPTR_STRDUP_WtoA( cs32->lpszClass );
2023 cs->lpszName = SEGPTR_GET(name);
2024 cs->lpszClass = SEGPTR_GET(cls);
2025 *pmsg16 = (UINT16)msg32;
2026 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2027 *plparam = (LPARAM)SEGPTR_GET(cs);
2029 return 1;
2030 case WM_MDICREATE:
2032 MDICREATESTRUCT16 *cs;
2033 MDICREATESTRUCTW *cs32 = (MDICREATESTRUCTW *)*plparam;
2034 LPSTR name, cls;
2036 if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1;
2037 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA *)cs32, cs );
2038 name = SEGPTR_STRDUP_WtoA( cs32->szTitle );
2039 cls = SEGPTR_STRDUP_WtoA( cs32->szClass );
2040 cs->szTitle = SEGPTR_GET(name);
2041 cs->szClass = SEGPTR_GET(cls);
2042 *pmsg16 = (UINT16)msg32;
2043 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2044 *plparam = (LPARAM)SEGPTR_GET(cs);
2046 return 1;
2047 case WM_SETTEXT:
2049 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
2050 if (!str) return -1;
2051 *pmsg16 = (UINT16)msg32;
2052 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2053 *plparam = (LPARAM)SEGPTR_GET(str);
2055 return 1;
2056 default: /* No Unicode translation needed */
2057 return WINPROC_MapMsg32ATo16( hwnd, msg32, wParam32, pmsg16,
2058 pwparam16, plparam );
2063 /**********************************************************************
2064 * WINPROC_UnmapMsg32WTo16
2066 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2068 void WINPROC_UnmapMsg32WTo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
2069 MSGPARAM16* p16 )
2071 switch(msg)
2073 case WM_GETTEXT:
2075 LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam);
2076 p16->lParam = *((LPARAM *)str - 1);
2077 lstrcpyAtoW( (LPWSTR)(p16->lParam), str );
2078 SEGPTR_FREE( (LPARAM *)str - 1 );
2080 break;
2081 default:
2082 WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, p16 );
2083 break;
2088 /**********************************************************************
2089 * WINPROC_CallProc32ATo32W
2091 * Call a window procedure, translating args from Ansi to Unicode.
2093 static LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd,
2094 UINT msg, WPARAM wParam,
2095 LPARAM lParam )
2097 LRESULT result;
2099 if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0;
2100 result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2101 WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
2102 return result;
2106 /**********************************************************************
2107 * WINPROC_CallProc32WTo32A
2109 * Call a window procedure, translating args from Unicode to Ansi.
2111 static LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd,
2112 UINT msg, WPARAM wParam,
2113 LPARAM lParam )
2115 LRESULT result;
2117 if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0;
2118 result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2119 WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
2120 return result;
2124 /**********************************************************************
2125 * WINPROC_CallProc16To32A
2127 * Call a 32-bit window procedure, translating the 16-bit args.
2129 LRESULT WINPROC_CallProc16To32A( HWND16 hwnd, UINT16 msg,
2130 WPARAM16 wParam, LPARAM lParam,
2131 WNDPROC func )
2133 LRESULT result;
2134 UINT msg32;
2135 WPARAM wParam32;
2137 if (WINPROC_MapMsg16To32A( msg, wParam, &msg32, &wParam32, &lParam ) == -1)
2138 return 0;
2139 result = WINPROC_CallWndProc( func, hwnd, msg32, wParam32, lParam );
2140 return WINPROC_UnmapMsg16To32A( hwnd, msg32, wParam32, lParam, result );
2144 /**********************************************************************
2145 * WINPROC_CallProc16To32W
2147 * Call a 32-bit window procedure, translating the 16-bit args.
2149 LRESULT WINPROC_CallProc16To32W( HWND16 hwnd, UINT16 msg,
2150 WPARAM16 wParam, LPARAM lParam,
2151 WNDPROC func )
2153 LRESULT result;
2154 UINT msg32;
2155 WPARAM wParam32;
2157 if (WINPROC_MapMsg16To32W( hwnd, msg, wParam, &msg32, &wParam32, &lParam ) == -1)
2158 return 0;
2159 result = WINPROC_CallWndProc( func, hwnd, msg32, wParam32, lParam );
2160 return WINPROC_UnmapMsg16To32W( hwnd, msg32, wParam32, lParam, result );
2164 /**********************************************************************
2165 * WINPROC_CallProc32ATo16
2167 * Call a 16-bit window procedure, translating the 32-bit args.
2169 static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND hwnd,
2170 UINT msg, WPARAM wParam,
2171 LPARAM lParam )
2173 UINT16 msg16;
2174 MSGPARAM16 mp16;
2176 mp16.lParam = lParam;
2177 if (WINPROC_MapMsg32ATo16( hwnd, msg, wParam,
2178 &msg16, &mp16.wParam, &mp16.lParam ) == -1)
2179 return 0;
2180 mp16.lResult = Callbacks->CallWndProc( func, hwnd, msg16,
2181 mp16.wParam, mp16.lParam );
2182 WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, &mp16 );
2183 return mp16.lResult;
2187 /**********************************************************************
2188 * WINPROC_CallProc32WTo16
2190 * Call a 16-bit window procedure, translating the 32-bit args.
2192 static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND hwnd,
2193 UINT msg, WPARAM wParam,
2194 LPARAM lParam )
2196 UINT16 msg16;
2197 MSGPARAM16 mp16;
2199 mp16.lParam = lParam;
2200 if (WINPROC_MapMsg32WTo16( hwnd, msg, wParam, &msg16, &mp16.wParam,
2201 &mp16.lParam ) == -1)
2202 return 0;
2203 mp16.lResult = Callbacks->CallWndProc( func, hwnd, msg16,
2204 mp16.wParam, mp16.lParam );
2205 WINPROC_UnmapMsg32WTo16( hwnd, msg, wParam, lParam, &mp16 );
2206 return mp16.lResult;
2210 /**********************************************************************
2211 * CallWindowProc16 (USER.122)
2213 LRESULT WINAPI CallWindowProc16( WNDPROC16 func, HWND16 hwnd, UINT16 msg,
2214 WPARAM16 wParam, LPARAM lParam )
2216 WINDOWPROC *proc = WINPROC_GetPtr( func );
2218 if (!proc)
2219 return Callbacks->CallWndProc( func, hwnd, msg, wParam, lParam );
2221 #if testing
2222 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_16 );
2223 return Callbacks->CallWndProc( func, hwnd, msg, wParam, lParam );
2224 #endif
2226 switch(proc->type)
2228 case WIN_PROC_16:
2229 if (!proc->thunk.t_from32.proc) return 0;
2230 return Callbacks->CallWndProc( proc->thunk.t_from32.proc,
2231 hwnd, msg, wParam, lParam );
2232 case WIN_PROC_32A:
2233 if (!proc->thunk.t_from16.proc) return 0;
2234 return WINPROC_CallProc16To32A( hwnd, msg, wParam, lParam,
2235 proc->thunk.t_from16.proc );
2236 case WIN_PROC_32W:
2237 if (!proc->thunk.t_from16.proc) return 0;
2238 return WINPROC_CallProc16To32W( hwnd, msg, wParam, lParam,
2239 proc->thunk.t_from16.proc );
2240 default:
2241 WARN( relay, "Invalid proc %p\n", proc );
2242 return 0;
2247 /**********************************************************************
2248 * CallWindowProc32A (USER32.18)
2250 * The CallWindowProc() function invokes the windows procedure _func_,
2251 * with _hwnd_ as the target window, the message specified by _msg_, and
2252 * the message parameters _wParam_ and _lParam_.
2254 * Some kinds of argument conversion may be done, I'm not sure what.
2256 * CallWindowProc() may be used for windows subclassing. Use
2257 * SetWindowLong() to set a new windows procedure for windows of the
2258 * subclass, and handle subclassed messages in the new windows
2259 * procedure. The new windows procedure may then use CallWindowProc()
2260 * with _func_ set to the parent class's windows procedure to dispatch
2261 * the message to the superclass.
2263 * RETURNS
2265 * The return value is message dependent.
2267 * CONFORMANCE
2269 * ECMA-234, Win32
2271 LRESULT WINAPI CallWindowProcA(
2272 WNDPROC func, /* window procedure */
2273 HWND hwnd, /* target window */
2274 UINT msg, /* message */
2275 WPARAM wParam, /* message dependent parameter */
2276 LPARAM lParam /* message dependent parameter */
2278 WINDOWPROC *proc = WINPROC_GetPtr( (WNDPROC16)func );
2280 if (!proc) return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2282 #if testing
2283 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_32A );
2284 return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2285 #endif
2287 switch(proc->type)
2289 case WIN_PROC_16:
2290 if (!proc->thunk.t_from32.proc) return 0;
2291 return WINPROC_CallProc32ATo16( proc->thunk.t_from32.proc,
2292 hwnd, msg, wParam, lParam );
2293 case WIN_PROC_32A:
2294 if (!proc->thunk.t_from16.proc) return 0;
2295 return WINPROC_CallWndProc( proc->thunk.t_from16.proc,
2296 hwnd, msg, wParam, lParam );
2297 case WIN_PROC_32W:
2298 if (!proc->thunk.t_from16.proc) return 0;
2299 return WINPROC_CallProc32ATo32W( proc->thunk.t_from16.proc,
2300 hwnd, msg, wParam, lParam );
2301 default:
2302 WARN( relay, "Invalid proc %p\n", proc );
2303 return 0;
2308 /**********************************************************************
2309 * CallWindowProc32W (USER32.19)
2311 LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg,
2312 WPARAM wParam, LPARAM lParam )
2314 WINDOWPROC *proc = WINPROC_GetPtr( (WNDPROC16)func );
2316 if (!proc) return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2318 #if testing
2319 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_32W );
2320 return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2321 #endif
2323 switch(proc->type)
2325 case WIN_PROC_16:
2326 if (!proc->thunk.t_from32.proc) return 0;
2327 return WINPROC_CallProc32WTo16( proc->thunk.t_from32.proc,
2328 hwnd, msg, wParam, lParam );
2329 case WIN_PROC_32A:
2330 if (!proc->thunk.t_from16.proc) return 0;
2331 return WINPROC_CallProc32WTo32A( proc->thunk.t_from16.proc,
2332 hwnd, msg, wParam, lParam );
2333 case WIN_PROC_32W:
2334 if (!proc->thunk.t_from16.proc) return 0;
2335 return WINPROC_CallWndProc( proc->thunk.t_from16.proc,
2336 hwnd, msg, wParam, lParam );
2337 default:
2338 WARN( relay, "Invalid proc %p\n", proc );
2339 return 0;