2 * Window procedure callbacks
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1996 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
32 #include "wine/winbase16.h"
33 #include "wine/winuser16.h"
34 #include "stackframe.h"
40 #include "wine/debug.h"
46 WINE_DECLARE_DEBUG_CHANNEL(msg);
47 WINE_DECLARE_DEBUG_CHANNEL(relay);
48 WINE_DEFAULT_DEBUG_CHANNEL(win);
52 /* Window procedure 16-to-32-bit thunk */
55 BYTE popl_eax; /* popl %eax (return address) */
56 BYTE pushl_func; /* pushl $proc */
58 BYTE pushl_eax; /* pushl %eax */
59 BYTE ljmp; /* ljmp relay*/
60 DWORD relay_offset; /* __wine_call_wndproc_32A/W */
62 } WINPROC_THUNK_FROM16;
64 /* Window procedure 32-to-16-bit thunk */
67 BYTE popl_eax; /* popl %eax (return address) */
68 BYTE pushl_func; /* pushl $proc */
70 BYTE pushl_eax; /* pushl %eax */
71 BYTE jmp; /* jmp relay (relative jump)*/
72 void (*relay)(); /* WINPROC_CallProc32ATo16() */
73 } WINPROC_THUNK_FROM32;
75 /* Simple jmp to call 32-bit procedure directly */
78 BYTE jmp; /* jmp proc (relative jump) */
85 WINPROC_THUNK_FROM16 t_from16;
86 WINPROC_THUNK_FROM32 t_from32;
89 typedef struct tagWINDOWPROC
91 WINPROC_THUNK thunk; /* Thunk */
92 WINPROC_JUMP jmp; /* Jump */
93 struct tagWINDOWPROC *next; /* Next window proc */
94 UINT magic; /* Magic number */
95 WINDOWPROCTYPE type; /* Function type */
96 WINDOWPROCUSER user; /* Function user */
99 #define WINPROC_MAGIC ('W' | ('P' << 8) | ('R' << 16) | ('C' << 24))
101 #define WINPROC_THUNKPROC(pproc) \
102 (((pproc)->type == WIN_PROC_16) ? \
103 (WNDPROC16)((pproc)->thunk.t_from32.proc) : \
104 (WNDPROC16)((pproc)->thunk.t_from16.proc))
106 static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND hwnd,
107 UINT msg, WPARAM wParam,
109 static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND hwnd,
110 UINT msg, WPARAM wParam,
113 #define MAX_WINPROCS (0x10000 / sizeof(WINDOWPROC))
115 static WINDOWPROC winproc_array[MAX_WINPROCS];
116 static WINDOWPROC *winproc_first_free;
117 static UINT winproc_used;
119 static CRITICAL_SECTION winproc_cs;
120 static CRITICAL_SECTION_DEBUG critsect_debug =
123 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
124 0, 0, { 0, (DWORD)(__FILE__ ": winproc_cs") }
126 static CRITICAL_SECTION winproc_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
128 /* allocate a window procedure from the global array */
129 static WINDOWPROC *alloc_winproc(void)
131 WINDOWPROC *ret = NULL;
133 EnterCriticalSection( &winproc_cs );
134 if ((ret = winproc_first_free))
135 winproc_first_free = ret->next;
136 else if (winproc_used < MAX_WINPROCS)
137 ret = &winproc_array[winproc_used++];
138 LeaveCriticalSection( &winproc_cs );
142 static void free_winproc( WINDOWPROC *proc )
144 EnterCriticalSection( &winproc_cs );
146 proc->next = winproc_first_free;
147 winproc_first_free = proc;
148 LeaveCriticalSection( &winproc_cs );
151 static BOOL is_valid_winproc( WINDOWPROC *proc )
153 if (proc < winproc_array || proc >= winproc_array + MAX_WINPROCS) return FALSE;
154 if (proc != winproc_array + (proc - winproc_array)) return FALSE;
155 return (proc->magic == WINPROC_MAGIC);
158 static WORD get_winproc_selector(void)
160 static LONG winproc_selector;
163 if (!(ret = winproc_selector))
166 WORD sel = wine_ldt_alloc_entries(1);
167 wine_ldt_set_base( &entry, winproc_array );
168 wine_ldt_set_limit( &entry, sizeof(winproc_array) - 1 );
169 wine_ldt_set_flags( &entry, WINE_LDT_FLAGS_CODE | WINE_LDT_FLAGS_32BIT );
170 wine_ldt_set_entry( sel, &entry );
171 if (!(ret = InterlockedCompareExchange( &winproc_selector, sel, 0 ))) ret = sel;
172 else wine_ldt_free_entries( sel, 1 ); /* somebody beat us to it */
179 /* Some window procedures modify register they shouldn't, or are not
180 * properly declared stdcall; so we need a small assembly wrapper to
182 extern LRESULT WINPROC_wrapper( WNDPROC proc, HWND hwnd, UINT msg,
183 WPARAM wParam, LPARAM lParam );
184 __ASM_GLOBAL_FUNC( WINPROC_wrapper,
194 "movl 8(%ebp),%eax\n\t"
196 "leal -12(%ebp),%esp\n\t"
203 static inline LRESULT WINPROC_wrapper( WNDPROC proc, HWND hwnd, UINT msg,
204 WPARAM wParam, LPARAM lParam )
206 return proc( hwnd, msg, wParam, lParam );
208 #endif /* __i386__ */
210 /**********************************************************************
211 * WINPROC_CallWndProc32
213 * Call a 32-bit WndProc.
215 static LRESULT WINPROC_CallWndProc( WNDPROC proc, HWND hwnd, UINT msg,
216 WPARAM wParam, LPARAM lParam )
221 hwnd = WIN_GetFullHandle( hwnd );
223 DPRINTF( "%04lx:Call window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
224 GetCurrentThreadId(), proc, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam );
225 /* To avoid any deadlocks, all the locks on the windows structures
226 must be suspended before the control is passed to the application */
227 iWndsLocks = WIN_SuspendWndsLock();
228 retvalue = WINPROC_wrapper( proc, hwnd, msg, wParam, lParam );
229 WIN_RestoreWndsLock(iWndsLocks);
232 DPRINTF( "%04lx:Ret window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx) retval=%08lx\n",
233 GetCurrentThreadId(), proc, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam, retvalue );
237 /***********************************************************************
238 * WINPROC_CallWndProc16
240 * Call a 16-bit window procedure
242 static LRESULT WINAPI WINPROC_CallWndProc16( WNDPROC16 proc, HWND16 hwnd,
243 UINT16 msg, WPARAM16 wParam,
250 TEB *teb = NtCurrentTeb();
253 /* Window procedures want ax = hInstance, ds = es = ss */
255 memset(&context, '\0', sizeof(context));
256 context.SegDs = context.SegEs = SELECTOROF(teb->cur_stack);
257 if (!(context.Eax = GetWindowWord( HWND_32(hwnd), GWL_HINSTANCE ))) context.Eax = context.SegDs;
258 context.SegCs = SELECTOROF(proc);
259 context.Eip = OFFSETOF(proc);
260 context.Ebp = OFFSETOF(teb->cur_stack)
261 + (WORD)&((STACK16FRAME*)0)->bp;
265 /* Some programs (eg. the "Undocumented Windows" examples, JWP) only
266 work if structures passed in lParam are placed in the stack/data
267 segment. Programmers easily make the mistake of converting lParam
268 to a near rather than a far pointer, since Windows apparently
269 allows this. We copy the structures to the 16 bit stack; this is
270 ugly but makes these programs work. */
275 offset = sizeof(CREATESTRUCT16); break;
277 offset = sizeof(DRAWITEMSTRUCT16); break;
279 offset = sizeof(COMPAREITEMSTRUCT16); break;
283 void *s = MapSL(lParam);
284 lParam = stack16_push( offset );
285 memcpy( MapSL(lParam), s, offset );
289 iWndsLocks = WIN_SuspendWndsLock();
294 args[1] = HIWORD(lParam);
295 args[0] = LOWORD(lParam);
296 WOWCallback16Ex( 0, WCB16_REGS, sizeof(args), args, (DWORD *)&context );
297 ret = MAKELONG( LOWORD(context.Eax), LOWORD(context.Edx) );
299 if (offset) stack16_pop( offset );
301 WIN_RestoreWndsLock(iWndsLocks);
307 /**********************************************************************
310 * Return a pointer to the win proc.
312 static WINDOWPROC *WINPROC_GetPtr( WNDPROC handle )
317 /* ptr cannot be < 64K */
318 if (!HIWORD(handle)) return NULL;
320 /* Check for a linear pointer */
322 ptr = (BYTE *)handle;
323 /* First check if it is the jmp address */
324 proc = (WINDOWPROC *)(ptr - (int)&((WINDOWPROC *)0)->jmp);
325 if (is_valid_winproc(proc)) return proc;
327 /* Now it must be the thunk address */
328 proc = (WINDOWPROC *)(ptr - (int)&((WINDOWPROC *)0)->thunk);
329 if (is_valid_winproc(proc)) return proc;
331 /* Check for a segmented pointer */
333 if (!IsBadReadPtr16( (SEGPTR)handle, sizeof(proc->thunk) ))
335 ptr = MapSL( (SEGPTR)handle );
336 /* It must be the thunk address */
337 proc = (WINDOWPROC *)(ptr - (int)&((WINDOWPROC *)0)->thunk);
338 if (is_valid_winproc(proc)) return proc;
345 /**********************************************************************
346 * WINPROC_AllocWinProc
348 * Allocate a new window procedure.
350 static WINDOWPROC *WINPROC_AllocWinProc( WNDPROC func, WINDOWPROCTYPE type,
351 WINDOWPROCUSER user )
353 static FARPROC16 relay_32A, relay_32W;
355 WINDOWPROC *proc, *oldproc;
357 /* Allocate a window procedure */
359 if (!(proc = alloc_winproc())) return 0;
361 /* Check if the function is already a win proc */
363 if ((oldproc = WINPROC_GetPtr( func )))
372 proc->thunk.t_from32.popl_eax = 0x58; /* popl %eax */
373 proc->thunk.t_from32.pushl_func = 0x68; /* pushl $proc */
374 proc->thunk.t_from32.proc = (WNDPROC16)func;
375 proc->thunk.t_from32.pushl_eax = 0x50; /* pushl %eax */
376 proc->thunk.t_from32.jmp = 0xe9; /* jmp relay*/
377 proc->thunk.t_from32.relay = /* relative jump */
378 (void(*)())((DWORD)WINPROC_CallProc32ATo16 -
379 (DWORD)(&proc->thunk.t_from32.relay + 1));
382 if (!relay_32A) relay_32A = GetProcAddress16( GetModuleHandle16("user"),
383 "__wine_call_wndproc_32A" );
384 proc->thunk.t_from16.popl_eax = 0x58; /* popl %eax */
385 proc->thunk.t_from16.pushl_func = 0x68; /* pushl $proc */
386 proc->thunk.t_from16.proc = func;
387 proc->thunk.t_from16.pushl_eax = 0x50; /* pushl %eax */
388 proc->thunk.t_from16.ljmp = 0xea; /* ljmp relay*/
389 proc->thunk.t_from16.relay_offset = OFFSETOF(relay_32A);
390 proc->thunk.t_from16.relay_sel = SELECTOROF(relay_32A);
391 proc->jmp.jmp = 0xe9;
392 /* Fixup relative jump */
393 proc->jmp.proc = (WNDPROC)((DWORD)func - (DWORD)(&proc->jmp.proc + 1));
396 if (!relay_32W) relay_32W = GetProcAddress16( GetModuleHandle16("user"),
397 "__wine_call_wndproc_32W" );
398 proc->thunk.t_from16.popl_eax = 0x58; /* popl %eax */
399 proc->thunk.t_from16.pushl_func = 0x68; /* pushl $proc */
400 proc->thunk.t_from16.proc = func;
401 proc->thunk.t_from16.pushl_eax = 0x50; /* pushl %eax */
402 proc->thunk.t_from16.ljmp = 0xea; /* ljmp relay*/
403 proc->thunk.t_from16.relay_offset = OFFSETOF(relay_32W);
404 proc->thunk.t_from16.relay_sel = SELECTOROF(relay_32W);
405 proc->jmp.jmp = 0xe9;
406 /* Fixup relative jump */
407 proc->jmp.proc = (WNDPROC)((char *)func - (char *)(&proc->jmp.proc + 1));
410 /* Should not happen */
413 proc->magic = WINPROC_MAGIC;
418 TRACE("(%p,%d): returning %p\n", func, type, proc );
423 /**********************************************************************
426 * Get a window procedure pointer that can be passed to the Windows program.
428 WNDPROC16 WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type )
430 WINDOWPROC *ptr = (WINDOWPROC *)proc;
432 if (!proc) return NULL;
433 if (type == WIN_PROC_16) /* We want a 16:16 address */
435 if (ptr->type == WIN_PROC_16)
436 return ptr->thunk.t_from32.proc;
438 return (WNDPROC16)MAKESEGPTR( get_winproc_selector(),
439 (char *)&ptr->thunk - (char *)winproc_array );
441 else /* We want a 32-bit address */
443 if (ptr->type == WIN_PROC_16)
444 return (WNDPROC16)&ptr->thunk;
445 else if (type != ptr->type)
446 /* Have to return the jmp address if types don't match */
447 return (WNDPROC16)&ptr->jmp;
449 /* Some Win16 programs want to get back the proc they set */
450 return (WNDPROC16)ptr->thunk.t_from16.proc;
455 /**********************************************************************
458 * Set the window procedure for a window or class. There are
459 * three tree classes of winproc callbacks:
461 * 1) class -> wp - not subclassed
462 * class -> wp -> wp -> wp -> wp - SetClassLong()
464 * 2) window -' / - not subclassed
465 * window -> wp -> wp ' - SetWindowLong()
467 * 3) timer -> wp - SetTimer()
469 * Initially, winproc of the window points to the current winproc
470 * thunk of its class. Subclassing prepends a new thunk to the
471 * window winproc chain at the head of the list. Thus, window thunk
472 * list includes class thunks and the latter are preserved when the
473 * window is destroyed.
476 BOOL WINPROC_SetProc( WNDPROC *pFirst, WNDPROC func,
477 WINDOWPROCTYPE type, WINDOWPROCUSER user )
479 BOOL bRecycle = FALSE;
480 WINDOWPROC *proc, **ppPrev;
482 /* Check if function is already in the list */
484 ppPrev = (WINDOWPROC **)pFirst;
485 proc = WINPROC_GetPtr( func );
492 if ((*ppPrev)->user != user)
494 /* terminal thunk is being restored */
496 WINPROC_FreeProc( *pFirst, (*ppPrev)->user );
497 *(WINDOWPROC **)pFirst = *ppPrev;
506 if (((*ppPrev)->type == type) &&
507 (func == (WNDPROC)WINPROC_THUNKPROC(*ppPrev)))
509 if((*ppPrev)->user == user)
515 WINPROC_FreeProc( (WNDPROC)*ppPrev, user );
522 /* WPF_CLASS thunk terminates window thunk list */
523 if ((*ppPrev)->user != user) break;
524 ppPrev = &(*ppPrev)->next;
529 /* Extract this thunk from the list */
531 *ppPrev = proc->next;
533 else /* Allocate a new one */
535 if (proc) /* Was already a win proc */
538 func = (WNDPROC)WINPROC_THUNKPROC(proc);
540 proc = WINPROC_AllocWinProc( func, type, user );
541 if (!proc) return FALSE;
544 /* Add the win proc at the head of the list */
546 TRACE("(%p,%p,%d): res=%p\n", *pFirst, func, type, proc );
547 proc->next = *(WINDOWPROC **)pFirst;
548 *(WINDOWPROC **)pFirst = proc;
553 /**********************************************************************
556 * Free a list of win procs.
558 void WINPROC_FreeProc( WNDPROC proc, WINDOWPROCUSER user )
560 WINDOWPROC *ptr = (WINDOWPROC *)proc;
563 WINDOWPROC *next = ptr->next;
564 if (ptr->user != user) break;
565 TRACE("freeing %p (%d)\n", ptr, user);
572 /**********************************************************************
573 * WINPROC_GetProcType
575 * Return the window procedure type.
577 WINDOWPROCTYPE WINPROC_GetProcType( WNDPROC proc )
580 (((WINDOWPROC *)proc)->magic != WINPROC_MAGIC))
581 return WIN_PROC_INVALID;
582 return ((WINDOWPROC *)proc)->type;
584 /**********************************************************************
585 * WINPROC_TestCBForStr
587 * Return TRUE if the lparam is a string
589 inline static BOOL WINPROC_TestCBForStr( HWND hwnd )
591 DWORD style = GetWindowLongA( hwnd, GWL_STYLE );
592 return (!(style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) || (style & CBS_HASSTRINGS));
594 /**********************************************************************
595 * WINPROC_TestLBForStr
597 * Return TRUE if the lparam is a string
599 inline static BOOL WINPROC_TestLBForStr( HWND hwnd )
601 DWORD style = GetWindowLongA( hwnd, GWL_STYLE );
602 return (!(style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) || (style & LBS_HASSTRINGS));
605 /**********************************************************************
606 * WINPROC_MapMsg32ATo32W
608 * Map a message from Ansi to Unicode.
609 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
612 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
613 * the first four bytes are the handle of the icon
614 * when the WM_SETTEXT message has been used to set the icon
616 INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam, LPARAM *plparam )
621 case WM_ASKCBFORMATNAME:
623 LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
624 *pwparam * sizeof(WCHAR) + sizeof(LPARAM) );
626 *ptr++ = *plparam; /* Store previous lParam */
627 *plparam = (LPARAM)ptr;
630 /* lparam is string (0-terminated) */
632 case WM_WININICHANGE:
633 case WM_DEVMODECHANGE:
639 DWORD len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*plparam, -1, NULL, 0);
640 WCHAR *buf = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
641 len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)*plparam, -1, buf, len);
642 *plparam = (LPARAM)buf;
643 return (*plparam ? 1 : -1);
645 case WM_GETTEXTLENGTH:
646 case CB_GETLBTEXTLEN:
648 return 1; /* need to map result */
652 UNICODE_STRING usBuffer;
654 { CREATESTRUCTW cs; /* new structure */
655 LPCWSTR lpszName; /* allocated Name */
656 LPCWSTR lpszClass; /* allocated Class */
659 struct s *xs = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct s));
661 xs->cs = *(CREATESTRUCTW *)*plparam;
662 if (HIWORD(xs->cs.lpszName))
664 RtlCreateUnicodeStringFromAsciiz(&usBuffer,(LPCSTR)xs->cs.lpszName);
665 xs->lpszName = xs->cs.lpszName = usBuffer.Buffer;
667 if (HIWORD(xs->cs.lpszClass))
669 RtlCreateUnicodeStringFromAsciiz(&usBuffer,(LPCSTR)xs->cs.lpszClass);
670 xs->lpszClass = xs->cs.lpszClass = usBuffer.Buffer;
672 *plparam = (LPARAM)xs;
677 MDICREATESTRUCTW *cs =
678 (MDICREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) );
680 *cs = *(MDICREATESTRUCTW *)*plparam;
681 if (HIWORD(cs->szClass))
683 UNICODE_STRING usBuffer;
684 RtlCreateUnicodeStringFromAsciiz(&usBuffer,(LPCSTR)cs->szClass);
685 cs->szClass = usBuffer.Buffer;
687 if (HIWORD(cs->szTitle))
689 UNICODE_STRING usBuffer;
690 RtlCreateUnicodeStringFromAsciiz(&usBuffer,(LPCSTR)cs->szTitle);
691 cs->szTitle = usBuffer.Buffer;
693 *plparam = (LPARAM)cs;
699 case LB_INSERTSTRING:
701 case LB_FINDSTRINGEXACT:
702 case LB_SELECTSTRING:
703 if(!*plparam) return 0;
704 if ( WINPROC_TestLBForStr( hwnd ))
706 UNICODE_STRING usBuffer;
707 RtlCreateUnicodeStringFromAsciiz(&usBuffer,(LPCSTR)*plparam);
708 *plparam = (LPARAM)usBuffer.Buffer;
710 return (*plparam ? 1 : -1);
712 case LB_GETTEXT: /* FIXME: fixed sized buffer */
713 { if ( WINPROC_TestLBForStr( hwnd ))
714 { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
716 *ptr++ = *plparam; /* Store previous lParam */
717 *plparam = (LPARAM)ptr;
724 case CB_INSERTSTRING:
725 case CB_FINDSTRINGEXACT:
727 case CB_SELECTSTRING:
728 if(!*plparam) return 0;
729 if ( WINPROC_TestCBForStr( hwnd ))
731 UNICODE_STRING usBuffer;
732 RtlCreateUnicodeStringFromAsciiz(&usBuffer,(LPCSTR)*plparam);
733 *plparam = (LPARAM)usBuffer.Buffer;
735 return (*plparam ? 1 : -1);
737 case CB_GETLBTEXT: /* FIXME: fixed sized buffer */
738 { if ( WINPROC_TestCBForStr( hwnd ))
739 { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
741 *ptr++ = *plparam; /* Store previous lParam */
742 *plparam = (LPARAM)ptr;
749 { WORD len = (WORD)*plparam;
750 LPARAM *ptr = (LPARAM *) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
752 *ptr++ = *plparam; /* Store previous lParam */
753 *((WORD *) ptr) = len; /* Store the length */
754 *plparam = (LPARAM)ptr;
764 case EM_SETPASSWORDCHAR:
766 BYTE ch = LOWORD(*pwparam);
768 MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1);
769 *pwparam = MAKEWPARAM( wch, HIWORD(*pwparam) );
777 ch[0] = (*pwparam >> 8);
778 ch[1] = *pwparam & 0xff;
779 MultiByteToWideChar(CP_ACP, 0, ch, 2, &wch, 1);
780 *pwparam = MAKEWPARAM( wch, HIWORD(*pwparam) );
784 case WM_PAINTCLIPBOARD:
785 case WM_SIZECLIPBOARD:
786 FIXME_(msg)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg, hwnd), msg );
788 default: /* No translation needed */
794 /**********************************************************************
795 * WINPROC_UnmapMsg32ATo32W
797 * Unmap a message that was mapped from Ansi to Unicode.
799 LRESULT WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
805 case WM_ASKCBFORMATNAME:
807 LPARAM *ptr = (LPARAM *)lParam - 1;
808 if (wParam > 0 && !WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1,
809 (LPSTR)*ptr, wParam, NULL, NULL ))
810 ((LPSTR)*ptr)[wParam-1] = 0;
811 HeapFree( GetProcessHeap(), 0, ptr );
814 case WM_GETTEXTLENGTH:
815 case CB_GETLBTEXTLEN:
817 /* there may be one DBCS char for each Unicode char */
823 { CREATESTRUCTW cs; /* new structure */
824 LPWSTR lpszName; /* allocated Name */
825 LPWSTR lpszClass; /* allocated Class */
827 struct s *xs = (struct s *)lParam;
828 if (xs->lpszName) HeapFree( GetProcessHeap(), 0, xs->lpszName );
829 if (xs->lpszClass) HeapFree( GetProcessHeap(), 0, xs->lpszClass );
830 HeapFree( GetProcessHeap(), 0, xs );
836 MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
837 if (HIWORD(cs->szTitle))
838 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle );
839 if (HIWORD(cs->szClass))
840 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass );
841 HeapFree( GetProcessHeap(), 0, cs );
846 case WM_WININICHANGE:
847 case WM_DEVMODECHANGE:
852 HeapFree( GetProcessHeap(), 0, (void *)lParam );
857 case LB_INSERTSTRING:
859 case LB_FINDSTRINGEXACT:
860 case LB_SELECTSTRING:
861 if ( WINPROC_TestLBForStr( hwnd ))
862 HeapFree( GetProcessHeap(), 0, (void *)lParam );
866 { if ( WINPROC_TestLBForStr( hwnd ))
867 { LPARAM *ptr = (LPARAM *)lParam - 1;
868 WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, (LPSTR)*ptr, 0x7fffffff, NULL, NULL );
869 HeapFree( GetProcessHeap(), 0, ptr );
876 case CB_INSERTSTRING:
878 case CB_FINDSTRINGEXACT:
879 case CB_SELECTSTRING:
880 if ( WINPROC_TestCBForStr( hwnd ))
881 HeapFree( GetProcessHeap(), 0, (void *)lParam );
885 { if ( WINPROC_TestCBForStr( hwnd ))
886 { LPARAM *ptr = (LPARAM *)lParam - 1;
887 WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, (LPSTR)*ptr, 0x7fffffff, NULL, NULL );
888 HeapFree( GetProcessHeap(), 0, ptr );
895 { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lParam */
896 WORD len = *(WORD *) lParam;
897 if (len > 0 && !WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1,
898 (LPSTR)*ptr, len, NULL, NULL ))
899 ((LPSTR)*ptr)[len-1] = 0;
900 HeapFree( GetProcessHeap(), 0, ptr );
908 /**********************************************************************
909 * WINPROC_MapMsg32WTo32A
911 * Map a message from Unicode to Ansi.
912 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
914 INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM *pwparam, LPARAM *plparam )
919 case WM_ASKCBFORMATNAME:
921 LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
922 *pwparam + sizeof(LPARAM) );
924 *ptr++ = *plparam; /* Store previous lParam */
925 *plparam = (LPARAM)ptr;
930 case WM_WININICHANGE:
931 case WM_DEVMODECHANGE:
936 if(!*plparam) return 0;
937 *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
938 return (*plparam ? 1 : -1);
943 CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0,
946 *cs = *(CREATESTRUCTA *)*plparam;
947 if (HIWORD(cs->lpszName))
948 cs->lpszName = HEAP_strdupWtoA( GetProcessHeap(), 0,
949 (LPCWSTR)cs->lpszName );
950 if (HIWORD(cs->lpszClass))
951 cs->lpszClass = HEAP_strdupWtoA( GetProcessHeap(), 0,
952 (LPCWSTR)cs->lpszClass);
953 *plparam = (LPARAM)cs;
958 MDICREATESTRUCTA *cs =
959 (MDICREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) );
961 *cs = *(MDICREATESTRUCTA *)*plparam;
962 if (HIWORD(cs->szTitle))
963 cs->szTitle = HEAP_strdupWtoA( GetProcessHeap(), 0,
964 (LPCWSTR)cs->szTitle );
965 if (HIWORD(cs->szClass))
966 cs->szClass = HEAP_strdupWtoA( GetProcessHeap(), 0,
967 (LPCWSTR)cs->szClass );
968 *plparam = (LPARAM)cs;
974 case LB_INSERTSTRING:
976 case LB_FINDSTRINGEXACT:
977 case LB_SELECTSTRING:
978 if(!*plparam) return 0;
979 if ( WINPROC_TestLBForStr( hwnd ))
980 *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
981 return (*plparam ? 1 : -1);
983 case LB_GETTEXT: /* FIXME: fixed sized buffer */
984 { if ( WINPROC_TestLBForStr( hwnd ))
985 { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
987 *ptr++ = *plparam; /* Store previous lParam */
988 *plparam = (LPARAM)ptr;
995 case CB_INSERTSTRING:
997 case CB_FINDSTRINGEXACT:
998 case CB_SELECTSTRING:
999 if(!*plparam) return 0;
1000 if ( WINPROC_TestCBForStr( hwnd ))
1001 *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
1002 return (*plparam ? 1 : -1);
1004 case CB_GETLBTEXT: /* FIXME: fixed sized buffer */
1005 { if ( WINPROC_TestCBForStr( hwnd ))
1006 { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
1007 if (!ptr) return -1;
1008 *ptr++ = *plparam; /* Store previous lParam */
1009 *plparam = (LPARAM)ptr;
1014 /* Multiline edit */
1016 { WORD len = (WORD)*plparam;
1017 LPARAM *ptr = (LPARAM *) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
1018 if (!ptr) return -1;
1019 *ptr++ = *plparam; /* Store previous lParam */
1020 *((WORD *) ptr) = len; /* Store the length */
1021 *plparam = (LPARAM)ptr;
1030 case WM_SYSDEADCHAR:
1031 case EM_SETPASSWORDCHAR:
1033 WCHAR wch = LOWORD(*pwparam);
1035 WideCharToMultiByte( CP_ACP, 0, &wch, 1, &ch, 1, NULL, NULL );
1036 *pwparam = MAKEWPARAM( ch, HIWORD(*pwparam) );
1042 WCHAR wch = LOWORD(*pwparam);
1046 WideCharToMultiByte( CP_ACP, 0, &wch, 1, ch, 2, NULL, NULL );
1047 *pwparam = MAKEWPARAM( (ch[0] << 8) | ch[1], HIWORD(*pwparam) );
1051 case WM_PAINTCLIPBOARD:
1052 case WM_SIZECLIPBOARD:
1053 FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg, hwnd),msg );
1055 default: /* No translation needed */
1061 /**********************************************************************
1062 * WINPROC_UnmapMsg32WTo32A
1064 * Unmap a message that was mapped from Unicode to Ansi.
1066 void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
1071 case WM_ASKCBFORMATNAME:
1073 LPARAM *ptr = (LPARAM *)lParam - 1;
1076 if (!MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, wParam ))
1077 ((LPWSTR)*ptr)[wParam-1] = 0;
1079 HeapFree( GetProcessHeap(), 0, ptr );
1084 case WM_WININICHANGE:
1085 case WM_DEVMODECHANGE:
1090 HeapFree( GetProcessHeap(), 0, (void *)lParam );
1096 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
1097 if (HIWORD(cs->lpszName))
1098 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName );
1099 if (HIWORD(cs->lpszClass))
1100 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass );
1101 HeapFree( GetProcessHeap(), 0, cs );
1107 MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
1108 if (HIWORD(cs->szTitle))
1109 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle );
1110 if (HIWORD(cs->szClass))
1111 HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass );
1112 HeapFree( GetProcessHeap(), 0, cs );
1118 case LB_INSERTSTRING:
1120 case LB_FINDSTRINGEXACT:
1121 case LB_SELECTSTRING:
1122 if ( WINPROC_TestLBForStr( hwnd ))
1123 HeapFree( GetProcessHeap(), 0, (void *)lParam );
1127 if ( WINPROC_TestLBForStr( hwnd ))
1129 LPARAM *ptr = (LPARAM *)lParam - 1;
1130 MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, 0x7fffffff );
1131 HeapFree( GetProcessHeap(), 0, ptr );
1137 case CB_INSERTSTRING:
1139 case CB_FINDSTRINGEXACT:
1140 case CB_SELECTSTRING:
1141 if ( WINPROC_TestCBForStr( hwnd ))
1142 HeapFree( GetProcessHeap(), 0, (void *)lParam );
1146 if ( WINPROC_TestCBForStr( hwnd ))
1148 LPARAM *ptr = (LPARAM *)lParam - 1;
1149 MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, 0x7fffffff );
1150 HeapFree( GetProcessHeap(), 0, ptr );
1154 /* Multiline edit */
1156 { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lparam */
1157 WORD len = *(WORD *)ptr;
1160 if (!MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, len ))
1161 ((LPWSTR)*ptr)[len-1] = 0;
1163 HeapFree( GetProcessHeap(), 0, ptr );
1169 static UINT convert_handle_16_to_32(HANDLE16 src, unsigned int flags)
1172 UINT sz = GlobalSize16(src);
1175 if (!(dst = GlobalAlloc(flags, sz)))
1177 ptr16 = GlobalLock16(src);
1178 ptr32 = GlobalLock(dst);
1179 if (ptr16 != NULL && ptr32 != NULL) memcpy(ptr32, ptr16, sz);
1180 GlobalUnlock16(src);
1186 /**********************************************************************
1187 * WINPROC_MapMsg16To32A
1189 * Map a message from 16- to 32-bit Ansi.
1190 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1192 INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
1193 WPARAM *pwparam32, LPARAM *plparam )
1195 *pmsg32 = (UINT)msg16;
1196 *pwparam32 = (WPARAM)wParam16;
1203 *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
1204 *plparam = (LPARAM)WIN_Handle32( LOWORD(*plparam) );
1208 *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
1209 *plparam = (LPARAM)WIN_Handle32( HIWORD(*plparam) );
1212 if ( HIWORD(*plparam) > CTLCOLOR_STATIC ) return -1;
1213 *pmsg32 = WM_CTLCOLORMSGBOX + HIWORD(*plparam);
1214 *pwparam32 = (WPARAM)HDC_32(wParam16);
1215 *plparam = (LPARAM)WIN_Handle32( LOWORD(*plparam) );
1217 case WM_COMPAREITEM:
1219 COMPAREITEMSTRUCT16* cis16 = MapSL(*plparam);
1220 COMPAREITEMSTRUCT *cis = (COMPAREITEMSTRUCT *)
1221 HeapAlloc(GetProcessHeap(), 0, sizeof(*cis));
1222 if (!cis) return -1;
1223 cis->CtlType = cis16->CtlType;
1224 cis->CtlID = cis16->CtlID;
1225 cis->hwndItem = WIN_Handle32( cis16->hwndItem );
1226 cis->itemID1 = cis16->itemID1;
1227 cis->itemData1 = cis16->itemData1;
1228 cis->itemID2 = cis16->itemID2;
1229 cis->itemData2 = cis16->itemData2;
1230 cis->dwLocaleId = 0; /* FIXME */
1231 *plparam = (LPARAM)cis;
1236 DELETEITEMSTRUCT16* dis16 = MapSL(*plparam);
1237 DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)
1238 HeapAlloc(GetProcessHeap(), 0, sizeof(*dis));
1239 if (!dis) return -1;
1240 dis->CtlType = dis16->CtlType;
1241 dis->CtlID = dis16->CtlID;
1242 dis->hwndItem = WIN_Handle32( dis16->hwndItem );
1243 dis->itemData = dis16->itemData;
1244 *plparam = (LPARAM)dis;
1247 case WM_MEASUREITEM:
1249 MEASUREITEMSTRUCT16* mis16 = MapSL(*plparam);
1250 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)
1251 HeapAlloc(GetProcessHeap(), 0,
1252 sizeof(*mis) + sizeof(LPARAM));
1253 if (!mis) return -1;
1254 mis->CtlType = mis16->CtlType;
1255 mis->CtlID = mis16->CtlID;
1256 mis->itemID = mis16->itemID;
1257 mis->itemWidth = mis16->itemWidth;
1258 mis->itemHeight = mis16->itemHeight;
1259 mis->itemData = mis16->itemData;
1260 *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */
1261 *plparam = (LPARAM)mis;
1266 DRAWITEMSTRUCT16* dis16 = MapSL(*plparam);
1267 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)HeapAlloc(GetProcessHeap(), 0,
1269 if (!dis) return -1;
1270 dis->CtlType = dis16->CtlType;
1271 dis->CtlID = dis16->CtlID;
1272 dis->itemID = dis16->itemID;
1273 dis->itemAction = dis16->itemAction;
1274 dis->itemState = dis16->itemState;
1275 dis->hwndItem = (dis->CtlType == ODT_MENU) ? (HWND)HMENU_32(dis16->hwndItem)
1276 : WIN_Handle32( dis16->hwndItem );
1277 dis->hDC = HDC_32(dis16->hDC);
1278 dis->itemData = dis16->itemData;
1279 CONV_RECT16TO32( &dis16->rcItem, &dis->rcItem );
1280 *plparam = (LPARAM)dis;
1283 case WM_GETMINMAXINFO:
1285 MINMAXINFO *mmi = (MINMAXINFO *)HeapAlloc( GetProcessHeap(), 0,
1286 sizeof(*mmi) + sizeof(LPARAM));
1287 if (!mmi) return -1;
1288 STRUCT32_MINMAXINFO16to32( MapSL(*plparam), mmi );
1289 *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */
1290 *plparam = (LPARAM)mmi;
1295 case WM_WININICHANGE:
1296 case WM_DEVMODECHANGE:
1297 case WM_ASKCBFORMATNAME:
1298 *plparam = (LPARAM)MapSL(*plparam);
1302 MDICREATESTRUCT16 *cs16 = MapSL(*plparam);
1303 MDICREATESTRUCTA *cs = HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) + sizeof(LPARAM) );
1305 STRUCT32_MDICREATESTRUCT16to32A( cs16, cs );
1306 cs->szTitle = MapSL(cs16->szTitle);
1307 cs->szClass = MapSL(cs16->szClass);
1308 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1309 *plparam = (LPARAM)cs;
1312 case WM_MDIGETACTIVE:
1313 *plparam = (LPARAM)HeapAlloc( GetProcessHeap(), 0, sizeof(BOOL) );
1314 *(BOOL*)(*plparam) = 0;
1318 *pmsg32=WM_MDIREFRESHMENU;
1319 *pwparam32 = (WPARAM)HMENU_32(LOWORD(*plparam));
1320 *plparam = (LPARAM)HMENU_32(HIWORD(*plparam));
1323 *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
1324 *plparam = (LPARAM)HMENU_32(HIWORD(*plparam));
1327 if((LOWORD(*plparam) & MF_POPUP) && (LOWORD(*plparam) != 0xFFFF))
1329 HMENU hmenu=HMENU_32(HIWORD(*plparam));
1330 UINT Pos=MENU_FindSubMenu( &hmenu, HMENU_32(wParam16));
1331 if(Pos==0xFFFF) Pos=0; /* NO_SELECTED_ITEM */
1332 *pwparam32 = MAKEWPARAM( Pos, LOWORD(*plparam) );
1334 else *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
1335 *plparam = (LPARAM)HMENU_32(HIWORD(*plparam));
1337 case WM_MDIACTIVATE:
1340 *pwparam32 = (WPARAM)WIN_Handle32( HIWORD(*plparam) );
1341 *plparam = (LPARAM)WIN_Handle32( LOWORD(*plparam) );
1343 else /* message sent to MDI client */
1344 *pwparam32 = wParam16;
1348 NCCALCSIZE_PARAMS16 *nc16;
1349 NCCALCSIZE_PARAMS *nc;
1351 nc = (NCCALCSIZE_PARAMS *)HeapAlloc( GetProcessHeap(), 0,
1352 sizeof(*nc) + sizeof(LPARAM) );
1354 nc16 = MapSL(*plparam);
1355 CONV_RECT16TO32( &nc16->rgrc[0], &nc->rgrc[0] );
1358 nc->lppos = (WINDOWPOS *)HeapAlloc( GetProcessHeap(), 0,
1359 sizeof(*nc->lppos) );
1360 CONV_RECT16TO32( &nc16->rgrc[1], &nc->rgrc[1] );
1361 CONV_RECT16TO32( &nc16->rgrc[2], &nc->rgrc[2] );
1362 if (nc->lppos) STRUCT32_WINDOWPOS16to32( MapSL(nc16->lppos), nc->lppos );
1364 *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */
1365 *plparam = (LPARAM)nc;
1371 CREATESTRUCT16 *cs16 = MapSL(*plparam);
1372 CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0,
1373 sizeof(*cs) + sizeof(LPARAM) );
1375 STRUCT32_CREATESTRUCT16to32A( cs16, cs );
1376 cs->lpszName = MapSL(cs16->lpszName);
1377 cs->lpszClass = MapSL(cs16->lpszClass);
1378 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1379 *plparam = (LPARAM)cs;
1382 case WM_PARENTNOTIFY:
1383 if ((wParam16 == WM_CREATE) || (wParam16 == WM_DESTROY))
1385 *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
1386 *plparam = (LPARAM)WIN_Handle32( LOWORD(*plparam) );
1389 case WM_WINDOWPOSCHANGING:
1390 case WM_WINDOWPOSCHANGED:
1392 WINDOWPOS *wp = (WINDOWPOS *)HeapAlloc( GetProcessHeap(), 0,
1393 sizeof(*wp) + sizeof(LPARAM) );
1395 STRUCT32_WINDOWPOS16to32( MapSL(*plparam), wp );
1396 *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */
1397 *plparam = (LPARAM)wp;
1403 LPMSG16 msg16 = MapSL(*plparam);
1404 LPMSG msg32 = (LPMSG)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG) );
1406 if (!msg32) return -1;
1407 msg32->hwnd = WIN_Handle32( msg16->hwnd );
1408 msg32->lParam = msg16->lParam;
1409 msg32->time = msg16->time;
1410 CONV_POINT16TO32(&msg16->pt,&msg32->pt);
1411 /* this is right, right? */
1412 if (WINPROC_MapMsg16To32A( msg32->hwnd, msg16->message,msg16->wParam,
1413 &msg32->message,&msg32->wParam,
1414 &msg32->lParam)<0) {
1415 HeapFree( GetProcessHeap(), 0, msg32 );
1418 *plparam = (LPARAM)msg32;
1423 *plparam = (LPARAM)MapSL(*plparam);
1425 case WM_ACTIVATEAPP:
1426 /* We need this when SetActiveWindow sends a Sendmessage16() to
1427 * a 32bit window. Might be superflous with 32bit interprocess
1428 * message queues. */
1429 if (*plparam) *plparam = HTASK_32( *plparam );
1433 MDINEXTMENU *next = HeapAlloc( GetProcessHeap(), 0, sizeof(*next) );
1434 if (!next) return -1;
1435 next->hmenuIn = (HMENU)*plparam;
1436 next->hmenuNext = 0;
1438 *plparam = (LPARAM)next;
1441 case WM_PAINTCLIPBOARD:
1442 case WM_SIZECLIPBOARD:
1443 FIXME_(msg)("message %04x needs translation\n",msg16 );
1445 case WM_DDE_INITIATE:
1446 case WM_DDE_TERMINATE:
1447 case WM_DDE_UNADVISE:
1448 case WM_DDE_REQUEST:
1449 *pwparam32 = (WPARAM)WIN_Handle32(wParam16);
1459 *pwparam32 = (WPARAM)WIN_Handle32(wParam16);
1460 lo16 = LOWORD(*plparam);
1461 hi = HIWORD(*plparam);
1462 if (lo16 && !(lo32 = convert_handle_16_to_32(lo16, GMEM_DDESHARE)))
1464 *plparam = PackDDElParam(msg16, lo32, hi);
1466 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1473 *pwparam32 = (WPARAM)WIN_Handle32(wParam16);
1475 lo = LOWORD(*plparam);
1476 hi = HIWORD(*plparam);
1478 if (GlobalGetAtomNameA(hi, buf, 2) > 0) flag |= 1;
1479 if (GlobalSize16(hi) != 0) flag |= 2;
1485 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
1490 break; /* atom, nothing to do */
1492 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi);
1495 hi = convert_handle_16_to_32(hi, GMEM_DDESHARE);
1498 *plparam = PackDDElParam(WM_DDE_ACK, lo, hi);
1500 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1501 case WM_DDE_EXECUTE:
1502 *plparam = convert_handle_16_to_32(*plparam, GMEM_DDESHARE);
1503 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1504 default: /* No translation needed */
1510 /**********************************************************************
1511 * WINPROC_UnmapMsg16To32A
1513 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1515 LRESULT WINPROC_UnmapMsg16To32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
1520 case WM_COMPAREITEM:
1523 HeapFree( GetProcessHeap(), 0, (LPVOID)lParam );
1525 case WM_MEASUREITEM:
1527 MEASUREITEMSTRUCT16 *mis16;
1528 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam;
1529 lParam = *(LPARAM *)(mis + 1);
1530 mis16 = MapSL(lParam);
1531 mis16->itemWidth = (UINT16)mis->itemWidth;
1532 mis16->itemHeight = (UINT16)mis->itemHeight;
1533 HeapFree( GetProcessHeap(), 0, mis );
1536 case WM_GETMINMAXINFO:
1538 MINMAXINFO *mmi = (MINMAXINFO *)lParam;
1539 lParam = *(LPARAM *)(mmi + 1);
1540 STRUCT32_MINMAXINFO32to16( mmi, MapSL(lParam));
1541 HeapFree( GetProcessHeap(), 0, mmi );
1546 MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
1547 lParam = *(LPARAM *)(cs + 1);
1548 STRUCT32_MDICREATESTRUCT32Ato16( cs, MapSL(lParam) );
1549 HeapFree( GetProcessHeap(), 0, cs );
1552 case WM_MDIGETACTIVE:
1553 result = MAKELONG( LOWORD(result), (BOOL16)(*(BOOL *)lParam) );
1554 HeapFree( GetProcessHeap(), 0, (BOOL *)lParam );
1558 NCCALCSIZE_PARAMS16 *nc16;
1559 NCCALCSIZE_PARAMS *nc = (NCCALCSIZE_PARAMS *)lParam;
1560 lParam = *(LPARAM *)(nc + 1);
1561 nc16 = MapSL(lParam);
1562 CONV_RECT32TO16( &nc->rgrc[0], &nc16->rgrc[0] );
1565 CONV_RECT32TO16( &nc->rgrc[1], &nc16->rgrc[1] );
1566 CONV_RECT32TO16( &nc->rgrc[2], &nc16->rgrc[2] );
1569 STRUCT32_WINDOWPOS32to16( nc->lppos, MapSL(nc16->lppos));
1570 HeapFree( GetProcessHeap(), 0, nc->lppos );
1573 HeapFree( GetProcessHeap(), 0, nc );
1579 CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
1580 lParam = *(LPARAM *)(cs + 1);
1581 STRUCT32_CREATESTRUCT32Ato16( cs, MapSL(lParam) );
1582 HeapFree( GetProcessHeap(), 0, cs );
1585 case WM_WINDOWPOSCHANGING:
1586 case WM_WINDOWPOSCHANGED:
1588 WINDOWPOS *wp = (WINDOWPOS *)lParam;
1589 lParam = *(LPARAM *)(wp + 1);
1590 STRUCT32_WINDOWPOS32to16(wp, MapSL(lParam));
1591 HeapFree( GetProcessHeap(), 0, wp );
1597 LPMSG msg32 = (LPMSG)lParam;
1599 WINPROC_UnmapMsg16To32A( hwnd, msg32->message, msg32->wParam, msg32->lParam,
1601 HeapFree( GetProcessHeap(), 0, msg32 );
1606 MDINEXTMENU *next = (MDINEXTMENU *)lParam;
1607 result = MAKELONG( HMENU_16(next->hmenuNext), HWND_16(next->hwndNext) );
1608 HeapFree( GetProcessHeap(), 0, next );
1616 /**********************************************************************
1617 * WINPROC_MapMsg16To32W
1619 * Map a message from 16- to 32-bit Unicode.
1620 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1622 INT WINPROC_MapMsg16To32W( HWND hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
1623 WPARAM *pwparam32, LPARAM *plparam )
1628 *pmsg32=(UINT)msg16;
1629 *pwparam32 = (WPARAM)wParam16;
1634 case WM_WININICHANGE:
1635 case WM_DEVMODECHANGE:
1636 case WM_ASKCBFORMATNAME:
1637 *plparam = (LPARAM)MapSL(*plparam);
1638 return WINPROC_MapMsg32ATo32W( hwnd, *pmsg32, pwparam32, plparam );
1639 case WM_GETTEXTLENGTH:
1640 case CB_GETLBTEXTLEN:
1642 return 1; /* need to map result */
1646 CREATESTRUCT16 *cs16 = MapSL(*plparam);
1647 CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0,
1648 sizeof(*cs) + sizeof(LPARAM) );
1650 STRUCT32_CREATESTRUCT16to32A( cs16, (CREATESTRUCTA *)cs );
1651 cs->lpszName = map_str_16_to_32W(cs16->lpszName);
1652 cs->lpszClass = map_str_16_to_32W(cs16->lpszClass);
1653 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1654 *plparam = (LPARAM)cs;
1659 MDICREATESTRUCT16 *cs16 = MapSL(*plparam);
1660 MDICREATESTRUCTW *cs =
1661 (MDICREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0,
1662 sizeof(*cs) + sizeof(LPARAM) );
1664 STRUCT32_MDICREATESTRUCT16to32A( cs16, (MDICREATESTRUCTA *)cs );
1665 cs->szTitle = map_str_16_to_32W(cs16->szTitle);
1666 cs->szClass = map_str_16_to_32W(cs16->szClass);
1667 *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */
1668 *plparam = (LPARAM)cs;
1674 LPMSG16 msg16 = MapSL(*plparam);
1675 LPMSG msg32 = (LPMSG)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG) );
1677 if (!msg32) return -1;
1678 msg32->hwnd = WIN_Handle32( msg16->hwnd );
1679 msg32->lParam = msg16->lParam;
1680 msg32->time = msg16->time;
1681 CONV_POINT16TO32(&msg16->pt,&msg32->pt);
1682 /* this is right, right? */
1683 if (WINPROC_MapMsg16To32W(hwnd, msg16->message,msg16->wParam,
1684 &msg32->message,&msg32->wParam,
1685 &msg32->lParam)<0) {
1686 HeapFree( GetProcessHeap(), 0, msg32 );
1689 *plparam = (LPARAM)msg32;
1696 MultiByteToWideChar( CP_ACP, 0, &ch, 1, &wch, 1);
1697 *pwparam32 = MAKEWPARAM( wch, HIWORD(*plparam) );
1698 *plparam = (LPARAM)WIN_Handle32( LOWORD(*plparam) );
1702 MultiByteToWideChar( CP_ACP, 0, &ch, 1, &wch, 1);
1703 *pwparam32 = MAKEWPARAM( wch, LOWORD(*plparam) );
1704 *plparam = (LPARAM)HMENU_32(HIWORD(*plparam));
1709 case WM_SYSDEADCHAR:
1711 MultiByteToWideChar( CP_ACP, 0, &ch, 1, &wch, 1);
1717 ch[0] = (wParam16 >> 8);
1718 ch[1] = wParam16 & 0xff;
1719 MultiByteToWideChar(CP_ACP, 0, ch, 2, &wch, 1);
1724 default: /* No Unicode translation needed */
1725 return WINPROC_MapMsg16To32A( hwnd, msg16, wParam16, pmsg32,
1726 pwparam32, plparam );
1731 /**********************************************************************
1732 * WINPROC_UnmapMsg16To32W
1734 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1736 LRESULT WINPROC_UnmapMsg16To32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
1743 case WM_GETTEXTLENGTH:
1744 case CB_GETLBTEXTLEN:
1746 case WM_ASKCBFORMATNAME:
1747 return WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam, result );
1751 CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
1752 lParam = *(LPARAM *)(cs + 1);
1753 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA *)cs, MapSL(lParam) );
1754 unmap_str_16_to_32W( cs->lpszName );
1755 unmap_str_16_to_32W( cs->lpszClass );
1756 HeapFree( GetProcessHeap(), 0, cs );
1761 MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
1762 lParam = *(LPARAM *)(cs + 1);
1763 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA *)cs, MapSL(lParam) );
1764 unmap_str_16_to_32W( cs->szTitle );
1765 unmap_str_16_to_32W( cs->szClass );
1766 HeapFree( GetProcessHeap(), 0, cs );
1772 LPMSG msg32 = (LPMSG)lParam;
1774 WINPROC_UnmapMsg16To32W( hwnd, msg32->message, msg32->wParam, msg32->lParam,
1776 HeapFree( GetProcessHeap(), 0, msg32 );
1780 return WINPROC_UnmapMsg16To32A( hwnd, msg, wParam, lParam, result );
1785 static HANDLE16 convert_handle_32_to_16(UINT src, unsigned int flags)
1788 UINT sz = GlobalSize((HANDLE)src);
1791 if (!(dst = GlobalAlloc16(flags, sz)))
1793 ptr32 = GlobalLock((HANDLE)src);
1794 ptr16 = GlobalLock16(dst);
1795 if (ptr16 != NULL && ptr32 != NULL) memcpy(ptr16, ptr32, sz);
1796 GlobalUnlock((HANDLE)src);
1797 GlobalUnlock16(dst);
1803 /**********************************************************************
1804 * WINPROC_MapMsg32ATo16
1806 * Map a message from 32-bit Ansi to 16-bit.
1807 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1809 INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32,
1810 UINT16 *pmsg16, WPARAM16 *pwparam16,
1813 *pmsg16 = (UINT16)msg32;
1814 *pwparam16 = (WPARAM16)LOWORD(wParam32);
1822 *pmsg16 = (UINT16)msg32 + (BM_GETCHECK16 - BM_GETCHECK);
1831 case EM_SCROLLCARET:
1834 case EM_GETLINECOUNT:
1846 case EM_LINEFROMCHAR:
1847 case EM_SETTABSTOPS:
1848 case EM_SETPASSWORDCHAR:
1849 case EM_EMPTYUNDOBUFFER:
1850 case EM_GETFIRSTVISIBLELINE:
1851 case EM_SETREADONLY:
1852 case EM_SETWORDBREAKPROC:
1853 case EM_GETWORDBREAKPROC:
1854 case EM_GETPASSWORDCHAR:
1855 *pmsg16 = (UINT16)msg32 + (EM_GETSEL16 - EM_GETSEL);
1860 case LB_DELETESTRING:
1861 case LB_GETANCHORINDEX:
1862 case LB_GETCARETINDEX:
1865 case LB_GETHORIZONTALEXTENT:
1866 case LB_GETITEMDATA:
1867 case LB_GETITEMHEIGHT:
1869 case LB_GETSELCOUNT:
1871 case LB_GETTOPINDEX:
1872 case LB_RESETCONTENT:
1873 case LB_SELITEMRANGE:
1874 case LB_SELITEMRANGEEX:
1875 case LB_SETANCHORINDEX:
1876 case LB_SETCARETINDEX:
1877 case LB_SETCOLUMNWIDTH:
1879 case LB_SETHORIZONTALEXTENT:
1880 case LB_SETITEMDATA:
1881 case LB_SETITEMHEIGHT:
1883 case LB_SETTOPINDEX:
1884 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
1886 case CB_DELETESTRING:
1888 case CB_GETLBTEXTLEN:
1890 case CB_RESETCONTENT:
1894 case CB_SHOWDROPDOWN:
1895 case CB_SETITEMDATA:
1896 case CB_SETITEMHEIGHT:
1897 case CB_GETITEMHEIGHT:
1898 case CB_SETEXTENDEDUI:
1899 case CB_GETEXTENDEDUI:
1900 case CB_GETDROPPEDSTATE:
1901 *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL);
1904 *pmsg16 = CB_GETEDITSEL16;
1909 case LB_FINDSTRINGEXACT:
1910 case LB_INSERTSTRING:
1911 case LB_SELECTSTRING:
1914 *plparam = (LPARAM)MapLS( (LPSTR)*plparam );
1915 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
1920 case CB_FINDSTRINGEXACT:
1921 case CB_INSERTSTRING:
1922 case CB_SELECTSTRING:
1924 *plparam = (LPARAM)MapLS( (LPSTR)*plparam );
1925 *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL);
1928 case LB_GETITEMRECT:
1930 RECT16 *rect = HeapAlloc( GetProcessHeap(), 0, sizeof(RECT16) + sizeof(LPARAM) );
1931 if (!rect) return -1;
1932 *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */
1933 *plparam = MapLS( rect );
1935 *pmsg16 = LB_GETITEMRECT16;
1937 case LB_GETSELITEMS:
1940 *pwparam16 = (WPARAM16)min( wParam32, 0x7f80 ); /* Must be < 64K */
1941 if (!(items = HeapAlloc( GetProcessHeap(), 0,
1942 *pwparam16 * sizeof(INT16) + sizeof(LPARAM)))) return -1;
1943 *((LPARAM *)items)++ = *plparam; /* Store the previous lParam */
1944 *plparam = MapLS( items );
1946 *pmsg16 = LB_GETSELITEMS16;
1948 case LB_SETTABSTOPS:
1953 *pwparam16 = (WPARAM16)min( wParam32, 0x7f80 ); /* Must be < 64K */
1954 if (!(stops = HeapAlloc( GetProcessHeap(), 0,
1955 *pwparam16 * sizeof(INT16) + sizeof(LPARAM)))) return -1;
1956 for (i = 0; i < *pwparam16; i++) stops[i] = *((LPINT)*plparam+i);
1957 *plparam = MapLS( stops );
1960 *pmsg16 = LB_SETTABSTOPS16;
1963 case CB_GETDROPPEDCONTROLRECT:
1965 RECT16 *rect = HeapAlloc( GetProcessHeap(), 0, sizeof(RECT16) + sizeof(LPARAM) );
1966 if (!rect) return -1;
1967 *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */
1968 *plparam = (LPARAM)MapLS(rect);
1970 *pmsg16 = CB_GETDROPPEDCONTROLRECT16;
1974 *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) );
1975 *pmsg16 = LB_GETTEXT16;
1979 *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) );
1980 *pmsg16 = CB_GETLBTEXT16;
1985 *plparam = MAKELONG( (INT16)(INT)wParam32, (INT16)*plparam );
1986 *pmsg16 = EM_SETSEL16;
1993 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32) );
1997 *plparam = MAKELPARAM( HIWORD(wParam32), (HWND16)*plparam );
1999 case WM_CTLCOLORMSGBOX:
2000 case WM_CTLCOLOREDIT:
2001 case WM_CTLCOLORLISTBOX:
2002 case WM_CTLCOLORBTN:
2003 case WM_CTLCOLORDLG:
2004 case WM_CTLCOLORSCROLLBAR:
2005 case WM_CTLCOLORSTATIC:
2006 *pmsg16 = WM_CTLCOLOR;
2007 *plparam = MAKELPARAM( (HWND16)*plparam,
2008 (WORD)msg32 - WM_CTLCOLORMSGBOX );
2010 case WM_COMPAREITEM:
2012 COMPAREITEMSTRUCT *cis32 = (COMPAREITEMSTRUCT *)*plparam;
2013 COMPAREITEMSTRUCT16 *cis = HeapAlloc( GetProcessHeap(), 0, sizeof(COMPAREITEMSTRUCT16));
2014 if (!cis) return -1;
2015 cis->CtlType = (UINT16)cis32->CtlType;
2016 cis->CtlID = (UINT16)cis32->CtlID;
2017 cis->hwndItem = HWND_16( cis32->hwndItem );
2018 cis->itemID1 = (UINT16)cis32->itemID1;
2019 cis->itemData1 = cis32->itemData1;
2020 cis->itemID2 = (UINT16)cis32->itemID2;
2021 cis->itemData2 = cis32->itemData2;
2022 *plparam = MapLS( cis );
2027 DELETEITEMSTRUCT *dis32 = (DELETEITEMSTRUCT *)*plparam;
2028 DELETEITEMSTRUCT16 *dis = HeapAlloc( GetProcessHeap(), 0, sizeof(DELETEITEMSTRUCT16) );
2029 if (!dis) return -1;
2030 dis->CtlType = (UINT16)dis32->CtlType;
2031 dis->CtlID = (UINT16)dis32->CtlID;
2032 dis->itemID = (UINT16)dis32->itemID;
2033 dis->hwndItem = (dis->CtlType == ODT_MENU) ? (HWND16)LOWORD(dis32->hwndItem)
2034 : HWND_16( dis32->hwndItem );
2035 dis->itemData = dis32->itemData;
2036 *plparam = MapLS( dis );
2041 DRAWITEMSTRUCT *dis32 = (DRAWITEMSTRUCT *)*plparam;
2042 DRAWITEMSTRUCT16 *dis = HeapAlloc( GetProcessHeap(), 0, sizeof(DRAWITEMSTRUCT16) );
2043 if (!dis) return -1;
2044 dis->CtlType = (UINT16)dis32->CtlType;
2045 dis->CtlID = (UINT16)dis32->CtlID;
2046 dis->itemID = (UINT16)dis32->itemID;
2047 dis->itemAction = (UINT16)dis32->itemAction;
2048 dis->itemState = (UINT16)dis32->itemState;
2049 dis->hwndItem = HWND_16( dis32->hwndItem );
2050 dis->hDC = HDC_16(dis32->hDC);
2051 dis->itemData = dis32->itemData;
2052 CONV_RECT32TO16( &dis32->rcItem, &dis->rcItem );
2053 *plparam = MapLS( dis );
2056 case WM_MEASUREITEM:
2058 MEASUREITEMSTRUCT *mis32 = (MEASUREITEMSTRUCT *)*plparam;
2059 MEASUREITEMSTRUCT16 *mis = HeapAlloc( GetProcessHeap(), 0, sizeof(*mis)+sizeof(LPARAM));
2060 if (!mis) return -1;
2061 mis->CtlType = (UINT16)mis32->CtlType;
2062 mis->CtlID = (UINT16)mis32->CtlID;
2063 mis->itemID = (UINT16)mis32->itemID;
2064 mis->itemWidth = (UINT16)mis32->itemWidth;
2065 mis->itemHeight = (UINT16)mis32->itemHeight;
2066 mis->itemData = mis32->itemData;
2067 *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */
2068 *plparam = MapLS( mis );
2071 case WM_GETMINMAXINFO:
2073 MINMAXINFO16 *mmi = HeapAlloc( GetProcessHeap(), 0, sizeof(*mmi) + sizeof(LPARAM) );
2074 if (!mmi) return -1;
2075 STRUCT32_MINMAXINFO32to16( (MINMAXINFO *)*plparam, mmi );
2076 *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */
2077 *plparam = MapLS( mmi );
2081 case WM_ASKCBFORMATNAME:
2084 *pwparam16 = (WPARAM16)min( wParam32, 0xff80 ); /* Must be < 64K */
2085 if (!(str = HeapAlloc( GetProcessHeap(), 0, *pwparam16 + sizeof(LPARAM)))) return -1;
2086 *((LPARAM *)str)++ = *plparam; /* Store the previous lParam */
2087 *plparam = MapLS( str );
2092 MDICREATESTRUCT16 *cs;
2093 MDICREATESTRUCTA *cs32 = (MDICREATESTRUCTA *)*plparam;
2095 if (!(cs = HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16) ))) return -1;
2096 STRUCT32_MDICREATESTRUCT32Ato16( cs32, cs );
2097 cs->szTitle = MapLS( cs32->szTitle );
2098 cs->szClass = MapLS( cs32->szClass );
2099 *plparam = MapLS( cs );
2102 case WM_MDIGETACTIVE:
2105 *plparam = MAKELPARAM( (HMENU16)LOWORD(wParam32),
2106 (HMENU16)LOWORD(*plparam) );
2107 *pwparam16 = (*plparam == 0);
2110 if(HIWORD(wParam32) & MF_POPUP)
2113 if (((UINT)HIWORD(wParam32) != 0xFFFF) || (*plparam))
2115 if((hmenu = GetSubMenu((HMENU)*plparam, *pwparam16)))
2116 *pwparam16=HMENU_16(hmenu);
2121 *plparam = MAKELPARAM( HIWORD(wParam32), (HMENU16)*plparam );
2123 case WM_MDIACTIVATE:
2124 if (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_MDICHILD)
2126 *pwparam16 = ((HWND)*plparam == hwnd);
2127 *plparam = MAKELPARAM( (HWND16)LOWORD(*plparam),
2128 (HWND16)LOWORD(wParam32) );
2132 *pwparam16 = HWND_16( (HWND)wParam32 );
2138 NCCALCSIZE_PARAMS *nc32 = (NCCALCSIZE_PARAMS *)*plparam;
2139 NCCALCSIZE_PARAMS16 *nc = HeapAlloc( GetProcessHeap(), 0, sizeof(*nc) + sizeof(LPARAM));
2142 CONV_RECT32TO16( &nc32->rgrc[0], &nc->rgrc[0] );
2146 CONV_RECT32TO16( &nc32->rgrc[1], &nc->rgrc[1] );
2147 CONV_RECT32TO16( &nc32->rgrc[2], &nc->rgrc[2] );
2148 if (!(wp = HeapAlloc( GetProcessHeap(), 0, sizeof(WINDOWPOS16) )))
2150 HeapFree( GetProcessHeap(), 0, nc );
2153 STRUCT32_WINDOWPOS32to16( nc32->lppos, wp );
2154 nc->lppos = MapLS( wp );
2156 *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */
2157 *plparam = MapLS( nc );
2164 CREATESTRUCTA *cs32 = (CREATESTRUCTA *)*plparam;
2166 if (!(cs = HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16) ))) return -1;
2167 STRUCT32_CREATESTRUCT32Ato16( cs32, cs );
2168 cs->lpszName = MapLS( cs32->lpszName );
2169 cs->lpszClass = MapLS( cs32->lpszClass );
2170 *plparam = MapLS( cs );
2173 case WM_PARENTNOTIFY:
2174 if ((LOWORD(wParam32)==WM_CREATE) || (LOWORD(wParam32)==WM_DESTROY))
2175 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32));
2176 /* else nothing to do */
2179 *plparam = MapLS( (NMHDR *)*plparam ); /* NMHDR is already 32-bit */
2182 case WM_WININICHANGE:
2183 case WM_DEVMODECHANGE:
2184 *plparam = MapLS( (LPSTR)*plparam );
2186 case WM_WINDOWPOSCHANGING:
2187 case WM_WINDOWPOSCHANGED:
2189 WINDOWPOS16 *wp = HeapAlloc( GetProcessHeap(), 0, sizeof(*wp) + sizeof(LPARAM) );
2191 STRUCT32_WINDOWPOS32to16( (WINDOWPOS *)*plparam, wp );
2192 *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */
2193 *plparam = MapLS( wp );
2198 LPMSG msg32 = (LPMSG) *plparam;
2199 LPMSG16 msg16 = HeapAlloc( GetProcessHeap(), 0, sizeof(MSG16) );
2201 if (!msg16) return -1;
2202 msg16->hwnd = HWND_16( msg32->hwnd );
2203 msg16->lParam = msg32->lParam;
2204 msg16->time = msg32->time;
2205 CONV_POINT32TO16(&msg32->pt,&msg16->pt);
2206 /* this is right, right? */
2207 if (WINPROC_MapMsg32ATo16(msg32->hwnd,msg32->message,msg32->wParam,
2208 &msg16->message,&msg16->wParam, &msg16->lParam)<0)
2210 HeapFree( GetProcessHeap(), 0, msg16 );
2213 *plparam = MapLS( msg16 );
2218 case WM_ACTIVATEAPP:
2219 if (*plparam) *plparam = HTASK_16( (HANDLE)*plparam );
2223 MDINEXTMENU *next = (MDINEXTMENU *)*plparam;
2224 *plparam = (LPARAM)next->hmenuIn;
2227 case WM_PAINTCLIPBOARD:
2228 case WM_SIZECLIPBOARD:
2229 FIXME_(msg)("message %04x needs translation\n", msg32 );
2231 /* following messages should not be sent to 16-bit apps */
2234 case WM_CAPTURECHANGED:
2235 case WM_STYLECHANGING:
2236 case WM_STYLECHANGED:
2238 case WM_DDE_INITIATE:
2239 case WM_DDE_TERMINATE:
2240 case WM_DDE_UNADVISE:
2241 case WM_DDE_REQUEST:
2242 *pwparam16 = HWND_16((HWND)wParam32);
2251 *pwparam16 = HWND_16((HWND)wParam32);
2252 UnpackDDElParam(msg32, *plparam, &lo32, &hi);
2253 if (lo32 && !(lo16 = convert_handle_32_to_16(lo32, GMEM_DDESHARE)))
2255 *plparam = MAKELPARAM(lo16, hi);
2257 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2264 *pwparam16 = HWND_16((HWND)wParam32);
2266 UnpackDDElParam(msg32, *plparam, &lo, &hi);
2268 if (GlobalGetAtomNameA((ATOM)hi, buf, sizeof(buf)) > 0) flag |= 1;
2269 if (GlobalSize((HANDLE)hi) != 0) flag |= 2;
2275 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
2280 break; /* atom, nothing to do */
2282 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi);
2285 hi = convert_handle_32_to_16(hi, GMEM_DDESHARE);
2288 *plparam = MAKELPARAM(lo, hi);
2290 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2291 case WM_DDE_EXECUTE:
2292 *plparam = convert_handle_32_to_16(*plparam, GMEM_DDESHARE);
2293 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2294 default: /* No translation needed */
2300 /**********************************************************************
2301 * WINPROC_UnmapMsg32ATo16
2303 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
2305 void WINPROC_UnmapMsg32ATo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
2314 case LB_FINDSTRINGEXACT:
2315 case LB_INSERTSTRING:
2316 case LB_SELECTSTRING:
2320 case CB_FINDSTRINGEXACT:
2321 case CB_INSERTSTRING:
2322 case CB_SELECTSTRING:
2326 case WM_WININICHANGE:
2327 case WM_DEVMODECHANGE:
2328 UnMapLS( (SEGPTR)p16->lParam );
2330 case LB_SETTABSTOPS:
2331 case WM_COMPAREITEM:
2335 void *ptr = MapSL( p16->lParam );
2336 UnMapLS( p16->lParam );
2337 HeapFree( GetProcessHeap(), 0, ptr );
2340 case CB_GETDROPPEDCONTROLRECT:
2341 case LB_GETITEMRECT:
2343 RECT16 *rect = MapSL(p16->lParam);
2344 UnMapLS( p16->lParam );
2345 p16->lParam = *(LPARAM *)(rect + 1);
2346 CONV_RECT16TO32( rect, (RECT *)(p16->lParam));
2347 HeapFree( GetProcessHeap(), 0, rect );
2350 case LB_GETSELITEMS:
2353 LPINT16 items = MapSL(p16->lParam);
2354 UnMapLS( p16->lParam );
2355 p16->lParam = *((LPARAM *)items - 1);
2356 for (i = 0; i < p16->wParam; i++) *((LPINT)(p16->lParam) + i) = items[i];
2357 HeapFree( GetProcessHeap(), 0, (LPARAM *)items - 1 );
2363 *((PUINT)(wParam)) = LOWORD(p16->lResult);
2365 *((PUINT)(lParam)) = HIWORD(p16->lResult); /* FIXME: substract 1? */
2368 case WM_MEASUREITEM:
2370 MEASUREITEMSTRUCT16 *mis = MapSL(p16->lParam);
2371 MEASUREITEMSTRUCT *mis32 = *(MEASUREITEMSTRUCT **)(mis + 1);
2372 mis32->itemWidth = mis->itemWidth;
2373 mis32->itemHeight = mis->itemHeight;
2374 UnMapLS( p16->lParam );
2375 HeapFree( GetProcessHeap(), 0, mis );
2378 case WM_GETMINMAXINFO:
2380 MINMAXINFO16 *mmi = MapSL(p16->lParam);
2381 UnMapLS( p16->lParam );
2382 p16->lParam = *(LPARAM *)(mmi + 1);
2383 STRUCT32_MINMAXINFO16to32( mmi, (MINMAXINFO *)(p16->lParam) );
2384 HeapFree( GetProcessHeap(), 0, mmi );
2388 case WM_ASKCBFORMATNAME:
2390 LPSTR str = MapSL(p16->lParam);
2391 UnMapLS( p16->lParam );
2392 p16->lParam = *((LPARAM *)str - 1);
2393 lstrcpynA( (LPSTR)(p16->lParam), str, p16->wParam );
2394 HeapFree( GetProcessHeap(), 0, (LPARAM *)str - 1 );
2399 MDICREATESTRUCT16 *cs = MapSL(p16->lParam);
2400 UnMapLS( cs->szTitle );
2401 UnMapLS( cs->szClass );
2402 UnMapLS( p16->lParam );
2403 HeapFree( GetProcessHeap(), 0, cs );
2406 case WM_MDIGETACTIVE:
2407 if (lParam) *(BOOL *)lParam = (BOOL16)HIWORD(p16->lResult);
2408 p16->lResult = (LRESULT)WIN_Handle32( LOWORD(p16->lResult) );
2412 NCCALCSIZE_PARAMS *nc32;
2413 NCCALCSIZE_PARAMS16 *nc = MapSL(p16->lParam);
2414 UnMapLS( p16->lParam );
2415 p16->lParam = *(LPARAM *)(nc + 1);
2416 nc32 = (NCCALCSIZE_PARAMS *)(p16->lParam);
2417 CONV_RECT16TO32( &nc->rgrc[0], &nc32->rgrc[0] );
2420 WINDOWPOS16 *pos = MapSL(nc->lppos);
2421 UnMapLS( nc->lppos );
2422 CONV_RECT16TO32( &nc->rgrc[1], &nc32->rgrc[1] );
2423 CONV_RECT16TO32( &nc->rgrc[2], &nc32->rgrc[2] );
2424 STRUCT32_WINDOWPOS16to32( pos, nc32->lppos );
2425 HeapFree( GetProcessHeap(), 0, pos );
2427 HeapFree( GetProcessHeap(), 0, nc );
2433 CREATESTRUCT16 *cs = MapSL(p16->lParam);
2434 UnMapLS( p16->lParam );
2435 UnMapLS( cs->lpszName );
2436 UnMapLS( cs->lpszClass );
2437 HeapFree( GetProcessHeap(), 0, cs );
2440 case WM_WINDOWPOSCHANGING:
2441 case WM_WINDOWPOSCHANGED:
2443 WINDOWPOS16 *wp = MapSL(p16->lParam);
2444 UnMapLS( p16->lParam );
2445 p16->lParam = *(LPARAM *)(wp + 1);
2446 STRUCT32_WINDOWPOS16to32( wp, (WINDOWPOS *)p16->lParam );
2447 HeapFree( GetProcessHeap(), 0, wp );
2451 UnMapLS(p16->lParam);
2456 LPMSG16 msg16 = MapSL(p16->lParam);
2458 UnMapLS( p16->lParam );
2459 msgp16.wParam=msg16->wParam;
2460 msgp16.lParam=msg16->lParam;
2461 WINPROC_UnmapMsg32ATo16(((LPMSG)lParam)->hwnd, ((LPMSG)lParam)->message,
2462 ((LPMSG)lParam)->wParam, ((LPMSG)lParam)->lParam,
2464 HeapFree( GetProcessHeap(), 0, msg16 );
2469 MDINEXTMENU *next = (MDINEXTMENU *)lParam;
2470 next->hmenuNext = HMENU_32( LOWORD(p16->lResult) );
2471 next->hwndNext = WIN_Handle32( HIWORD(p16->lResult) );
2479 /**********************************************************************
2480 * WINPROC_MapMsg32WTo16
2482 * Map a message from 32-bit Unicode to 16-bit.
2483 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
2485 INT WINPROC_MapMsg32WTo16( HWND hwnd, UINT msg32, WPARAM wParam32,
2486 UINT16 *pmsg16, WPARAM16 *pwparam16,
2492 *pmsg16 = LOWORD(msg32);
2493 *pwparam16 = LOWORD(wParam32);
2498 case LB_FINDSTRINGEXACT:
2499 case LB_INSERTSTRING:
2500 case LB_SELECTSTRING:
2503 *plparam = map_str_32W_to_16( (LPWSTR)*plparam );
2504 *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING);
2509 case CB_FINDSTRINGEXACT:
2510 case CB_INSERTSTRING:
2511 case CB_SELECTSTRING:
2513 *plparam = map_str_32W_to_16( (LPWSTR)*plparam );
2514 *pmsg16 = (UINT16)msg32 + (CB_ADDSTRING16 - CB_ADDSTRING);
2521 CREATESTRUCTW *cs32 = (CREATESTRUCTW *)*plparam;
2523 if (!(cs = HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16) ))) return -1;
2524 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA *)cs32, cs );
2525 cs->lpszName = map_str_32W_to_16( cs32->lpszName );
2526 cs->lpszClass = map_str_32W_to_16( cs32->lpszClass );
2527 *plparam = MapLS(cs);
2532 MDICREATESTRUCT16 *cs;
2533 MDICREATESTRUCTW *cs32 = (MDICREATESTRUCTW *)*plparam;
2535 if (!(cs = HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16) ))) return -1;
2536 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA *)cs32, cs );
2537 cs->szTitle = map_str_32W_to_16( cs32->szTitle );
2538 cs->szClass = map_str_32W_to_16( cs32->szClass );
2539 *plparam = MapLS(cs);
2543 case WM_WININICHANGE:
2544 case WM_DEVMODECHANGE:
2545 *plparam = map_str_32W_to_16( (LPWSTR)*plparam );
2549 if ( WINPROC_TestLBForStr( hwnd ))
2551 LPSTR str = HeapAlloc( GetProcessHeap(), 0, 256 ); /* FIXME: fixed sized buffer */
2552 if (!str) return -1;
2553 *pmsg16 = (msg32 == LB_GETTEXT)? LB_GETTEXT16 : CB_GETLBTEXT16;
2554 *plparam = (LPARAM)MapLS(str);
2559 wch = LOWORD(wParam32);
2560 WideCharToMultiByte( CP_ACP, 0, &wch, 1, &ch, 1, NULL, NULL);
2562 *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32) );
2565 wch = LOWORD(wParam32);
2566 WideCharToMultiByte( CP_ACP, 0, &wch, 1, &ch, 1, NULL, NULL);
2568 *plparam = MAKELPARAM( HIWORD(wParam32), (HMENU16)*plparam );
2573 case WM_SYSDEADCHAR:
2575 WideCharToMultiByte( CP_ACP, 0, &wch, 1, &ch, 1, NULL, NULL);
2585 WideCharToMultiByte( CP_ACP, 0, &wch, 1, ch, 2, NULL, NULL );
2586 *pwparam16 = (ch[0] << 8) | ch[1];
2590 default: /* No Unicode translation needed (?) */
2591 return WINPROC_MapMsg32ATo16( hwnd, msg32, wParam32, pmsg16,
2592 pwparam16, plparam );
2597 /**********************************************************************
2598 * WINPROC_UnmapMsg32WTo16
2600 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2602 void WINPROC_UnmapMsg32WTo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
2609 case LB_FINDSTRINGEXACT:
2610 case LB_INSERTSTRING:
2611 case LB_SELECTSTRING:
2616 case CB_FINDSTRINGEXACT:
2617 case CB_INSERTSTRING:
2618 case CB_SELECTSTRING:
2621 case WM_WININICHANGE:
2622 case WM_DEVMODECHANGE:
2623 unmap_str_32W_to_16( p16->lParam );
2628 CREATESTRUCT16 *cs = MapSL(p16->lParam);
2629 UnMapLS( p16->lParam );
2630 unmap_str_32W_to_16( cs->lpszName );
2631 unmap_str_32W_to_16( cs->lpszClass );
2632 HeapFree( GetProcessHeap(), 0, cs );
2637 MDICREATESTRUCT16 *cs = MapSL(p16->lParam);
2638 UnMapLS( p16->lParam );
2639 unmap_str_32W_to_16( cs->szTitle );
2640 unmap_str_32W_to_16( cs->szClass );
2641 HeapFree( GetProcessHeap(), 0, cs );
2645 case WM_ASKCBFORMATNAME:
2647 LPSTR str = MapSL(p16->lParam);
2648 UnMapLS( p16->lParam );
2649 p16->lParam = *((LPARAM *)str - 1);
2650 MultiByteToWideChar( CP_ACP, 0, str, -1, (LPWSTR)p16->lParam, 0x7fffffff );
2651 HeapFree( GetProcessHeap(), 0, (LPARAM *)str - 1 );
2656 if ( WINPROC_TestLBForStr( hwnd ))
2658 LPSTR str = MapSL(p16->lParam);
2659 UnMapLS( p16->lParam );
2660 MultiByteToWideChar( CP_ACP, 0, str, -1, (LPWSTR)lParam, 0x7fffffff );
2661 HeapFree( GetProcessHeap(), 0, (LPARAM *)str );
2665 WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, p16 );
2671 /**********************************************************************
2672 * WINPROC_CallProc32ATo32W
2674 * Call a window procedure, translating args from Ansi to Unicode.
2676 static LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd,
2677 UINT msg, WPARAM wParam,
2683 TRACE_(msg)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2684 func, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam);
2686 if( (unmap = WINPROC_MapMsg32ATo32W( hwnd, msg, &wParam, &lParam )) == -1) {
2687 ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
2688 SPY_GetMsgName(msg, hwnd), wParam, lParam );
2691 result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2692 if (unmap) result = WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam, result );
2697 /**********************************************************************
2698 * WINPROC_CallProc32WTo32A
2700 * Call a window procedure, translating args from Unicode to Ansi.
2702 static LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd,
2703 UINT msg, WPARAM wParam,
2709 TRACE_(msg)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2710 func, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam);
2712 if ((unmap = WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam )) == -1) {
2713 ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
2714 SPY_GetMsgName(msg, hwnd), wParam, lParam );
2717 result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2718 if( unmap ) WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
2723 /**********************************************************************
2724 * __wine_call_wndproc_32A (USER.1010)
2726 LRESULT WINAPI __wine_call_wndproc_32A( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam,
2732 HWND hwnd32 = WIN_Handle32( hwnd );
2734 if (WINPROC_MapMsg16To32A( hwnd32, msg, wParam, &msg32, &wParam32, &lParam ) == -1)
2736 result = WINPROC_CallWndProc( func, hwnd32, msg32, wParam32, lParam );
2737 return WINPROC_UnmapMsg16To32A( hwnd32, msg32, wParam32, lParam, result );
2741 /**********************************************************************
2742 * __wine_call_wndproc_32W (USER.1011)
2744 LRESULT WINAPI __wine_call_wndproc_32W( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam,
2750 HWND hwnd32 = WIN_Handle32( hwnd );
2752 if (WINPROC_MapMsg16To32W( hwnd32, msg, wParam, &msg32, &wParam32, &lParam ) == -1)
2754 result = WINPROC_CallWndProc( func, hwnd32, msg32, wParam32, lParam );
2755 return WINPROC_UnmapMsg16To32W( hwnd32, msg32, wParam32, lParam, result );
2759 /**********************************************************************
2760 * WINPROC_CallProc32ATo16
2762 * Call a 16-bit window procedure, translating the 32-bit args.
2764 static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND hwnd,
2765 UINT msg, WPARAM wParam,
2771 TRACE_(msg)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2772 func, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam);
2774 mp16.lParam = lParam;
2775 if (WINPROC_MapMsg32ATo16( hwnd, msg, wParam, &msg16, &mp16.wParam, &mp16.lParam ) == -1)
2777 mp16.lResult = WINPROC_CallWndProc16( func, HWND_16(hwnd), msg16,
2778 mp16.wParam, mp16.lParam );
2779 WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, &mp16 );
2780 return mp16.lResult;
2784 /**********************************************************************
2785 * WINPROC_CallProc32WTo16
2787 * Call a 16-bit window procedure, translating the 32-bit args.
2789 static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND hwnd,
2790 UINT msg, WPARAM wParam,
2796 TRACE_(msg)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2797 func, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam);
2799 mp16.lParam = lParam;
2800 if (WINPROC_MapMsg32WTo16( hwnd, msg, wParam, &msg16, &mp16.wParam,
2801 &mp16.lParam ) == -1)
2803 mp16.lResult = WINPROC_CallWndProc16( func, HWND_16(hwnd), msg16,
2804 mp16.wParam, mp16.lParam );
2805 WINPROC_UnmapMsg32WTo16( hwnd, msg, wParam, lParam, &mp16 );
2806 return mp16.lResult;
2810 /**********************************************************************
2811 * CallWindowProc (USER.122)
2813 LRESULT WINAPI CallWindowProc16( WNDPROC16 func, HWND16 hwnd, UINT16 msg,
2814 WPARAM16 wParam, LPARAM lParam )
2818 if (!func) return 0;
2820 if (!(proc = WINPROC_GetPtr( (WNDPROC)func )))
2821 return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam );
2824 func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_16 );
2825 return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam );
2831 if (!proc->thunk.t_from32.proc) return 0;
2832 return WINPROC_CallWndProc16( proc->thunk.t_from32.proc,
2833 hwnd, msg, wParam, lParam );
2835 if (!proc->thunk.t_from16.proc) return 0;
2836 return __wine_call_wndproc_32A( hwnd, msg, wParam, lParam, proc->thunk.t_from16.proc );
2838 if (!proc->thunk.t_from16.proc) return 0;
2839 return __wine_call_wndproc_32W( hwnd, msg, wParam, lParam, proc->thunk.t_from16.proc );
2841 WARN_(relay)("Invalid proc %p\n", proc );
2847 /**********************************************************************
2848 * CallWindowProcA (USER32.@)
2850 * The CallWindowProc() function invokes the windows procedure _func_,
2851 * with _hwnd_ as the target window, the message specified by _msg_, and
2852 * the message parameters _wParam_ and _lParam_.
2854 * Some kinds of argument conversion may be done, I'm not sure what.
2856 * CallWindowProc() may be used for windows subclassing. Use
2857 * SetWindowLong() to set a new windows procedure for windows of the
2858 * subclass, and handle subclassed messages in the new windows
2859 * procedure. The new windows procedure may then use CallWindowProc()
2860 * with _func_ set to the parent class's windows procedure to dispatch
2861 * the message to the superclass.
2865 * The return value is message dependent.
2871 LRESULT WINAPI CallWindowProcA(
2872 WNDPROC func, /* [in] window procedure */
2873 HWND hwnd, /* [in] target window */
2874 UINT msg, /* [in] message */
2875 WPARAM wParam, /* [in] message dependent parameter */
2876 LPARAM lParam /* [in] message dependent parameter */
2880 if (!func) return 0;
2882 if (!(proc = WINPROC_GetPtr( func )))
2883 return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2886 func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_32A );
2887 return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2893 if (!proc->thunk.t_from32.proc) return 0;
2894 return WINPROC_CallProc32ATo16( proc->thunk.t_from32.proc,
2895 hwnd, msg, wParam, lParam );
2897 if (!proc->thunk.t_from16.proc) return 0;
2898 return WINPROC_CallWndProc( proc->thunk.t_from16.proc,
2899 hwnd, msg, wParam, lParam );
2901 if (!proc->thunk.t_from16.proc) return 0;
2902 return WINPROC_CallProc32ATo32W( proc->thunk.t_from16.proc,
2903 hwnd, msg, wParam, lParam );
2905 WARN_(relay)("Invalid proc %p\n", proc );
2911 /**********************************************************************
2912 * CallWindowProcW (USER32.@)
2914 LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg,
2915 WPARAM wParam, LPARAM lParam )
2919 if (!func) return 0;
2921 if (!(proc = WINPROC_GetPtr( (WNDPROC)func )))
2922 return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2925 func = WINPROC_GetProc( (WNDPROC)proc, WIN_PROC_32W );
2926 return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
2932 if (!proc->thunk.t_from32.proc) return 0;
2933 return WINPROC_CallProc32WTo16( proc->thunk.t_from32.proc,
2934 hwnd, msg, wParam, lParam );
2936 if (!proc->thunk.t_from16.proc) return 0;
2937 return WINPROC_CallProc32WTo32A( proc->thunk.t_from16.proc,
2938 hwnd, msg, wParam, lParam );
2940 if (!proc->thunk.t_from16.proc) return 0;
2941 return WINPROC_CallWndProc( proc->thunk.t_from16.proc,
2942 hwnd, msg, wParam, lParam );
2944 WARN_(relay)("Invalid proc %p\n", proc );