Fix a couple of 64bit platform problems and speed up compilation. See
[wine/multimedia.git] / windows / winproc.c
blob396c9c18e0f559e1fcd2d03857614d4b978cba8f
1 /*
2 * Window procedure callbacks
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1996 Alexandre Julliard
6 */
8 #include "windows.h"
9 #include "callback.h"
10 #include "heap.h"
11 #include "selectors.h"
12 #include "struct32.h"
13 #include "win.h"
14 #include "winproc.h"
15 #include "debug.h"
16 #include "spy.h"
17 #include "commctrl.h"
18 #include "task.h"
19 #include "thread.h"
21 /* Window procedure 16-to-32-bit thunk,
22 * see BuildSpec16Files() in tools/build.c */
24 typedef struct
26 BYTE popl_eax; /* popl %eax (return address) */
27 BYTE pushl_func; /* pushl $proc */
28 WNDPROC32 proc WINE_PACKED;
29 BYTE pushl_eax; /* pushl %eax */
30 WORD pushw_bp WINE_PACKED; /* pushw %bp */
31 BYTE pushl_thunk; /* pushl $thunkfrom16 */
32 void (*thunk32)() WINE_PACKED;
33 BYTE lcall; /* lcall cs:relay */
34 void (*relay)() WINE_PACKED; /* WINPROC_CallProc16To32A/W() */
35 WORD cs WINE_PACKED;
36 } WINPROC_THUNK_FROM16;
38 /* Window procedure 32-to-16-bit thunk,
39 * see BuildSpec32Files() in tools/build.c */
41 typedef struct
43 BYTE popl_eax; /* popl %eax (return address) */
44 BYTE pushl_func; /* pushl $proc */
45 WNDPROC16 proc WINE_PACKED;
46 BYTE pushl_eax; /* pushl %eax */
47 BYTE jmp; /* jmp relay (relative jump)*/
48 void (*relay)() WINE_PACKED; /* WINPROC_CallProc32ATo16() */
49 } WINPROC_THUNK_FROM32;
51 /* Simple jmp to call 32-bit procedure directly */
52 typedef struct
54 BYTE jmp; /* jmp proc (relative jump) */
55 WNDPROC32 proc WINE_PACKED;
56 } WINPROC_JUMP;
58 typedef union
60 WINPROC_THUNK_FROM16 t_from16;
61 WINPROC_THUNK_FROM32 t_from32;
62 } WINPROC_THUNK;
64 typedef struct tagWINDOWPROC
66 WINPROC_THUNK thunk; /* Thunk */
67 WINPROC_JUMP jmp; /* Jump */
68 struct tagWINDOWPROC *next; /* Next window proc */
69 UINT32 magic; /* Magic number */
70 WINDOWPROCTYPE type; /* Function type */
71 WINDOWPROCUSER user; /* Function user */
72 } WINDOWPROC;
74 #define WINPROC_MAGIC ('W' | ('P' << 8) | ('R' << 16) | ('C' << 24))
76 #define WINPROC_THUNKPROC(pproc) \
77 (((pproc)->type == WIN_PROC_16) ? \
78 (WNDPROC16)((pproc)->thunk.t_from32.proc) : \
79 (WNDPROC16)((pproc)->thunk.t_from16.proc))
81 static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND32 hwnd,
82 UINT32 msg, WPARAM32 wParam,
83 LPARAM lParam );
84 static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND32 hwnd,
85 UINT32 msg, WPARAM32 wParam,
86 LPARAM lParam );
87 static LRESULT WINPROC_CallProc16To32A( HWND16 hwnd, UINT16 msg,
88 WPARAM16 wParam, LPARAM lParam,
89 WNDPROC32 func );
90 static LRESULT WINPROC_CallProc16To32W( HWND16 hwnd, UINT16 msg,
91 WPARAM16 wParam, LPARAM lParam,
92 WNDPROC32 func );
94 static HANDLE32 WinProcHeap;
97 /**********************************************************************
98 * WINPROC_Init
100 BOOL32 WINPROC_Init(void)
102 WinProcHeap = HeapCreate( HEAP_WINE_SEGPTR | HEAP_WINE_CODESEG, 0, 0 );
103 if (!WinProcHeap)
105 WARN(relay, "Unable to create winproc heap\n" );
106 return FALSE;
108 return TRUE;
112 /**********************************************************************
113 * WINPROC_CallWndProc32
115 * Call a 32-bit WndProc.
117 static LRESULT WINPROC_CallWndProc32( WNDPROC32 proc, HWND32 hwnd, UINT32 msg,
118 WPARAM32 wParam, LPARAM lParam )
120 TRACE(relay, "(wndproc=%p,hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n",
121 proc, hwnd, SPY_GetMsgName(msg), wParam, lParam );
122 return proc( hwnd, msg, wParam, lParam );
126 /**********************************************************************
127 * WINPROC_GetPtr
129 * Return a pointer to the win proc.
131 static WINDOWPROC *WINPROC_GetPtr( WNDPROC16 handle )
133 BYTE *ptr;
134 WINDOWPROC *proc;
136 /* Check for a linear pointer */
138 if (HEAP_IsInsideHeap( WinProcHeap, 0, (LPVOID)handle ))
140 ptr = (BYTE *)handle;
141 /* First check if it is the jmp address */
142 if (*ptr == 0xe9 /* jmp */) ptr -= (int)&((WINDOWPROC *)0)->jmp -
143 (int)&((WINDOWPROC *)0)->thunk;
144 /* Now it must be the thunk address */
145 if (*ptr == 0x58 /* popl eax */) ptr -= (int)&((WINDOWPROC *)0)->thunk;
146 /* Now we have a pointer to the WINDOWPROC struct */
147 if (((WINDOWPROC *)ptr)->magic == WINPROC_MAGIC)
148 return (WINDOWPROC *)ptr;
151 /* Check for a segmented pointer */
153 if (!IsBadReadPtr16((SEGPTR)handle,sizeof(WINDOWPROC)-sizeof(proc->thunk)))
155 ptr = (BYTE *)PTR_SEG_TO_LIN(handle);
156 if (!HEAP_IsInsideHeap( WinProcHeap, 0, ptr )) return NULL;
157 /* It must be the thunk address */
158 if (*ptr == 0x58 /* popl eax */) ptr -= (int)&((WINDOWPROC *)0)->thunk;
159 /* Now we have a pointer to the WINDOWPROC struct */
160 if (((WINDOWPROC *)ptr)->magic == WINPROC_MAGIC)
161 return (WINDOWPROC *)ptr;
164 return NULL;
168 /**********************************************************************
169 * WINPROC_AllocWinProc
171 * Allocate a new window procedure.
173 static WINDOWPROC *WINPROC_AllocWinProc( WNDPROC16 func, WINDOWPROCTYPE type,
174 WINDOWPROCUSER user )
176 WINDOWPROC *proc, *oldproc;
178 /* Allocate a window procedure */
180 if (!(proc = HeapAlloc( WinProcHeap, 0, sizeof(WINDOWPROC) ))) return 0;
182 /* Check if the function is already a win proc */
184 if ((oldproc = WINPROC_GetPtr( func )))
186 *proc = *oldproc;
188 else
190 switch(type)
192 case WIN_PROC_16:
193 proc->thunk.t_from32.popl_eax = 0x58; /* popl %eax */
194 proc->thunk.t_from32.pushl_func = 0x68; /* pushl $proc */
195 proc->thunk.t_from32.proc = func;
196 proc->thunk.t_from32.pushl_eax = 0x50; /* pushl %eax */
197 proc->thunk.t_from32.jmp = 0xe9; /* jmp relay*/
198 proc->thunk.t_from32.relay = /* relative jump */
199 (void(*)())((DWORD)WINPROC_CallProc32ATo16 -
200 (DWORD)(&proc->thunk.t_from32.relay + 1));
201 break;
202 case WIN_PROC_32A:
203 case WIN_PROC_32W:
204 proc->thunk.t_from16.popl_eax = 0x58; /* popl %eax */
205 proc->thunk.t_from16.pushl_func = 0x68; /* pushl $proc */
206 proc->thunk.t_from16.proc = (FARPROC32)func;
207 proc->thunk.t_from16.pushl_eax = 0x50; /* pushl %eax */
208 proc->thunk.t_from16.pushw_bp = 0x5566; /* pushw %bp */
209 proc->thunk.t_from16.pushl_thunk = 0x68; /* pushl $thunkfrom16 */
210 proc->thunk.t_from16.thunk32 = (type == WIN_PROC_32A) ?
211 (void(*)())WINPROC_CallProc16To32A :
212 (void(*)())WINPROC_CallProc16To32W;
213 proc->thunk.t_from16.lcall = 0x9a; /* lcall cs:relay */
214 proc->thunk.t_from16.relay = (void*)Callbacks->CallFrom16WndProc;
215 GET_CS(proc->thunk.t_from16.cs);
216 proc->jmp.jmp = 0xe9;
217 /* Fixup relative jump */
218 proc->jmp.proc = (WNDPROC32)((DWORD)func -
219 (DWORD)(&proc->jmp.proc + 1));
220 break;
221 default:
222 /* Should not happen */
223 break;
225 proc->magic = WINPROC_MAGIC;
226 proc->type = type;
227 proc->user = user;
229 proc->next = NULL;
230 TRACE(win, "(%08x,%d): returning %08x\n",
231 (UINT32)func, type, (UINT32)proc );
232 return proc;
236 /**********************************************************************
237 * WINPROC_GetProc
239 * Get a window procedure pointer that can be passed to the Windows program.
241 WNDPROC16 WINPROC_GetProc( HWINDOWPROC proc, WINDOWPROCTYPE type )
243 if (!proc) return NULL;
244 if (type == WIN_PROC_16) /* We want a 16:16 address */
246 if (((WINDOWPROC *)proc)->type == WIN_PROC_16)
247 return ((WINDOWPROC *)proc)->thunk.t_from32.proc;
248 else
249 return (WNDPROC16)HEAP_GetSegptr( WinProcHeap, 0,
250 &((WINDOWPROC *)proc)->thunk );
252 else /* We want a 32-bit address */
254 if (((WINDOWPROC *)proc)->type == WIN_PROC_16)
255 return (WNDPROC16)&((WINDOWPROC *)proc)->thunk;
256 else if (type != ((WINDOWPROC *)proc)->type)
257 /* Have to return the jmp address if types don't match */
258 return (WNDPROC16)&((WINDOWPROC *)proc)->jmp;
259 else
260 /* Some Win16 programs want to get back the proc they set */
261 return (WNDPROC16)((WINDOWPROC *)proc)->thunk.t_from16.proc;
266 /**********************************************************************
267 * WINPROC_SetProc
269 * Set the window procedure for a window or class. There are
270 * three tree classes of winproc callbacks:
272 * 1) class -> wp - not subclassed
273 * class -> wp -> wp -> wp -> wp - SetClassLong()
274 * / /
275 * 2) window -' / - not subclassed
276 * window -> wp -> wp ' - SetWindowLong()
278 * 3) timer -> wp - SetTimer()
280 * Initially, winproc of the window points to the current winproc
281 * thunk of its class. Subclassing prepends a new thunk to the
282 * window winproc chain at the head of the list. Thus, window thunk
283 * list includes class thunks and the latter are preserved when the
284 * window is destroyed.
287 BOOL32 WINPROC_SetProc( HWINDOWPROC *pFirst, WNDPROC16 func,
288 WINDOWPROCTYPE type, WINDOWPROCUSER user )
290 BOOL32 bRecycle = FALSE;
291 WINDOWPROC *proc, **ppPrev;
293 /* Check if function is already in the list */
295 ppPrev = (WINDOWPROC **)pFirst;
296 proc = WINPROC_GetPtr( func );
297 while (*ppPrev)
299 if (proc)
301 if (*ppPrev == proc)
303 if ((*ppPrev)->user != user)
305 /* terminal thunk is being restored */
307 WINPROC_FreeProc( *pFirst, (*ppPrev)->user );
308 *(WINDOWPROC **)pFirst = *ppPrev;
309 return TRUE;
311 bRecycle = TRUE;
312 break;
315 else
317 if (((*ppPrev)->type == type) &&
318 (func == WINPROC_THUNKPROC(*ppPrev)))
320 bRecycle = TRUE;
321 break;
325 /* WPF_CLASS thunk terminates window thunk list */
326 if ((*ppPrev)->user != user) break;
327 ppPrev = &(*ppPrev)->next;
330 if (bRecycle)
332 /* Extract this thunk from the list */
333 proc = *ppPrev;
334 *ppPrev = proc->next;
336 else /* Allocate a new one */
338 if (proc) /* Was already a win proc */
340 type = proc->type;
341 func = WINPROC_THUNKPROC(proc);
343 proc = WINPROC_AllocWinProc( func, type, user );
344 if (!proc) return FALSE;
347 /* Add the win proc at the head of the list */
349 TRACE(win, "(%08x,%08x,%d): res=%08x\n",
350 (UINT32)*pFirst, (UINT32)func, type, (UINT32)proc );
351 proc->next = *(WINDOWPROC **)pFirst;
352 *(WINDOWPROC **)pFirst = proc;
353 return TRUE;
357 /**********************************************************************
358 * WINPROC_FreeProc
360 * Free a list of win procs.
362 void WINPROC_FreeProc( HWINDOWPROC proc, WINDOWPROCUSER user )
364 while (proc)
366 WINDOWPROC *next = ((WINDOWPROC *)proc)->next;
367 if (((WINDOWPROC *)proc)->user != user) break;
368 TRACE(win, "freeing %08x\n", (UINT32)proc);
369 HeapFree( WinProcHeap, 0, proc );
370 proc = next;
375 /**********************************************************************
376 * WINPROC_GetProcType
378 * Return the window procedure type.
380 WINDOWPROCTYPE WINPROC_GetProcType( HWINDOWPROC proc )
382 if (!proc ||
383 (((WINDOWPROC *)proc)->magic != WINPROC_MAGIC))
384 return WIN_PROC_INVALID;
385 return ((WINDOWPROC *)proc)->type;
387 /**********************************************************************
388 * WINPROC_TestCBForStr
390 * Return TRUE if the lparam is a string
392 BOOL32 WINPROC_TestCBForStr ( HWND32 hwnd )
393 { WND * wnd = WIN_FindWndPtr(hwnd);
394 return ( !(LOWORD(wnd->dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
395 (LOWORD(wnd->dwStyle) & CBS_HASSTRINGS) );
397 /**********************************************************************
398 * WINPROC_TestLBForStr
400 * Return TRUE if the lparam is a string
402 BOOL32 WINPROC_TestLBForStr ( HWND32 hwnd )
403 { WND * wnd = WIN_FindWndPtr(hwnd);
404 return ( !(LOWORD(wnd->dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
405 (LOWORD(wnd->dwStyle) & LBS_HASSTRINGS) );
407 /**********************************************************************
408 * WINPROC_MapMsg32ATo32W
410 * Map a message from Ansi to Unicode.
411 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
413 * FIXME:
414 * WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR
416 * FIXME:
417 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
418 * the first four bytes are the handle of the icon
419 * when the WM_SETTEXT message has been used to set the icon
421 INT32 WINPROC_MapMsg32ATo32W( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM *plparam )
423 switch(msg)
425 case WM_GETTEXT:
427 LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0,
428 wParam * sizeof(WCHAR) + sizeof(LPARAM) );
429 if (!ptr) return -1;
430 *ptr++ = *plparam; /* Store previous lParam */
431 *plparam = (LPARAM)ptr;
433 return 1;
435 case WM_SETTEXT:
436 case CB_DIR32:
437 case CB_FINDSTRING32:
438 case CB_FINDSTRINGEXACT32:
439 case CB_SELECTSTRING32:
440 case LB_DIR32:
441 case LB_ADDFILE32:
442 case LB_FINDSTRING32:
443 case LB_SELECTSTRING32:
444 case EM_REPLACESEL32:
445 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
446 return (*plparam ? 1 : -1);
448 case WM_NCCREATE:
449 case WM_CREATE:
451 CREATESTRUCT32W *cs = (CREATESTRUCT32W *)HeapAlloc( SystemHeap, 0,
452 sizeof(*cs) );
453 if (!cs) return -1;
454 *cs = *(CREATESTRUCT32W *)*plparam;
455 if (HIWORD(cs->lpszName))
456 cs->lpszName = HEAP_strdupAtoW( SystemHeap, 0,
457 (LPCSTR)cs->lpszName );
458 if (HIWORD(cs->lpszClass))
459 cs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0,
460 (LPCSTR)cs->lpszClass );
461 *plparam = (LPARAM)cs;
463 return 1;
464 case WM_MDICREATE:
466 MDICREATESTRUCT32W *cs =
467 (MDICREATESTRUCT32W *)HeapAlloc( SystemHeap, 0, sizeof(*cs) );
468 if (!cs) return -1;
469 *cs = *(MDICREATESTRUCT32W *)*plparam;
470 if (HIWORD(cs->szClass))
471 cs->szClass = HEAP_strdupAtoW( SystemHeap, 0,
472 (LPCSTR)cs->szClass );
473 if (HIWORD(cs->szTitle))
474 cs->szTitle = HEAP_strdupAtoW( SystemHeap, 0,
475 (LPCSTR)cs->szTitle );
476 *plparam = (LPARAM)cs;
478 return 1;
480 /* Listbox */
481 case LB_ADDSTRING32:
482 case LB_INSERTSTRING32:
483 if ( WINPROC_TestLBForStr( hwnd ))
484 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
485 return (*plparam ? 1 : -1);
487 case LB_GETTEXT32: /* fixme: fixed sized buffer */
488 { if ( WINPROC_TestLBForStr( hwnd ))
489 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
490 if (!ptr) return -1;
491 *ptr++ = *plparam; /* Store previous lParam */
492 *plparam = (LPARAM)ptr;
495 return 1;
497 /* Combobox */
498 case CB_ADDSTRING32:
499 case CB_INSERTSTRING32:
500 if ( WINPROC_TestCBForStr( hwnd ))
501 *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam );
502 return (*plparam ? 1 : -1);
504 case CB_GETLBTEXT32: /* fixme: fixed sized buffer */
505 { if ( WINPROC_TestCBForStr( hwnd ))
506 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
507 if (!ptr) return -1;
508 *ptr++ = *plparam; /* Store previous lParam */
509 *plparam = (LPARAM)ptr;
512 return 1;
514 /* Multiline edit */
515 case EM_GETLINE32:
516 { WORD len = (WORD)*plparam;
517 LPARAM *ptr = (LPARAM *) HEAP_xalloc( SystemHeap, 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
518 if (!ptr) return -1;
519 *ptr++ = *plparam; /* Store previous lParam */
520 (WORD)*ptr = len; /* Store the lenght */
521 *plparam = (LPARAM)ptr;
523 return 1;
525 case WM_ASKCBFORMATNAME:
526 case WM_DEVMODECHANGE:
527 case WM_PAINTCLIPBOARD:
528 case WM_SIZECLIPBOARD:
529 case WM_WININICHANGE:
530 case EM_SETPASSWORDCHAR32:
531 FIXME(msg, "message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg );
532 return -1;
533 default: /* No translation needed */
534 return 0;
539 /**********************************************************************
540 * WINPROC_UnmapMsg32ATo32W
542 * Unmap a message that was mapped from Ansi to Unicode.
544 void WINPROC_UnmapMsg32ATo32W( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam )
546 switch(msg)
548 case WM_GETTEXT:
550 LPARAM *ptr = (LPARAM *)lParam - 1;
551 lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam );
552 HeapFree( SystemHeap, 0, ptr );
554 break;
556 case WM_NCCREATE:
557 case WM_CREATE:
559 CREATESTRUCT32W *cs = (CREATESTRUCT32W *)lParam;
560 if (HIWORD(cs->lpszName))
561 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
562 if (HIWORD(cs->lpszClass))
563 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
564 HeapFree( SystemHeap, 0, cs );
566 break;
568 case WM_MDICREATE:
570 MDICREATESTRUCT32W *cs = (MDICREATESTRUCT32W *)lParam;
571 if (HIWORD(cs->szTitle))
572 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
573 if (HIWORD(cs->szClass))
574 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
575 HeapFree( SystemHeap, 0, cs );
577 break;
579 case WM_SETTEXT:
580 case CB_DIR32:
581 case CB_FINDSTRING32:
582 case CB_FINDSTRINGEXACT32:
583 case CB_SELECTSTRING32:
584 case LB_DIR32:
585 case LB_ADDFILE32:
586 case LB_FINDSTRING32:
587 case LB_SELECTSTRING32:
588 case EM_REPLACESEL32:
589 HeapFree( SystemHeap, 0, (void *)lParam );
590 break;
592 /* Listbox */
593 case LB_ADDSTRING32:
594 case LB_INSERTSTRING32:
595 if ( WINPROC_TestLBForStr( hwnd ))
596 HeapFree( SystemHeap, 0, (void *)lParam );
597 break;
599 case LB_GETTEXT32:
600 { if ( WINPROC_TestLBForStr( hwnd ))
601 { LPARAM *ptr = (LPARAM *)lParam - 1;
602 lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
603 HeapFree( SystemHeap, 0, ptr );
606 break;
608 /* Combobox */
609 case CB_ADDSTRING32:
610 case CB_INSERTSTRING32:
611 if ( WINPROC_TestCBForStr( hwnd ))
612 HeapFree( SystemHeap, 0, (void *)lParam );
613 break;
615 case CB_GETLBTEXT32:
616 { if ( WINPROC_TestCBForStr( hwnd ))
617 { LPARAM *ptr = (LPARAM *)lParam - 1;
618 lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
619 HeapFree( SystemHeap, 0, ptr );
622 break;
624 /* Multiline edit */
625 case EM_GETLINE32:
626 { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lParam */
627 WORD len = *(WORD *) lParam;
628 lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len );
629 HeapFree( SystemHeap, 0, ptr );
631 break;
636 /**********************************************************************
637 * WINPROC_MapMsg32WTo32A
639 * Map a message from Unicode to Ansi.
640 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
642 INT32 WINPROC_MapMsg32WTo32A( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM *plparam )
643 { switch(msg)
645 case WM_GETTEXT:
647 LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0,
648 wParam + sizeof(LPARAM) );
649 if (!ptr) return -1;
650 *ptr++ = *plparam; /* Store previous lParam */
651 *plparam = (LPARAM)ptr;
653 return 1;
655 case WM_SETTEXT:
656 case CB_DIR32:
657 case CB_FINDSTRING32:
658 case CB_FINDSTRINGEXACT32:
659 case CB_SELECTSTRING32:
660 case LB_DIR32:
661 case LB_ADDFILE32:
662 case LB_FINDSTRING32:
663 case LB_SELECTSTRING32:
664 case EM_REPLACESEL32:
665 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
666 return (*plparam ? 1 : -1);
668 case WM_NCCREATE:
669 case WM_CREATE:
671 CREATESTRUCT32A *cs = (CREATESTRUCT32A *)HeapAlloc( SystemHeap, 0,
672 sizeof(*cs) );
673 if (!cs) return -1;
674 *cs = *(CREATESTRUCT32A *)*plparam;
675 if (HIWORD(cs->lpszName))
676 cs->lpszName = HEAP_strdupWtoA( SystemHeap, 0,
677 (LPCWSTR)cs->lpszName );
678 if (HIWORD(cs->lpszClass))
679 cs->lpszClass = HEAP_strdupWtoA( SystemHeap, 0,
680 (LPCWSTR)cs->lpszClass);
681 *plparam = (LPARAM)cs;
683 return 1;
684 case WM_MDICREATE:
686 MDICREATESTRUCT32A *cs =
687 (MDICREATESTRUCT32A *)HeapAlloc( SystemHeap, 0, sizeof(*cs) );
688 if (!cs) return -1;
689 *cs = *(MDICREATESTRUCT32A *)*plparam;
690 if (HIWORD(cs->szTitle))
691 cs->szTitle = HEAP_strdupWtoA( SystemHeap, 0,
692 (LPCWSTR)cs->szTitle );
693 if (HIWORD(cs->szClass))
694 cs->szClass = HEAP_strdupWtoA( SystemHeap, 0,
695 (LPCWSTR)cs->szClass );
696 *plparam = (LPARAM)cs;
698 return 1;
700 /* Listbox */
701 case LB_ADDSTRING32:
702 case LB_INSERTSTRING32:
703 if ( WINPROC_TestLBForStr( hwnd ))
704 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
705 return (*plparam ? 1 : -1);
707 case LB_GETTEXT32: /* fixme: fixed sized buffer */
708 { if ( WINPROC_TestLBForStr( hwnd ))
709 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 + sizeof(LPARAM) );
710 if (!ptr) return -1;
711 *ptr++ = *plparam; /* Store previous lParam */
712 *plparam = (LPARAM)ptr;
715 return 1;
717 /* Combobox */
718 case CB_ADDSTRING32:
719 case CB_INSERTSTRING32:
720 if ( WINPROC_TestCBForStr( hwnd ))
721 *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam );
722 return (*plparam ? 1 : -1);
724 case CB_GETLBTEXT32: /* fixme: fixed sized buffer */
725 { if ( WINPROC_TestCBForStr( hwnd ))
726 { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 + sizeof(LPARAM) );
727 if (!ptr) return -1;
728 *ptr++ = *plparam; /* Store previous lParam */
729 *plparam = (LPARAM)ptr;
732 return 1;
734 /* Multiline edit */
735 case EM_GETLINE32:
736 { WORD len = (WORD)*plparam;
737 LPARAM *ptr = (LPARAM *) HEAP_xalloc( SystemHeap, 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
738 if (!ptr) return -1;
739 *ptr++ = *plparam; /* Store previous lParam */
740 (WORD)*ptr = len; /* Store the lenght */
741 *plparam = (LPARAM)ptr;
743 return 1;
745 case WM_ASKCBFORMATNAME:
746 case WM_DEVMODECHANGE:
747 case WM_PAINTCLIPBOARD:
748 case WM_SIZECLIPBOARD:
749 case WM_WININICHANGE:
750 case EM_SETPASSWORDCHAR32:
751 FIXME(msg, "message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg );
752 return -1;
753 default: /* No translation needed */
754 return 0;
759 /**********************************************************************
760 * WINPROC_UnmapMsg32WTo32A
762 * Unmap a message that was mapped from Unicode to Ansi.
764 void WINPROC_UnmapMsg32WTo32A( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam )
766 switch(msg)
768 case WM_GETTEXT:
770 LPARAM *ptr = (LPARAM *)lParam - 1;
771 lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam );
772 HeapFree( SystemHeap, 0, ptr );
774 break;
776 case WM_SETTEXT:
777 case CB_DIR32:
778 case CB_FINDSTRING32:
779 case CB_FINDSTRINGEXACT32:
780 case CB_SELECTSTRING32:
781 case LB_DIR32:
782 case LB_ADDFILE32:
783 case LB_FINDSTRING32:
784 case LB_SELECTSTRING32:
785 case EM_REPLACESEL32:
786 HeapFree( SystemHeap, 0, (void *)lParam );
787 break;
789 case WM_NCCREATE:
790 case WM_CREATE:
792 CREATESTRUCT32A *cs = (CREATESTRUCT32A *)lParam;
793 if (HIWORD(cs->lpszName))
794 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
795 if (HIWORD(cs->lpszClass))
796 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
797 HeapFree( SystemHeap, 0, cs );
799 break;
801 case WM_MDICREATE:
803 MDICREATESTRUCT32A *cs = (MDICREATESTRUCT32A *)lParam;
804 if (HIWORD(cs->szTitle))
805 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
806 if (HIWORD(cs->szClass))
807 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
808 HeapFree( SystemHeap, 0, cs );
810 break;
812 /* Listbox */
813 case LB_ADDSTRING32:
814 case LB_INSERTSTRING32:
815 if ( WINPROC_TestLBForStr( hwnd ))
816 HeapFree( SystemHeap, 0, (void *)lParam );
817 break;
819 case LB_GETTEXT32:
820 { if ( WINPROC_TestLBForStr( hwnd ))
821 { LPARAM *ptr = (LPARAM *)lParam - 1;
822 lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
823 HeapFree( SystemHeap, 0, ptr );
826 break;
828 /* Combobox */
829 case CB_ADDSTRING32:
830 case CB_INSERTSTRING32:
831 if ( WINPROC_TestCBForStr( hwnd ))
832 HeapFree( SystemHeap, 0, (void *)lParam );
833 break;
835 case CB_GETLBTEXT32:
836 { if ( WINPROC_TestCBForStr( hwnd ))
837 { LPARAM *ptr = (LPARAM *)lParam - 1;
838 lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
839 HeapFree( SystemHeap, 0, ptr );
842 break;
844 /* Multiline edit */
845 case EM_GETLINE32:
846 { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lparam */
847 WORD len = *(WORD *)ptr;
848 lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
849 HeapFree( SystemHeap, 0, ptr );
851 break;
856 /**********************************************************************
857 * WINPROC_MapMsg16To32A
859 * Map a message from 16- to 32-bit Ansi.
860 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
862 INT32 WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT32 *pmsg32,
863 WPARAM32 *pwparam32, LPARAM *plparam )
865 *pmsg32 = (UINT32)msg16;
866 *pwparam32 = (WPARAM32)wParam16;
867 switch(msg16)
869 case WM_ACTIVATE:
870 case WM_CHARTOITEM:
871 case WM_COMMAND:
872 case WM_VKEYTOITEM:
873 *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
874 *plparam = (LPARAM)(HWND32)LOWORD(*plparam);
875 return 0;
876 case WM_HSCROLL:
877 case WM_VSCROLL:
878 *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
879 *plparam = (LPARAM)(HWND32)HIWORD(*plparam);
880 return 0;
881 case WM_CTLCOLOR:
882 if ( HIWORD(*plparam) > CTLCOLOR_STATIC ) return -1;
883 *pmsg32 = WM_CTLCOLORMSGBOX + HIWORD(*plparam);
884 *pwparam32 = (WPARAM32)(HDC32)wParam16;
885 *plparam = (LPARAM)(HWND32)LOWORD(*plparam);
886 return 0;
887 case WM_COMPAREITEM:
889 COMPAREITEMSTRUCT16* cis16 = (COMPAREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
890 COMPAREITEMSTRUCT32 *cis = (COMPAREITEMSTRUCT32 *)
891 HeapAlloc(SystemHeap, 0, sizeof(*cis));
892 if (!cis) return -1;
893 cis->CtlType = cis16->CtlType;
894 cis->CtlID = cis16->CtlID;
895 cis->hwndItem = cis16->hwndItem;
896 cis->itemID1 = cis16->itemID1;
897 cis->itemData1 = cis16->itemData1;
898 cis->itemID2 = cis16->itemID2;
899 cis->itemData2 = cis16->itemData2;
900 cis->dwLocaleId = 0; /* FIXME */
901 *plparam = (LPARAM)cis;
903 return 1;
904 case WM_DELETEITEM:
906 DELETEITEMSTRUCT16* dis16 = (DELETEITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
907 DELETEITEMSTRUCT32 *dis = (DELETEITEMSTRUCT32 *)
908 HeapAlloc(SystemHeap, 0, sizeof(*dis));
909 if (!dis) return -1;
910 dis->CtlType = dis16->CtlType;
911 dis->CtlID = dis16->CtlID;
912 dis->hwndItem = dis16->hwndItem;
913 dis->itemData = dis16->itemData;
914 *plparam = (LPARAM)dis;
916 return 1;
917 case WM_MEASUREITEM:
919 MEASUREITEMSTRUCT16* mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
920 MEASUREITEMSTRUCT32 *mis = (MEASUREITEMSTRUCT32 *)
921 HeapAlloc(SystemHeap, 0,
922 sizeof(*mis) + sizeof(LPARAM));
923 if (!mis) return -1;
924 mis->CtlType = mis16->CtlType;
925 mis->CtlID = mis16->CtlID;
926 mis->itemID = mis16->itemID;
927 mis->itemWidth = mis16->itemWidth;
928 mis->itemHeight = mis16->itemHeight;
929 mis->itemData = mis16->itemData;
930 *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */
931 *plparam = (LPARAM)mis;
933 return 1;
934 case WM_DRAWITEM:
936 DRAWITEMSTRUCT16* dis16 = (DRAWITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
937 DRAWITEMSTRUCT32 *dis = (DRAWITEMSTRUCT32*)HeapAlloc(SystemHeap, 0,
938 sizeof(*dis));
939 if (!dis) return -1;
940 dis->CtlType = dis16->CtlType;
941 dis->CtlID = dis16->CtlID;
942 dis->itemID = dis16->itemID;
943 dis->itemAction = dis16->itemAction;
944 dis->itemState = dis16->itemState;
945 dis->hwndItem = dis16->hwndItem;
946 dis->hDC = dis16->hDC;
947 dis->itemData = dis16->itemData;
948 CONV_RECT16TO32( &dis16->rcItem, &dis->rcItem );
949 *plparam = (LPARAM)dis;
951 return 1;
952 case WM_GETMINMAXINFO:
954 MINMAXINFO32 *mmi = (MINMAXINFO32 *)HeapAlloc( SystemHeap, 0,
955 sizeof(*mmi) + sizeof(LPARAM));
956 if (!mmi) return -1;
957 STRUCT32_MINMAXINFO16to32( (MINMAXINFO16*)PTR_SEG_TO_LIN(*plparam),
958 mmi );
959 *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */
960 *plparam = (LPARAM)mmi;
962 return 1;
963 case WM_GETTEXT:
964 case WM_SETTEXT:
965 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
966 return 0;
967 case WM_MDICREATE:
969 MDICREATESTRUCT16 *cs16 =
970 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
971 MDICREATESTRUCT32A *cs =
972 (MDICREATESTRUCT32A *)HeapAlloc( SystemHeap, 0,
973 sizeof(*cs) + sizeof(LPARAM) );
974 if (!cs) return -1;
975 STRUCT32_MDICREATESTRUCT16to32A( cs16, cs );
976 cs->szTitle = (LPCSTR)PTR_SEG_TO_LIN(cs16->szTitle);
977 cs->szClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->szClass);
978 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
979 *plparam = (LPARAM)cs;
981 return 1;
982 case WM_MDIGETACTIVE:
983 *plparam = (LPARAM)HeapAlloc( SystemHeap, 0, sizeof(BOOL32) );
984 *(BOOL32*)(*plparam) = 0;
985 return 1;
986 case WM_MDISETMENU:
987 if(wParam16==TRUE)
988 *pmsg32=WM_MDIREFRESHMENU;
989 *pwparam32 = (WPARAM32)(HMENU32)LOWORD(*plparam);
990 *plparam = (LPARAM)(HMENU32)HIWORD(*plparam);
991 return 0;
992 case WM_MENUCHAR:
993 case WM_MENUSELECT:
994 *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
995 *plparam = (LPARAM)(HMENU32)HIWORD(*plparam);
996 return 0;
997 case WM_MDIACTIVATE:
998 if( *plparam )
1000 *pwparam32 = (WPARAM32)(HWND32)HIWORD(*plparam);
1001 *plparam = (LPARAM)(HWND32)LOWORD(*plparam);
1003 else /* message sent to MDI client */
1004 *pwparam32 = wParam16;
1005 return 0;
1006 case WM_NCCALCSIZE:
1008 NCCALCSIZE_PARAMS16 *nc16;
1009 NCCALCSIZE_PARAMS32 *nc;
1011 nc = (NCCALCSIZE_PARAMS32 *)HeapAlloc( SystemHeap, 0,
1012 sizeof(*nc) + sizeof(LPARAM) );
1013 if (!nc) return -1;
1014 nc16 = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(*plparam);
1015 CONV_RECT16TO32( &nc16->rgrc[0], &nc->rgrc[0] );
1016 if (wParam16)
1018 nc->lppos = (WINDOWPOS32 *)HeapAlloc( SystemHeap, 0,
1019 sizeof(*nc->lppos) );
1020 CONV_RECT16TO32( &nc16->rgrc[1], &nc->rgrc[1] );
1021 CONV_RECT16TO32( &nc16->rgrc[2], &nc->rgrc[2] );
1022 if (nc->lppos) STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc16->lppos), nc->lppos );
1024 *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */
1025 *plparam = (LPARAM)nc;
1027 return 1;
1028 case WM_NCCREATE:
1029 case WM_CREATE:
1031 CREATESTRUCT16 *cs16 = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1032 CREATESTRUCT32A *cs = (CREATESTRUCT32A *)HeapAlloc( SystemHeap, 0,
1033 sizeof(*cs) + sizeof(LPARAM) );
1034 if (!cs) return -1;
1035 STRUCT32_CREATESTRUCT16to32A( cs16, cs );
1036 cs->lpszName = (LPCSTR)PTR_SEG_TO_LIN(cs16->lpszName);
1037 cs->lpszClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->lpszClass);
1038 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1039 *plparam = (LPARAM)cs;
1041 return 1;
1042 case WM_PARENTNOTIFY:
1043 if ((wParam16 == WM_CREATE) || (wParam16 == WM_DESTROY))
1045 *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
1046 *plparam = (LPARAM)(HWND32)LOWORD(*plparam);
1048 return 0;
1049 case WM_WINDOWPOSCHANGING:
1050 case WM_WINDOWPOSCHANGED:
1052 WINDOWPOS32 *wp = (WINDOWPOS32 *)HeapAlloc( SystemHeap, 0,
1053 sizeof(*wp) + sizeof(LPARAM) );
1054 if (!wp) return -1;
1055 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(*plparam),
1056 wp );
1057 *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */
1058 *plparam = (LPARAM)wp;
1060 return 1;
1061 case WM_GETDLGCODE:
1062 if (*plparam)
1064 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(*plparam);
1065 LPMSG32 msg32 = (LPMSG32)HeapAlloc( SystemHeap, 0, sizeof(MSG32) );
1067 if (!msg32) return -1;
1068 msg32->hwnd = msg16->hwnd;
1069 msg32->lParam = msg16->lParam;
1070 msg32->time = msg16->time;
1071 CONV_POINT16TO32(&msg16->pt,&msg32->pt);
1072 /* this is right, right? */
1073 if (WINPROC_MapMsg16To32A(msg16->message,msg16->wParam,
1074 &msg32->message,&msg32->wParam,
1075 &msg32->lParam)<0) {
1076 HeapFree( SystemHeap, 0, msg32 );
1077 return -1;
1079 *plparam = (LPARAM)msg32;
1080 return 1;
1082 else return 0;
1083 case WM_NOTIFY:
1084 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
1085 return 1;
1086 case WM_ACTIVATEAPP:
1087 if (*plparam)
1088 { /* We need this when SetActiveWindow sends a Sendmessage16() to
1089 a 32bit window. Might be superflous with 32bit interprocess
1090 message queues.
1092 HTASK16 htask = (HTASK16) *plparam;
1093 DWORD idThread = THDB_TO_THREAD_ID(((TDB*)GlobalLock16(htask))->thdb);
1094 *plparam = (LPARAM) idThread;
1096 return 1;
1097 case WM_ASKCBFORMATNAME:
1098 case WM_DEVMODECHANGE:
1099 case WM_PAINTCLIPBOARD:
1100 case WM_SIZECLIPBOARD:
1101 case WM_WININICHANGE:
1102 FIXME( msg, "message %04x needs translation\n",msg16 );
1103 return -1;
1105 default: /* No translation needed */
1106 return 0;
1111 /**********************************************************************
1112 * WINPROC_UnmapMsg16To32A
1114 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1116 LRESULT WINPROC_UnmapMsg16To32A( HWND16 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam,
1117 LRESULT result )
1119 switch(msg)
1121 case WM_COMPAREITEM:
1122 case WM_DELETEITEM:
1123 case WM_DRAWITEM:
1124 HeapFree( SystemHeap, 0, (LPVOID)lParam );
1125 break;
1126 case WM_MEASUREITEM:
1128 MEASUREITEMSTRUCT16 *mis16;
1129 MEASUREITEMSTRUCT32 *mis = (MEASUREITEMSTRUCT32 *)lParam;
1130 lParam = *(LPARAM *)(mis + 1);
1131 mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(lParam);
1132 mis16->itemWidth = (UINT16)mis->itemWidth;
1133 mis16->itemHeight = (UINT16)mis->itemHeight;
1134 HeapFree( SystemHeap, 0, mis );
1136 break;
1137 case WM_GETMINMAXINFO:
1139 MINMAXINFO32 *mmi = (MINMAXINFO32 *)lParam;
1140 lParam = *(LPARAM *)(mmi + 1);
1141 STRUCT32_MINMAXINFO32to16( mmi,
1142 (MINMAXINFO16 *)PTR_SEG_TO_LIN(lParam));
1143 HeapFree( SystemHeap, 0, mmi );
1145 break;
1146 case WM_MDICREATE:
1148 MDICREATESTRUCT32A *cs = (MDICREATESTRUCT32A *)lParam;
1149 lParam = *(LPARAM *)(cs + 1);
1150 STRUCT32_MDICREATESTRUCT32Ato16( cs,
1151 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1152 HeapFree( SystemHeap, 0, cs );
1154 break;
1155 case WM_MDIGETACTIVE:
1156 result = MAKELONG( LOWORD(result), (BOOL16)(*(BOOL32 *)lParam) );
1157 HeapFree( SystemHeap, 0, (BOOL32 *)lParam );
1158 break;
1159 case WM_NCCALCSIZE:
1161 NCCALCSIZE_PARAMS16 *nc16;
1162 NCCALCSIZE_PARAMS32 *nc = (NCCALCSIZE_PARAMS32 *)lParam;
1163 lParam = *(LPARAM *)(nc + 1);
1164 nc16 = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(lParam);
1165 CONV_RECT32TO16( &nc->rgrc[0], &nc16->rgrc[0] );
1166 if (wParam)
1168 CONV_RECT32TO16( &nc->rgrc[1], &nc16->rgrc[1] );
1169 CONV_RECT32TO16( &nc->rgrc[2], &nc16->rgrc[2] );
1170 if (nc->lppos)
1172 STRUCT32_WINDOWPOS32to16( nc->lppos,
1173 (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc16->lppos));
1174 HeapFree( SystemHeap, 0, nc->lppos );
1177 HeapFree( SystemHeap, 0, nc );
1179 break;
1180 case WM_NCCREATE:
1181 case WM_CREATE:
1183 CREATESTRUCT32A *cs = (CREATESTRUCT32A *)lParam;
1184 lParam = *(LPARAM *)(cs + 1);
1185 STRUCT32_CREATESTRUCT32Ato16( cs,
1186 (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1187 HeapFree( SystemHeap, 0, cs );
1189 break;
1190 case WM_WINDOWPOSCHANGING:
1191 case WM_WINDOWPOSCHANGED:
1193 WINDOWPOS32 *wp = (WINDOWPOS32 *)lParam;
1194 lParam = *(LPARAM *)(wp + 1);
1195 STRUCT32_WINDOWPOS32to16(wp,(WINDOWPOS16 *)PTR_SEG_TO_LIN(lParam));
1196 HeapFree( SystemHeap, 0, wp );
1198 break;
1199 case WM_GETDLGCODE:
1200 if (lParam)
1202 LPMSG32 msg32 = (LPMSG32)lParam;
1204 WINPROC_UnmapMsg16To32A( hwnd, msg32->message, msg32->wParam, msg32->lParam,
1205 result);
1206 HeapFree( SystemHeap, 0, msg32 );
1208 break;
1210 return result;
1214 /**********************************************************************
1215 * WINPROC_MapMsg16To32W
1217 * Map a message from 16- to 32-bit Unicode.
1218 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1220 INT32 WINPROC_MapMsg16To32W( HWND16 hwnd, UINT16 msg16, WPARAM16 wParam16, UINT32 *pmsg32,
1221 WPARAM32 *pwparam32, LPARAM *plparam )
1223 switch(msg16)
1225 case WM_GETTEXT:
1226 case WM_SETTEXT:
1227 *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam);
1228 return WINPROC_MapMsg32ATo32W( hwnd, *pmsg32, *pwparam32, plparam );
1229 case WM_NCCREATE:
1230 case WM_CREATE:
1232 CREATESTRUCT16 *cs16 = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1233 CREATESTRUCT32W *cs = (CREATESTRUCT32W *)HeapAlloc( SystemHeap, 0,
1234 sizeof(*cs) + sizeof(LPARAM) );
1235 if (!cs) return -1;
1236 STRUCT32_CREATESTRUCT16to32A( cs16, (CREATESTRUCT32A *)cs );
1237 cs->lpszName = (LPCWSTR)PTR_SEG_TO_LIN(cs16->lpszName);
1238 cs->lpszClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->lpszClass);
1239 if (HIWORD(cs->lpszName))
1240 cs->lpszName = HEAP_strdupAtoW( SystemHeap, 0,
1241 (LPCSTR)cs->lpszName );
1242 if (HIWORD(cs->lpszClass))
1243 cs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0,
1244 (LPCSTR)cs->lpszClass );
1245 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1246 *plparam = (LPARAM)cs;
1248 return 1;
1249 case WM_MDICREATE:
1251 MDICREATESTRUCT16 *cs16 =
1252 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
1253 MDICREATESTRUCT32W *cs =
1254 (MDICREATESTRUCT32W *)HeapAlloc( SystemHeap, 0,
1255 sizeof(*cs) + sizeof(LPARAM) );
1256 if (!cs) return -1;
1257 STRUCT32_MDICREATESTRUCT16to32A( cs16, (MDICREATESTRUCT32A *)cs );
1258 cs->szTitle = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szTitle);
1259 cs->szClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szClass);
1260 if (HIWORD(cs->szTitle))
1261 cs->szTitle = HEAP_strdupAtoW( SystemHeap, 0,
1262 (LPCSTR)cs->szTitle );
1263 if (HIWORD(cs->szClass))
1264 cs->szClass = HEAP_strdupAtoW( SystemHeap, 0,
1265 (LPCSTR)cs->szClass );
1266 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1267 *plparam = (LPARAM)cs;
1269 return 1;
1270 case WM_GETDLGCODE:
1271 if (*plparam)
1273 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(*plparam);
1274 LPMSG32 msg32 = (LPMSG32)HeapAlloc( SystemHeap, 0, sizeof(MSG32) );
1276 if (!msg32) return -1;
1277 msg32->hwnd = msg16->hwnd;
1278 msg32->lParam = msg16->lParam;
1279 msg32->time = msg16->time;
1280 CONV_POINT16TO32(&msg16->pt,&msg32->pt);
1281 /* this is right, right? */
1282 if (WINPROC_MapMsg16To32W(hwnd, msg16->message,msg16->wParam,
1283 &msg32->message,&msg32->wParam,
1284 &msg32->lParam)<0) {
1285 HeapFree( SystemHeap, 0, msg32 );
1286 return -1;
1288 *plparam = (LPARAM)msg32;
1289 return 1;
1291 else return 0;
1292 default: /* No Unicode translation needed */
1293 return WINPROC_MapMsg16To32A( msg16, wParam16, pmsg32,
1294 pwparam32, plparam );
1299 /**********************************************************************
1300 * WINPROC_UnmapMsg16To32W
1302 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1304 LRESULT WINPROC_UnmapMsg16To32W( HWND16 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam,
1305 LRESULT result )
1307 switch(msg)
1309 case WM_GETTEXT:
1310 case WM_SETTEXT:
1311 WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
1312 break;
1313 case WM_NCCREATE:
1314 case WM_CREATE:
1316 CREATESTRUCT32W *cs = (CREATESTRUCT32W *)lParam;
1317 lParam = *(LPARAM *)(cs + 1);
1318 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCT32A *)cs,
1319 (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1320 if (HIWORD(cs->lpszName))
1321 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName );
1322 if (HIWORD(cs->lpszClass))
1323 HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass );
1324 HeapFree( SystemHeap, 0, cs );
1326 break;
1327 case WM_MDICREATE:
1329 MDICREATESTRUCT32W *cs = (MDICREATESTRUCT32W *)lParam;
1330 lParam = *(LPARAM *)(cs + 1);
1331 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCT32A *)cs,
1332 (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) );
1333 if (HIWORD(cs->szTitle))
1334 HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle );
1335 if (HIWORD(cs->szClass))
1336 HeapFree( SystemHeap, 0, (LPVOID)cs->szClass );
1337 HeapFree( SystemHeap, 0, cs );
1339 break;
1340 case WM_GETDLGCODE:
1341 if (lParam)
1343 LPMSG32 msg32 = (LPMSG32)lParam;
1345 WINPROC_UnmapMsg16To32W( hwnd, msg32->message, msg32->wParam, msg32->lParam,
1346 result);
1347 HeapFree( SystemHeap, 0, msg32 );
1349 break;
1350 default:
1351 return WINPROC_UnmapMsg16To32A( hwnd, msg, wParam, lParam, result );
1353 return result;
1357 /**********************************************************************
1358 * WINPROC_MapMsg32ATo16
1360 * Map a message from 32-bit Ansi to 16-bit.
1361 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1363 INT32 WINPROC_MapMsg32ATo16( HWND32 hwnd, UINT32 msg32, WPARAM32 wParam32,
1364 UINT16 *pmsg16, WPARAM16 *pwparam16,
1365 LPARAM *plparam )
1367 *pmsg16 = (UINT16)msg32;
1368 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1369 switch(msg32)
1371 case BM_GETCHECK32:
1372 case BM_SETCHECK32:
1373 case BM_GETSTATE32:
1374 case BM_SETSTATE32:
1375 case BM_SETSTYLE32:
1376 *pmsg16 = (UINT16)msg32 + (BM_GETCHECK16 - BM_GETCHECK32);
1377 return 0;
1379 case EM_GETSEL32:
1380 case EM_GETRECT32:
1381 case EM_SETRECT32:
1382 case EM_SETRECTNP32:
1383 case EM_SCROLL32:
1384 case EM_LINESCROLL32:
1385 case EM_SCROLLCARET32:
1386 case EM_GETMODIFY32:
1387 case EM_SETMODIFY32:
1388 case EM_GETLINECOUNT32:
1389 case EM_LINEINDEX32:
1390 case EM_SETHANDLE32:
1391 case EM_GETHANDLE32:
1392 case EM_GETTHUMB32:
1393 case EM_LINELENGTH32:
1394 case EM_REPLACESEL32:
1395 case EM_GETLINE32:
1396 case EM_LIMITTEXT32:
1397 case EM_CANUNDO32:
1398 case EM_UNDO32:
1399 case EM_FMTLINES32:
1400 case EM_LINEFROMCHAR32:
1401 case EM_SETTABSTOPS32:
1402 case EM_SETPASSWORDCHAR32:
1403 case EM_EMPTYUNDOBUFFER32:
1404 case EM_GETFIRSTVISIBLELINE32:
1405 case EM_SETREADONLY32:
1406 case EM_SETWORDBREAKPROC32:
1407 case EM_GETWORDBREAKPROC32:
1408 case EM_GETPASSWORDCHAR32:
1409 *pmsg16 = (UINT16)msg32 + (EM_GETSEL16 - EM_GETSEL32);
1410 return 0;
1412 case LB_CARETOFF32:
1413 case LB_CARETON32:
1414 case LB_DELETESTRING32:
1415 case LB_GETANCHORINDEX32:
1416 case LB_GETCARETINDEX32:
1417 case LB_GETCOUNT32:
1418 case LB_GETCURSEL32:
1419 case LB_GETHORIZONTALEXTENT32:
1420 case LB_GETITEMDATA32:
1421 case LB_GETITEMHEIGHT32:
1422 case LB_GETSEL32:
1423 case LB_GETSELCOUNT32:
1424 case LB_GETTEXTLEN32:
1425 case LB_GETTOPINDEX32:
1426 case LB_RESETCONTENT32:
1427 case LB_SELITEMRANGE32:
1428 case LB_SELITEMRANGEEX32:
1429 case LB_SETANCHORINDEX32:
1430 case LB_SETCARETINDEX32:
1431 case LB_SETCOLUMNWIDTH32:
1432 case LB_SETCURSEL32:
1433 case LB_SETHORIZONTALEXTENT32:
1434 case LB_SETITEMDATA32:
1435 case LB_SETITEMHEIGHT32:
1436 case LB_SETSEL32:
1437 case LB_SETTOPINDEX32:
1438 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING32);
1439 return 0;
1440 case CB_DELETESTRING32:
1441 case CB_GETCOUNT32:
1442 case CB_GETLBTEXTLEN32:
1443 case CB_LIMITTEXT32:
1444 case CB_RESETCONTENT32:
1445 case CB_SETEDITSEL32:
1446 case CB_GETCURSEL32:
1447 case CB_SETCURSEL32:
1448 case CB_SHOWDROPDOWN32:
1449 case CB_SETITEMDATA32:
1450 case CB_SETITEMHEIGHT32:
1451 case CB_GETITEMHEIGHT32:
1452 case CB_SETEXTENDEDUI32:
1453 case CB_GETEXTENDEDUI32:
1454 case CB_GETDROPPEDSTATE32:
1455 *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL32);
1456 return 0;
1457 case CB_GETEDITSEL32:
1458 *pmsg16 = CB_GETEDITSEL16;
1459 return 1;
1461 case LB_ADDSTRING32:
1462 case LB_FINDSTRING32:
1463 case LB_FINDSTRINGEXACT32:
1464 case LB_INSERTSTRING32:
1465 case LB_SELECTSTRING32:
1466 case LB_DIR32:
1467 case LB_ADDFILE32:
1469 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1470 if (!str) return -1;
1471 *plparam = (LPARAM)SEGPTR_GET(str);
1473 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING32);
1474 return 1;
1476 case CB_ADDSTRING32:
1477 case CB_FINDSTRING32:
1478 case CB_FINDSTRINGEXACT32:
1479 case CB_INSERTSTRING32:
1480 case CB_SELECTSTRING32:
1481 case CB_DIR32:
1483 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1484 if (!str) return -1;
1485 *plparam = (LPARAM)SEGPTR_GET(str);
1487 *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL32);
1488 return 1;
1490 case LB_GETITEMRECT32:
1492 RECT16 *rect;
1493 rect = (RECT16 *)SEGPTR_ALLOC( sizeof(RECT16) + sizeof(LPARAM) );
1494 if (!rect) return -1;
1495 *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */
1496 *plparam = (LPARAM)SEGPTR_GET(rect);
1498 *pmsg16 = LB_GETITEMRECT16;
1499 return 1;
1500 case LB_GETSELITEMS32:
1502 LPINT16 items;
1503 *pwparam16 = (WPARAM16)MIN( wParam32, 0x7f80 ); /* Must be < 64K */
1504 if (!(items = SEGPTR_ALLOC( *pwparam16 * sizeof(INT16)
1505 + sizeof(LPARAM)))) return -1;
1506 *((LPARAM *)items)++ = *plparam; /* Store the previous lParam */
1507 *plparam = (LPARAM)SEGPTR_GET(items);
1509 *pmsg16 = LB_GETSELITEMS16;
1510 return 1;
1511 case LB_SETTABSTOPS32:
1512 if (wParam32)
1514 INT32 i;
1515 LPINT16 stops;
1516 *pwparam16 = (WPARAM16)MIN( wParam32, 0x7f80 ); /* Must be < 64K */
1517 if (!(stops = SEGPTR_ALLOC( *pwparam16 * sizeof(INT16)
1518 + sizeof(LPARAM)))) return -1;
1519 for (i = 0; i < *pwparam16; i++) stops[i] = *((LPINT32)*plparam+i);
1520 *plparam = (LPARAM)SEGPTR_GET(stops);
1521 return 1;
1523 *pmsg16 = LB_SETTABSTOPS16;
1524 return 0;
1526 case CB_GETDROPPEDCONTROLRECT32:
1528 RECT16 *rect;
1529 rect = (RECT16 *)SEGPTR_ALLOC( sizeof(RECT16) + sizeof(LPARAM) );
1530 if (!rect) return -1;
1531 *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */
1532 *plparam = (LPARAM)SEGPTR_GET(rect);
1534 *pmsg16 = CB_GETDROPPEDCONTROLRECT16;
1535 return 1;
1537 case LB_GETTEXT32:
1538 *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) );
1539 *pmsg16 = LB_GETTEXT16;
1540 return 1;
1542 case CB_GETLBTEXT32:
1543 *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) );
1544 *pmsg16 = CB_GETLBTEXT16;
1545 return 1;
1547 case EM_SETSEL32:
1548 *pwparam16 = 0;
1549 *plparam = MAKELONG( (INT16)(INT32)wParam32, (INT16)*plparam );
1550 *pmsg16 = EM_SETSEL16;
1551 return 0;
1553 case WM_ACTIVATE:
1554 case WM_CHARTOITEM:
1555 case WM_COMMAND:
1556 case WM_VKEYTOITEM:
1557 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32) );
1558 return 0;
1559 case WM_HSCROLL:
1560 case WM_VSCROLL:
1561 *plparam = MAKELPARAM( HIWORD(wParam32), (HWND16)*plparam );
1562 return 0;
1563 case WM_CTLCOLORMSGBOX:
1564 case WM_CTLCOLOREDIT:
1565 case WM_CTLCOLORLISTBOX:
1566 case WM_CTLCOLORBTN:
1567 case WM_CTLCOLORDLG:
1568 case WM_CTLCOLORSCROLLBAR:
1569 case WM_CTLCOLORSTATIC:
1570 *pmsg16 = WM_CTLCOLOR;
1571 *plparam = MAKELPARAM( (HWND16)*plparam,
1572 (WORD)msg32 - WM_CTLCOLORMSGBOX );
1573 return 0;
1574 case WM_COMPAREITEM:
1576 COMPAREITEMSTRUCT32 *cis32 = (COMPAREITEMSTRUCT32 *)*plparam;
1577 COMPAREITEMSTRUCT16 *cis = SEGPTR_NEW(COMPAREITEMSTRUCT16);
1578 if (!cis) return -1;
1579 cis->CtlType = (UINT16)cis32->CtlType;
1580 cis->CtlID = (UINT16)cis32->CtlID;
1581 cis->hwndItem = (HWND16)cis32->hwndItem;
1582 cis->itemID1 = (UINT16)cis32->itemID1;
1583 cis->itemData1 = cis32->itemData1;
1584 cis->itemID2 = (UINT16)cis32->itemID2;
1585 cis->itemData2 = cis32->itemData2;
1586 *plparam = (LPARAM)SEGPTR_GET(cis);
1588 return 1;
1589 case WM_DELETEITEM:
1591 DELETEITEMSTRUCT32 *dis32 = (DELETEITEMSTRUCT32 *)*plparam;
1592 DELETEITEMSTRUCT16 *dis = SEGPTR_NEW(DELETEITEMSTRUCT16);
1593 if (!dis) return -1;
1594 dis->CtlType = (UINT16)dis32->CtlType;
1595 dis->CtlID = (UINT16)dis32->CtlID;
1596 dis->itemID = (UINT16)dis32->itemID;
1597 dis->hwndItem = (HWND16)dis32->hwndItem;
1598 dis->itemData = dis32->itemData;
1599 *plparam = (LPARAM)SEGPTR_GET(dis);
1601 return 1;
1602 case WM_DRAWITEM:
1604 DRAWITEMSTRUCT32 *dis32 = (DRAWITEMSTRUCT32 *)*plparam;
1605 DRAWITEMSTRUCT16 *dis = SEGPTR_NEW(DRAWITEMSTRUCT16);
1606 if (!dis) return -1;
1607 dis->CtlType = (UINT16)dis32->CtlType;
1608 dis->CtlID = (UINT16)dis32->CtlID;
1609 dis->itemID = (UINT16)dis32->itemID;
1610 dis->itemAction = (UINT16)dis32->itemAction;
1611 dis->itemState = (UINT16)dis32->itemState;
1612 dis->hwndItem = (HWND16)dis32->hwndItem;
1613 dis->hDC = (HDC16)dis32->hDC;
1614 dis->itemData = dis32->itemData;
1615 CONV_RECT32TO16( &dis32->rcItem, &dis->rcItem );
1616 *plparam = (LPARAM)SEGPTR_GET(dis);
1618 return 1;
1619 case WM_MEASUREITEM:
1621 MEASUREITEMSTRUCT32 *mis32 = (MEASUREITEMSTRUCT32 *)*plparam;
1622 MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)
1623 SEGPTR_ALLOC(sizeof(*mis)+sizeof(LPARAM));
1624 if (!mis) return -1;
1625 mis->CtlType = (UINT16)mis32->CtlType;
1626 mis->CtlID = (UINT16)mis32->CtlID;
1627 mis->itemID = (UINT16)mis32->itemID;
1628 mis->itemWidth = (UINT16)mis32->itemWidth;
1629 mis->itemHeight = (UINT16)mis32->itemHeight;
1630 mis->itemData = mis32->itemData;
1631 *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */
1632 *plparam = (LPARAM)SEGPTR_GET(mis);
1634 return 1;
1635 case WM_GETMINMAXINFO:
1637 MINMAXINFO16 *mmi = (MINMAXINFO16 *)SEGPTR_ALLOC( sizeof(*mmi) +
1638 sizeof(LPARAM) );
1639 if (!mmi) return -1;
1640 STRUCT32_MINMAXINFO32to16( (MINMAXINFO32 *)*plparam, mmi );
1641 *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */
1642 *plparam = (LPARAM)SEGPTR_GET(mmi);
1644 return 1;
1645 case WM_GETTEXT:
1647 LPSTR str;
1648 *pwparam16 = (WPARAM16)MIN( wParam32, 0xff80 ); /* Must be < 64K */
1649 if (!(str = SEGPTR_ALLOC(*pwparam16 + sizeof(LPARAM)))) return -1;
1650 *((LPARAM *)str)++ = *plparam; /* Store the previous lParam */
1651 *plparam = (LPARAM)SEGPTR_GET(str);
1653 return 1;
1654 case WM_MDICREATE:
1656 MDICREATESTRUCT16 *cs;
1657 MDICREATESTRUCT32A *cs32 = (MDICREATESTRUCT32A *)*plparam;
1658 LPSTR name, cls;
1660 if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1;
1661 STRUCT32_MDICREATESTRUCT32Ato16( cs32, cs );
1662 name = SEGPTR_STRDUP( cs32->szTitle );
1663 cls = SEGPTR_STRDUP( cs32->szClass );
1664 cs->szTitle = SEGPTR_GET(name);
1665 cs->szClass = SEGPTR_GET(cls);
1666 *plparam = (LPARAM)SEGPTR_GET(cs);
1668 return 1;
1669 case WM_MDIGETACTIVE:
1670 return 1;
1671 case WM_MDISETMENU:
1672 *plparam = MAKELPARAM( (HMENU16)LOWORD(wParam32),
1673 (HMENU16)LOWORD(*plparam) );
1674 *pwparam16 = (*plparam == 0);
1675 return 0;
1676 case WM_MENUCHAR:
1677 case WM_MENUSELECT:
1678 *plparam = MAKELPARAM( HIWORD(wParam32), (HMENU16)*plparam );
1679 return 0;
1680 case WM_MDIACTIVATE:
1681 if( WIDGETS_IsControl32(WIN_FindWndPtr(hwnd), BIC32_MDICLIENT) )
1683 *pwparam16 = (HWND32)wParam32;
1684 *plparam = 0;
1686 else
1688 *pwparam16 = ((HWND32)*plparam == hwnd);
1689 *plparam = MAKELPARAM( (HWND16)LOWORD(*plparam),
1690 (HWND16)LOWORD(wParam32) );
1692 return 0;
1693 case WM_NCCALCSIZE:
1695 NCCALCSIZE_PARAMS32 *nc32 = (NCCALCSIZE_PARAMS32 *)*plparam;
1696 NCCALCSIZE_PARAMS16 *nc = (NCCALCSIZE_PARAMS16 *)SEGPTR_ALLOC( sizeof(*nc) + sizeof(LPARAM) );
1697 if (!nc) return -1;
1699 CONV_RECT32TO16( &nc32->rgrc[0], &nc->rgrc[0] );
1700 if (wParam32)
1702 WINDOWPOS16 *wp;
1703 CONV_RECT32TO16( &nc32->rgrc[1], &nc->rgrc[1] );
1704 CONV_RECT32TO16( &nc32->rgrc[2], &nc->rgrc[2] );
1705 if (!(wp = SEGPTR_NEW(WINDOWPOS16)))
1707 SEGPTR_FREE(nc);
1708 return -1;
1710 STRUCT32_WINDOWPOS32to16( nc32->lppos, wp );
1711 nc->lppos = SEGPTR_GET(wp);
1713 *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */
1714 *plparam = (LPARAM)SEGPTR_GET(nc);
1716 return 1;
1717 case WM_NCCREATE:
1718 case WM_CREATE:
1720 CREATESTRUCT16 *cs;
1721 CREATESTRUCT32A *cs32 = (CREATESTRUCT32A *)*plparam;
1722 LPSTR name, cls;
1724 if (!(cs = SEGPTR_NEW(CREATESTRUCT16))) return -1;
1725 STRUCT32_CREATESTRUCT32Ato16( cs32, cs );
1726 name = SEGPTR_STRDUP( cs32->lpszName );
1727 cls = SEGPTR_STRDUP( cs32->lpszClass );
1728 cs->lpszName = SEGPTR_GET(name);
1729 cs->lpszClass = SEGPTR_GET(cls);
1730 *plparam = (LPARAM)SEGPTR_GET(cs);
1732 return 1;
1733 case WM_PARENTNOTIFY:
1734 if ((LOWORD(wParam32)==WM_CREATE) || (LOWORD(wParam32)==WM_DESTROY))
1735 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32));
1736 /* else nothing to do */
1737 return 0;
1738 case WM_NOTIFY:
1739 *plparam = MapLS( (NMHDR *)*plparam ); /* NMHDR is already 32-bit */
1740 return 1;
1741 case WM_SETTEXT:
1743 LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam );
1744 if (!str) return -1;
1745 *plparam = (LPARAM)SEGPTR_GET(str);
1747 return 1;
1748 case WM_WINDOWPOSCHANGING:
1749 case WM_WINDOWPOSCHANGED:
1751 WINDOWPOS16 *wp = (WINDOWPOS16 *)SEGPTR_ALLOC( sizeof(*wp) +
1752 sizeof(LPARAM) );
1753 if (!wp) return -1;
1754 STRUCT32_WINDOWPOS32to16( (WINDOWPOS32 *)*plparam, wp );
1755 *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */
1756 *plparam = (LPARAM)SEGPTR_GET(wp);
1758 return 1;
1759 case WM_GETDLGCODE:
1760 if (*plparam) {
1761 LPMSG32 msg32 = (LPMSG32) *plparam;
1762 LPMSG16 msg16 = (LPMSG16) SEGPTR_NEW( MSG16 );
1764 if (!msg16) return -1;
1765 msg16->hwnd = msg32->hwnd;
1766 msg16->lParam = msg32->lParam;
1767 msg16->time = msg32->time;
1768 CONV_POINT32TO16(&msg32->pt,&msg16->pt);
1769 /* this is right, right? */
1770 if (WINPROC_MapMsg32ATo16(msg32->hwnd,msg32->message,msg32->wParam,
1771 &msg16->message,&msg16->wParam, &msg16->lParam)<0) {
1772 SEGPTR_FREE( msg16 );
1773 return -1;
1775 *plparam = (LPARAM)SEGPTR_GET(msg16);
1776 return 1;
1778 return 0;
1780 case WM_ACTIVATEAPP:
1781 if (*plparam) {
1782 *plparam = (LPARAM) THREAD_ID_TO_THDB((DWORD) *plparam)->teb.htask16;
1784 return 1;
1785 case WM_ASKCBFORMATNAME:
1786 case WM_DEVMODECHANGE:
1787 case WM_PAINTCLIPBOARD:
1788 case WM_SIZECLIPBOARD:
1789 case WM_WININICHANGE:
1790 FIXME( msg, "message %04x needs translation\n", msg32 );
1791 return -1;
1792 default: /* No translation needed */
1793 return 0;
1798 /**********************************************************************
1799 * WINPROC_UnmapMsg32ATo16
1801 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
1803 void WINPROC_UnmapMsg32ATo16( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam,
1804 MSGPARAM16* p16 )
1806 switch(msg)
1808 case LB_ADDFILE32:
1809 case LB_ADDSTRING32:
1810 case LB_DIR32:
1811 case LB_FINDSTRING32:
1812 case LB_FINDSTRINGEXACT32:
1813 case LB_INSERTSTRING32:
1814 case LB_SELECTSTRING32:
1815 case LB_SETTABSTOPS32:
1816 case CB_ADDSTRING32:
1817 case CB_FINDSTRING32:
1818 case CB_FINDSTRINGEXACT32:
1819 case CB_INSERTSTRING32:
1820 case CB_SELECTSTRING32:
1821 case CB_DIR32:
1822 case WM_COMPAREITEM:
1823 case WM_DELETEITEM:
1824 case WM_DRAWITEM:
1825 case WM_SETTEXT:
1826 SEGPTR_FREE( PTR_SEG_TO_LIN(p16->lParam) );
1827 break;
1829 case CB_GETDROPPEDCONTROLRECT32:
1830 case LB_GETITEMRECT32:
1832 RECT16 *rect = (RECT16 *)PTR_SEG_TO_LIN(p16->lParam);
1833 p16->lParam = *(LPARAM *)(rect + 1);
1834 CONV_RECT16TO32( rect, (RECT32 *)(p16->lParam));
1835 SEGPTR_FREE( rect );
1837 break;
1838 case LB_GETSELITEMS32:
1840 INT32 i;
1841 LPINT16 items = (LPINT16)PTR_SEG_TO_LIN(lParam);
1842 p16->lParam = *((LPARAM *)items - 1);
1843 for (i = 0; i < p16->wParam; i++) *((LPINT32)(p16->lParam) + i) = items[i];
1844 SEGPTR_FREE( (LPARAM *)items - 1 );
1846 break;
1848 case CB_GETEDITSEL32:
1849 if( wParam )
1850 *((LPUINT32)(wParam)) = LOWORD(p16->lResult);
1851 if( lParam )
1852 *((LPUINT32)(lParam)) = HIWORD(p16->lResult); /* FIXME: substract 1? */
1853 break;
1855 case LB_GETTEXT32:
1856 case CB_GETLBTEXT32:
1857 UnMapLS( (SEGPTR)(p16->lParam) );
1858 break;
1860 case WM_MEASUREITEM:
1862 MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(p16->lParam);
1863 MEASUREITEMSTRUCT32 *mis32 = *(MEASUREITEMSTRUCT32 **)(mis + 1);
1864 mis32->itemWidth = mis->itemWidth;
1865 mis32->itemHeight = mis->itemHeight;
1866 SEGPTR_FREE(mis);
1868 break;
1869 case WM_GETMINMAXINFO:
1871 MINMAXINFO16 *mmi = (MINMAXINFO16 *)PTR_SEG_TO_LIN(p16->lParam);
1872 p16->lParam = *(LPARAM *)(mmi + 1);
1873 STRUCT32_MINMAXINFO16to32( mmi, (MINMAXINFO32 *)(p16->lParam) );
1874 SEGPTR_FREE(mmi);
1876 break;
1877 case WM_GETTEXT:
1879 LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam);
1880 p16->lParam = *((LPARAM *)str - 1);
1881 lstrcpyn32A( (LPSTR)(p16->lParam), str, p16->wParam );
1882 SEGPTR_FREE( (LPARAM *)str - 1 );
1884 break;
1885 case WM_MDICREATE:
1887 MDICREATESTRUCT16 *cs = (MDICREATESTRUCT16*)PTR_SEG_TO_LIN(p16->lParam);
1888 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szTitle) );
1889 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szClass) );
1890 SEGPTR_FREE( cs );
1892 break;
1893 case WM_MDIGETACTIVE:
1894 if (lParam) *(BOOL32 *)lParam = (BOOL16)HIWORD(p16->lResult);
1895 p16->lResult = (HWND32)LOWORD(p16->lResult);
1896 break;
1897 case WM_NCCALCSIZE:
1899 NCCALCSIZE_PARAMS32 *nc32;
1900 NCCALCSIZE_PARAMS16 *nc = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(p16->lParam);
1901 p16->lParam = *(LPARAM *)(nc + 1);
1902 nc32 = (NCCALCSIZE_PARAMS32 *)(p16->lParam);
1903 CONV_RECT16TO32( &nc->rgrc[0], &nc32->rgrc[0] );
1904 if (p16->wParam)
1906 CONV_RECT16TO32( &nc->rgrc[1], &nc32->rgrc[1] );
1907 CONV_RECT16TO32( &nc->rgrc[2], &nc32->rgrc[2] );
1908 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc->lppos),
1909 nc32->lppos );
1910 SEGPTR_FREE( PTR_SEG_TO_LIN(nc->lppos) );
1912 SEGPTR_FREE(nc);
1914 break;
1915 case WM_NCCREATE:
1916 case WM_CREATE:
1918 CREATESTRUCT16 *cs = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(p16->lParam);
1919 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->lpszName) );
1920 SEGPTR_FREE( PTR_SEG_TO_LIN(cs->lpszClass) );
1921 SEGPTR_FREE( cs );
1923 break;
1924 case WM_WINDOWPOSCHANGING:
1925 case WM_WINDOWPOSCHANGED:
1927 WINDOWPOS16 *wp = (WINDOWPOS16 *)PTR_SEG_TO_LIN(p16->lParam);
1928 p16->lParam = *(LPARAM *)(wp + 1);
1929 STRUCT32_WINDOWPOS16to32( wp, (WINDOWPOS32 *)p16->lParam );
1930 SEGPTR_FREE(wp);
1932 break;
1933 case WM_NOTIFY:
1934 UnMapLS(p16->lParam);
1935 break;
1936 case WM_GETDLGCODE:
1937 if (p16->lParam)
1939 LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(p16->lParam);
1940 MSGPARAM16 msgp16;
1941 msgp16.wParam=msg16->wParam;
1942 msgp16.lParam=msg16->lParam;
1943 WINPROC_UnmapMsg32ATo16(((LPMSG32)lParam)->hwnd, ((LPMSG32)lParam)->message,
1944 ((LPMSG32)lParam)->wParam, ((LPMSG32)lParam)->lParam,
1945 &msgp16 );
1946 SEGPTR_FREE(msg16);
1948 break;
1953 /**********************************************************************
1954 * WINPROC_MapMsg32WTo16
1956 * Map a message from 32-bit Unicode to 16-bit.
1957 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1959 INT32 WINPROC_MapMsg32WTo16( HWND32 hwnd, UINT32 msg32, WPARAM32 wParam32,
1960 UINT16 *pmsg16, WPARAM16 *pwparam16,
1961 LPARAM *plparam )
1963 switch(msg32)
1965 case LB_ADDSTRING32:
1966 case LB_FINDSTRING32:
1967 case LB_FINDSTRINGEXACT32:
1968 case LB_INSERTSTRING32:
1969 case LB_SELECTSTRING32:
1970 case LB_DIR32:
1971 case LB_ADDFILE32:
1973 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
1974 if (!str) return -1;
1975 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1976 *plparam = (LPARAM)SEGPTR_GET(str);
1978 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING32);
1979 return 1;
1981 case CB_ADDSTRING32:
1982 case CB_FINDSTRING32:
1983 case CB_FINDSTRINGEXACT32:
1984 case CB_INSERTSTRING32:
1985 case CB_SELECTSTRING32:
1986 case CB_DIR32:
1988 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
1989 if (!str) return -1;
1990 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1991 *plparam = (LPARAM)SEGPTR_GET(str);
1993 *pmsg16 = (UINT16)msg32 + (CB_ADDSTRING16 - CB_ADDSTRING32);
1994 return 1;
1996 case WM_NCCREATE:
1997 case WM_CREATE:
1999 CREATESTRUCT16 *cs;
2000 CREATESTRUCT32W *cs32 = (CREATESTRUCT32W *)*plparam;
2001 LPSTR name, cls;
2003 if (!(cs = SEGPTR_NEW(CREATESTRUCT16))) return -1;
2004 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCT32A *)cs32, cs );
2005 name = SEGPTR_STRDUP_WtoA( cs32->lpszName );
2006 cls = SEGPTR_STRDUP_WtoA( cs32->lpszClass );
2007 cs->lpszName = SEGPTR_GET(name);
2008 cs->lpszClass = SEGPTR_GET(cls);
2009 *pmsg16 = (UINT16)msg32;
2010 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2011 *plparam = (LPARAM)SEGPTR_GET(cs);
2013 return 1;
2014 case WM_MDICREATE:
2016 MDICREATESTRUCT16 *cs;
2017 MDICREATESTRUCT32W *cs32 = (MDICREATESTRUCT32W *)*plparam;
2018 LPSTR name, cls;
2020 if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1;
2021 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCT32A *)cs32, cs );
2022 name = SEGPTR_STRDUP_WtoA( cs32->szTitle );
2023 cls = SEGPTR_STRDUP_WtoA( cs32->szClass );
2024 cs->szTitle = SEGPTR_GET(name);
2025 cs->szClass = SEGPTR_GET(cls);
2026 *pmsg16 = (UINT16)msg32;
2027 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2028 *plparam = (LPARAM)SEGPTR_GET(cs);
2030 return 1;
2031 case WM_SETTEXT:
2033 LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam );
2034 if (!str) return -1;
2035 *pmsg16 = (UINT16)msg32;
2036 *pwparam16 = (WPARAM16)LOWORD(wParam32);
2037 *plparam = (LPARAM)SEGPTR_GET(str);
2039 return 1;
2040 default: /* No Unicode translation needed */
2041 return WINPROC_MapMsg32ATo16( hwnd, msg32, wParam32, pmsg16,
2042 pwparam16, plparam );
2047 /**********************************************************************
2048 * WINPROC_UnmapMsg32WTo16
2050 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2052 void WINPROC_UnmapMsg32WTo16( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam,
2053 MSGPARAM16* p16 )
2055 switch(msg)
2057 case WM_GETTEXT:
2059 LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam);
2060 p16->lParam = *((LPARAM *)str - 1);
2061 lstrcpyAtoW( (LPWSTR)(p16->lParam), str );
2062 SEGPTR_FREE( (LPARAM *)str - 1 );
2064 break;
2065 default:
2066 WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, p16 );
2067 break;
2072 /**********************************************************************
2073 * WINPROC_CallProc32ATo32W
2075 * Call a window procedure, translating args from Ansi to Unicode.
2077 static LRESULT WINPROC_CallProc32ATo32W( WNDPROC32 func, HWND32 hwnd,
2078 UINT32 msg, WPARAM32 wParam,
2079 LPARAM lParam )
2081 LRESULT result;
2083 if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0;
2084 result = WINPROC_CallWndProc32( func, hwnd, msg, wParam, lParam );
2085 WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
2086 return result;
2090 /**********************************************************************
2091 * WINPROC_CallProc32WTo32A
2093 * Call a window procedure, translating args from Unicode to Ansi.
2095 static LRESULT WINPROC_CallProc32WTo32A( WNDPROC32 func, HWND32 hwnd,
2096 UINT32 msg, WPARAM32 wParam,
2097 LPARAM lParam )
2099 LRESULT result;
2101 if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0;
2102 result = WINPROC_CallWndProc32( func, hwnd, msg, wParam, lParam );
2103 WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
2104 return result;
2108 /**********************************************************************
2109 * WINPROC_CallProc16To32A
2111 * Call a 32-bit window procedure, translating the 16-bit args.
2113 LRESULT WINPROC_CallProc16To32A( HWND16 hwnd, UINT16 msg,
2114 WPARAM16 wParam, LPARAM lParam,
2115 WNDPROC32 func )
2117 LRESULT result;
2118 UINT32 msg32;
2119 WPARAM32 wParam32;
2121 if (WINPROC_MapMsg16To32A( msg, wParam, &msg32, &wParam32, &lParam ) == -1)
2122 return 0;
2123 result = WINPROC_CallWndProc32( func, hwnd, msg32, wParam32, lParam );
2124 return WINPROC_UnmapMsg16To32A( hwnd, msg32, wParam32, lParam, result );
2128 /**********************************************************************
2129 * WINPROC_CallProc16To32W
2131 * Call a 32-bit window procedure, translating the 16-bit args.
2133 LRESULT WINPROC_CallProc16To32W( HWND16 hwnd, UINT16 msg,
2134 WPARAM16 wParam, LPARAM lParam,
2135 WNDPROC32 func )
2137 LRESULT result;
2138 UINT32 msg32;
2139 WPARAM32 wParam32;
2141 if (WINPROC_MapMsg16To32W( hwnd, msg, wParam, &msg32, &wParam32, &lParam ) == -1)
2142 return 0;
2143 result = WINPROC_CallWndProc32( func, hwnd, msg32, wParam32, lParam );
2144 return WINPROC_UnmapMsg16To32W( hwnd, msg32, wParam32, lParam, result );
2148 /**********************************************************************
2149 * WINPROC_CallProc32ATo16
2151 * Call a 16-bit window procedure, translating the 32-bit args.
2153 static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND32 hwnd,
2154 UINT32 msg, WPARAM32 wParam,
2155 LPARAM lParam )
2157 UINT16 msg16;
2158 MSGPARAM16 mp16;
2160 mp16.lParam = lParam;
2161 if (WINPROC_MapMsg32ATo16( hwnd, msg, wParam,
2162 &msg16, &mp16.wParam, &mp16.lParam ) == -1)
2163 return 0;
2164 mp16.lResult = Callbacks->CallWndProc( func, hwnd, msg16,
2165 mp16.wParam, mp16.lParam );
2166 WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, &mp16 );
2167 return mp16.lResult;
2171 /**********************************************************************
2172 * WINPROC_CallProc32WTo16
2174 * Call a 16-bit window procedure, translating the 32-bit args.
2176 static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND32 hwnd,
2177 UINT32 msg, WPARAM32 wParam,
2178 LPARAM lParam )
2180 UINT16 msg16;
2181 MSGPARAM16 mp16;
2183 mp16.lParam = lParam;
2184 if (WINPROC_MapMsg32WTo16( hwnd, msg, wParam, &msg16, &mp16.wParam,
2185 &mp16.lParam ) == -1)
2186 return 0;
2187 mp16.lResult = Callbacks->CallWndProc( func, hwnd, msg16,
2188 mp16.wParam, mp16.lParam );
2189 WINPROC_UnmapMsg32WTo16( hwnd, msg, wParam, lParam, &mp16 );
2190 return mp16.lResult;
2194 /**********************************************************************
2195 * CallWindowProc16 (USER.122)
2197 LRESULT WINAPI CallWindowProc16( WNDPROC16 func, HWND16 hwnd, UINT16 msg,
2198 WPARAM16 wParam, LPARAM lParam )
2200 WINDOWPROC *proc = WINPROC_GetPtr( func );
2202 if (!proc)
2203 return Callbacks->CallWndProc( func, hwnd, msg, wParam, lParam );
2205 #if testing
2206 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_16 );
2207 return Callbacks->CallWndProc( func, hwnd, msg, wParam, lParam );
2208 #endif
2210 switch(proc->type)
2212 case WIN_PROC_16:
2213 if (!proc->thunk.t_from32.proc) return 0;
2214 return Callbacks->CallWndProc( proc->thunk.t_from32.proc,
2215 hwnd, msg, wParam, lParam );
2216 case WIN_PROC_32A:
2217 if (!proc->thunk.t_from16.proc) return 0;
2218 return WINPROC_CallProc16To32A( hwnd, msg, wParam, lParam,
2219 proc->thunk.t_from16.proc );
2220 case WIN_PROC_32W:
2221 if (!proc->thunk.t_from16.proc) return 0;
2222 return WINPROC_CallProc16To32W( hwnd, msg, wParam, lParam,
2223 proc->thunk.t_from16.proc );
2224 default:
2225 WARN( relay, "Invalid proc %p\n", proc );
2226 return 0;
2231 /**********************************************************************
2232 * CallWindowProc32A (USER32.18)
2234 * The CallWindowProc() function invokes the windows procedure _func_,
2235 * with _hwnd_ as the target window, the message specified by _msg_, and
2236 * the message parameters _wParam_ and _lParam_.
2238 * Some kinds of argument conversion may be done, I'm not sure what.
2240 * CallWindowProc() may be used for windows subclassing. Use
2241 * SetWindowLong() to set a new windows procedure for windows of the
2242 * subclass, and handle subclassed messages in the new windows
2243 * procedure. The new windows procedure may then use CallWindowProc()
2244 * with _func_ set to the parent class's windows procedure to dispatch
2245 * the message to the superclass.
2247 * RETURNS
2249 * The return value is message dependent.
2251 * CONFORMANCE
2253 * ECMA-234, Win32
2255 LRESULT WINAPI CallWindowProc32A(
2256 WNDPROC32 func, /* window procedure */
2257 HWND32 hwnd, /* target window */
2258 UINT32 msg, /* message */
2259 WPARAM32 wParam, /* message dependent parameter */
2260 LPARAM lParam /* message dependent parameter */
2262 WINDOWPROC *proc = WINPROC_GetPtr( (WNDPROC16)func );
2264 if (!proc) return WINPROC_CallWndProc32( func, hwnd, msg, wParam, lParam );
2266 #if testing
2267 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_32A );
2268 return WINPROC_CallWndProc32( func, hwnd, msg, wParam, lParam );
2269 #endif
2271 switch(proc->type)
2273 case WIN_PROC_16:
2274 if (!proc->thunk.t_from32.proc) return 0;
2275 return WINPROC_CallProc32ATo16( proc->thunk.t_from32.proc,
2276 hwnd, msg, wParam, lParam );
2277 case WIN_PROC_32A:
2278 if (!proc->thunk.t_from16.proc) return 0;
2279 return WINPROC_CallWndProc32( proc->thunk.t_from16.proc,
2280 hwnd, msg, wParam, lParam );
2281 case WIN_PROC_32W:
2282 if (!proc->thunk.t_from16.proc) return 0;
2283 return WINPROC_CallProc32ATo32W( proc->thunk.t_from16.proc,
2284 hwnd, msg, wParam, lParam );
2285 default:
2286 WARN( relay, "Invalid proc %p\n", proc );
2287 return 0;
2292 /**********************************************************************
2293 * CallWindowProc32W (USER32.19)
2295 LRESULT WINAPI CallWindowProc32W( WNDPROC32 func, HWND32 hwnd, UINT32 msg,
2296 WPARAM32 wParam, LPARAM lParam )
2298 WINDOWPROC *proc = WINPROC_GetPtr( (WNDPROC16)func );
2300 if (!proc) return WINPROC_CallWndProc32( func, hwnd, msg, wParam, lParam );
2302 #if testing
2303 func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_32W );
2304 return WINPROC_CallWndProc32( func, hwnd, msg, wParam, lParam );
2305 #endif
2307 switch(proc->type)
2309 case WIN_PROC_16:
2310 if (!proc->thunk.t_from32.proc) return 0;
2311 return WINPROC_CallProc32WTo16( proc->thunk.t_from32.proc,
2312 hwnd, msg, wParam, lParam );
2313 case WIN_PROC_32A:
2314 if (!proc->thunk.t_from16.proc) return 0;
2315 return WINPROC_CallProc32WTo32A( proc->thunk.t_from16.proc,
2316 hwnd, msg, wParam, lParam );
2317 case WIN_PROC_32W:
2318 if (!proc->thunk.t_from16.proc) return 0;
2319 return WINPROC_CallWndProc32( proc->thunk.t_from16.proc,
2320 hwnd, msg, wParam, lParam );
2321 default:
2322 WARN( relay, "Invalid proc %p\n", proc );
2323 return 0;