2 * Window procedure callbacks
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1996 Alexandre Julliard
14 #include "wine/winbase16.h"
15 #include "wine/winuser16.h"
16 #include "stackframe.h"
17 #include "builtin16.h"
23 #include "debugtools.h"
28 DECLARE_DEBUG_CHANNEL(msg
);
29 DECLARE_DEBUG_CHANNEL(relay
);
30 DECLARE_DEBUG_CHANNEL(win
);
32 /* Window procedure 16-to-32-bit thunk,
33 * see BuildSpec16File() in tools/build.c */
38 WORD pushw_bp
; /* pushw %bp */
39 BYTE pushl_func
; /* pushl $proc */
41 WORD pushw_ax
; /* pushw %ax */
42 BYTE pushl_relay
; /* pushl $relay */
43 void (*relay
)(); /* WINPROC_Thunk16To32A/W() */
44 BYTE lcall
; /* lcall cs:glue */
45 void (*glue
)(); /* __wine_call_from_16_long */
46 WORD cs
; /* __FLATCS */
47 WORD lret
; /* lret $10 */
49 } WINPROC_THUNK_FROM16
;
52 /* Window procedure 32-to-16-bit thunk,
53 * see BuildSpec32File() in tools/build.c */
57 BYTE popl_eax
; /* popl %eax (return address) */
58 BYTE pushl_func
; /* pushl $proc */
59 WNDPROC16 proc WINE_PACKED
;
60 BYTE pushl_eax
; /* pushl %eax */
61 BYTE jmp
; /* jmp relay (relative jump)*/
62 void (*relay
)() WINE_PACKED
; /* WINPROC_CallProc32ATo16() */
63 } WINPROC_THUNK_FROM32
;
65 /* Simple jmp to call 32-bit procedure directly */
68 BYTE jmp
; /* jmp proc (relative jump) */
69 WNDPROC proc WINE_PACKED
;
74 WINPROC_THUNK_FROM16 t_from16
;
75 WINPROC_THUNK_FROM32 t_from32
;
78 typedef struct tagWINDOWPROC
80 WINPROC_THUNK thunk
; /* Thunk */
81 WINPROC_JUMP jmp
; /* Jump */
82 struct tagWINDOWPROC
*next
; /* Next window proc */
83 UINT magic
; /* Magic number */
84 WINDOWPROCTYPE type
; /* Function type */
85 WINDOWPROCUSER user
; /* Function user */
88 #define WINPROC_MAGIC ('W' | ('P' << 8) | ('R' << 16) | ('C' << 24))
90 #define WINPROC_THUNKPROC(pproc) \
91 (((pproc)->type == WIN_PROC_16) ? \
92 (WNDPROC16)((pproc)->thunk.t_from32.proc) : \
93 (WNDPROC16)((pproc)->thunk.t_from16.proc))
95 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
96 UINT msg
, WPARAM wParam
,
98 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
99 UINT msg
, WPARAM wParam
,
101 static LRESULT WINAPI
WINPROC_Thunk16To32A( WNDPROC func
, LPBYTE args
);
102 static LRESULT WINAPI
WINPROC_Thunk16To32W( WNDPROC func
, LPBYTE args
);
104 static HANDLE WinProcHeap
;
107 /**********************************************************************
110 BOOL
WINPROC_Init(void)
112 WinProcHeap
= HeapCreate( HEAP_WINE_SEGPTR
| HEAP_WINE_CODESEG
, 0, 0 );
115 WARN_(relay
)("Unable to create winproc heap\n" );
123 /* Some window procedures modify register they shouldn't, or are not
124 * properly declared stdcall; so we need a small assembly wrapper to
126 extern LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
127 WPARAM wParam
, LPARAM lParam
);
128 __ASM_GLOBAL_FUNC( WINPROC_wrapper
,
138 "movl 8(%ebp),%eax\n\t"
140 "leal -12(%ebp),%esp\n\t"
147 static inline LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
148 WPARAM wParam
, LPARAM lParam
)
150 return proc( hwnd
, msg
, wParam
, lParam
);
152 #endif /* __i386__ */
154 /**********************************************************************
155 * WINPROC_CallWndProc32
157 * Call a 32-bit WndProc.
159 static LRESULT
WINPROC_CallWndProc( WNDPROC proc
, HWND hwnd
, UINT msg
,
160 WPARAM wParam
, LPARAM lParam
)
165 hwnd
= WIN_GetFullHandle( hwnd
);
167 DPRINTF( "%08lx:Call window proc %p (hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n",
168 GetCurrentThreadId(), proc
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
169 /* To avoid any deadlocks, all the locks on the windows structures
170 must be suspended before the control is passed to the application */
171 iWndsLocks
= WIN_SuspendWndsLock();
172 retvalue
= WINPROC_wrapper( proc
, hwnd
, msg
, wParam
, lParam
);
173 WIN_RestoreWndsLock(iWndsLocks
);
176 DPRINTF( "%08lx:Ret window proc %p (hwnd=%08x,msg=%s,wp=%08x,lp=%08lx) retval=%08lx\n",
177 GetCurrentThreadId(), proc
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
, retvalue
);
181 /***********************************************************************
182 * WINPROC_CallWndProc16
184 * Call a 16-bit window procedure
186 static LRESULT WINAPI
WINPROC_CallWndProc16( WNDPROC16 proc
, HWND16 hwnd
,
187 UINT16 msg
, WPARAM16 wParam
,
194 TEB
*teb
= NtCurrentTeb();
197 /* Window procedures want ax = hInstance, ds = es = ss */
199 memset(&context
, '\0', sizeof(context
));
200 context
.SegDs
= context
.SegEs
= SELECTOROF(teb
->cur_stack
);
201 if (!(context
.Eax
= GetWindowWord16( hwnd
, GWL_HINSTANCE
))) context
.Eax
= context
.SegDs
;
202 context
.SegCs
= SELECTOROF(proc
);
203 context
.Eip
= OFFSETOF(proc
);
204 context
.Ebp
= OFFSETOF(teb
->cur_stack
)
205 + (WORD
)&((STACK16FRAME
*)0)->bp
;
209 /* Some programs (eg. the "Undocumented Windows" examples, JWP) only
210 work if structures passed in lParam are placed in the stack/data
211 segment. Programmers easily make the mistake of converting lParam
212 to a near rather than a far pointer, since Windows apparently
213 allows this. We copy the structures to the 16 bit stack; this is
214 ugly but makes these programs work. */
219 offset
= sizeof(CREATESTRUCT16
); break;
221 offset
= sizeof(DRAWITEMSTRUCT16
); break;
223 offset
= sizeof(COMPAREITEMSTRUCT16
); break;
227 void *s
= MapSL(lParam
);
228 lParam
= stack16_push( offset
);
229 memcpy( MapSL(lParam
), s
, offset
);
233 iWndsLocks
= WIN_SuspendWndsLock();
235 args
= (WORD
*)THREAD_STACK16(teb
) - 5;
236 args
[0] = LOWORD(lParam
);
237 args
[1] = HIWORD(lParam
);
242 wine_call_to_16_regs_short( &context
, 5 * sizeof(WORD
) );
243 ret
= MAKELONG( LOWORD(context
.Eax
), LOWORD(context
.Edx
) );
244 if (offset
) stack16_pop( offset
);
246 WIN_RestoreWndsLock(iWndsLocks
);
252 /**********************************************************************
255 * Return a pointer to the win proc.
257 static WINDOWPROC
*WINPROC_GetPtr( WNDPROC16 handle
)
262 /* ptr cannot be < 64K */
263 if (!HIWORD(handle
)) return NULL
;
265 /* Check for a linear pointer */
267 ptr
= (BYTE
*)handle
;
268 /* First check if it is the jmp address */
269 proc
= (WINDOWPROC
*)(ptr
- (int)&((WINDOWPROC
*)0)->jmp
);
270 if (HeapValidate( WinProcHeap
, 0, proc
) && (proc
->magic
== WINPROC_MAGIC
))
272 /* Now it must be the thunk address */
273 proc
= (WINDOWPROC
*)(ptr
- (int)&((WINDOWPROC
*)0)->thunk
);
274 if (HeapValidate( WinProcHeap
, 0, proc
) && (proc
->magic
== WINPROC_MAGIC
))
277 /* Check for a segmented pointer */
279 if (!IsBadReadPtr16( (SEGPTR
)handle
, sizeof(proc
->thunk
) ))
281 ptr
= MapSL( (SEGPTR
)handle
);
282 /* It must be the thunk address */
283 proc
= (WINDOWPROC
*)(ptr
- (int)&((WINDOWPROC
*)0)->thunk
);
284 if (HeapValidate( WinProcHeap
, 0, proc
) && (proc
->magic
== WINPROC_MAGIC
))
292 /**********************************************************************
293 * WINPROC_AllocWinProc
295 * Allocate a new window procedure.
297 static WINDOWPROC
*WINPROC_AllocWinProc( WNDPROC16 func
, WINDOWPROCTYPE type
,
298 WINDOWPROCUSER user
)
300 WINDOWPROC
*proc
, *oldproc
;
302 /* Allocate a window procedure */
304 if (!(proc
= HeapAlloc( WinProcHeap
, 0, sizeof(WINDOWPROC
) ))) return 0;
306 /* Check if the function is already a win proc */
308 if ((oldproc
= WINPROC_GetPtr( func
)))
317 proc
->thunk
.t_from32
.popl_eax
= 0x58; /* popl %eax */
318 proc
->thunk
.t_from32
.pushl_func
= 0x68; /* pushl $proc */
319 proc
->thunk
.t_from32
.proc
= func
;
320 proc
->thunk
.t_from32
.pushl_eax
= 0x50; /* pushl %eax */
321 proc
->thunk
.t_from32
.jmp
= 0xe9; /* jmp relay*/
322 proc
->thunk
.t_from32
.relay
= /* relative jump */
323 (void(*)())((DWORD
)WINPROC_CallProc32ATo16
-
324 (DWORD
)(&proc
->thunk
.t_from32
.relay
+ 1));
328 proc
->thunk
.t_from16
.pushw_bp
= 0x5566; /* pushw %bp */
329 proc
->thunk
.t_from16
.pushl_func
= 0x68; /* pushl $proc */
330 proc
->thunk
.t_from16
.proc
= (WNDPROC
)func
;
331 proc
->thunk
.t_from16
.pushw_ax
= 0x5066; /* pushw %ax */
332 proc
->thunk
.t_from16
.pushl_relay
= 0x68; /* pushl $relay */
333 proc
->thunk
.t_from16
.relay
= (type
== WIN_PROC_32A
) ?
334 (void(*)())WINPROC_Thunk16To32A
:
335 (void(*)())WINPROC_Thunk16To32W
;
336 proc
->thunk
.t_from16
.lcall
= 0x9a; /* lcall cs:glue */
337 proc
->thunk
.t_from16
.glue
= (void*)__wine_call_from_16_long
;
338 proc
->thunk
.t_from16
.cs
= __get_cs();
339 proc
->thunk
.t_from16
.lret
= 0xca66;
340 proc
->thunk
.t_from16
.nArgs
= 10;
341 proc
->jmp
.jmp
= 0xe9;
342 /* Fixup relative jump */
343 proc
->jmp
.proc
= (WNDPROC
)((DWORD
)func
-
344 (DWORD
)(&proc
->jmp
.proc
+ 1));
347 /* Should not happen */
350 proc
->magic
= WINPROC_MAGIC
;
355 TRACE_(win
)("(%08x,%d): returning %08x\n",
356 (UINT
)func
, type
, (UINT
)proc
);
361 /**********************************************************************
364 * Get a window procedure pointer that can be passed to the Windows program.
366 WNDPROC16
WINPROC_GetProc( HWINDOWPROC proc
, WINDOWPROCTYPE type
)
368 if (!proc
) return NULL
;
369 if (type
== WIN_PROC_16
) /* We want a 16:16 address */
371 if (((WINDOWPROC
*)proc
)->type
== WIN_PROC_16
)
372 return ((WINDOWPROC
*)proc
)->thunk
.t_from32
.proc
;
374 return (WNDPROC16
)HEAP_GetSegptr( WinProcHeap
, 0,
375 &((WINDOWPROC
*)proc
)->thunk
);
377 else /* We want a 32-bit address */
379 if (((WINDOWPROC
*)proc
)->type
== WIN_PROC_16
)
380 return (WNDPROC16
)&((WINDOWPROC
*)proc
)->thunk
;
381 else if (type
!= ((WINDOWPROC
*)proc
)->type
)
382 /* Have to return the jmp address if types don't match */
383 return (WNDPROC16
)&((WINDOWPROC
*)proc
)->jmp
;
385 /* Some Win16 programs want to get back the proc they set */
386 return (WNDPROC16
)((WINDOWPROC
*)proc
)->thunk
.t_from16
.proc
;
391 /**********************************************************************
394 * Set the window procedure for a window or class. There are
395 * three tree classes of winproc callbacks:
397 * 1) class -> wp - not subclassed
398 * class -> wp -> wp -> wp -> wp - SetClassLong()
400 * 2) window -' / - not subclassed
401 * window -> wp -> wp ' - SetWindowLong()
403 * 3) timer -> wp - SetTimer()
405 * Initially, winproc of the window points to the current winproc
406 * thunk of its class. Subclassing prepends a new thunk to the
407 * window winproc chain at the head of the list. Thus, window thunk
408 * list includes class thunks and the latter are preserved when the
409 * window is destroyed.
412 BOOL
WINPROC_SetProc( HWINDOWPROC
*pFirst
, WNDPROC16 func
,
413 WINDOWPROCTYPE type
, WINDOWPROCUSER user
)
415 BOOL bRecycle
= FALSE
;
416 WINDOWPROC
*proc
, **ppPrev
;
418 /* Check if function is already in the list */
420 ppPrev
= (WINDOWPROC
**)pFirst
;
421 proc
= WINPROC_GetPtr( func
);
428 if ((*ppPrev
)->user
!= user
)
430 /* terminal thunk is being restored */
432 WINPROC_FreeProc( *pFirst
, (*ppPrev
)->user
);
433 *(WINDOWPROC
**)pFirst
= *ppPrev
;
442 if (((*ppPrev
)->type
== type
) &&
443 (func
== WINPROC_THUNKPROC(*ppPrev
)))
450 /* WPF_CLASS thunk terminates window thunk list */
451 if ((*ppPrev
)->user
!= user
) break;
452 ppPrev
= &(*ppPrev
)->next
;
457 /* Extract this thunk from the list */
459 *ppPrev
= proc
->next
;
461 else /* Allocate a new one */
463 if (proc
) /* Was already a win proc */
466 func
= WINPROC_THUNKPROC(proc
);
468 proc
= WINPROC_AllocWinProc( func
, type
, user
);
469 if (!proc
) return FALSE
;
472 /* Add the win proc at the head of the list */
474 TRACE_(win
)("(%08x,%08x,%d): res=%08x\n",
475 (UINT
)*pFirst
, (UINT
)func
, type
, (UINT
)proc
);
476 proc
->next
= *(WINDOWPROC
**)pFirst
;
477 *(WINDOWPROC
**)pFirst
= proc
;
482 /**********************************************************************
485 * Free a list of win procs.
487 void WINPROC_FreeProc( HWINDOWPROC proc
, WINDOWPROCUSER user
)
491 WINDOWPROC
*next
= ((WINDOWPROC
*)proc
)->next
;
492 if (((WINDOWPROC
*)proc
)->user
!= user
) break;
493 TRACE_(win
)("freeing %08x\n", (UINT
)proc
);
494 HeapFree( WinProcHeap
, 0, proc
);
500 /**********************************************************************
501 * WINPROC_GetProcType
503 * Return the window procedure type.
505 WINDOWPROCTYPE
WINPROC_GetProcType( HWINDOWPROC proc
)
508 (((WINDOWPROC
*)proc
)->magic
!= WINPROC_MAGIC
))
509 return WIN_PROC_INVALID
;
510 return ((WINDOWPROC
*)proc
)->type
;
512 /**********************************************************************
513 * WINPROC_TestCBForStr
515 * Return TRUE if the lparam is a string
517 inline static BOOL
WINPROC_TestCBForStr( HWND hwnd
)
519 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
520 return (!(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) || (style
& CBS_HASSTRINGS
));
522 /**********************************************************************
523 * WINPROC_TestLBForStr
525 * Return TRUE if the lparam is a string
527 inline static BOOL
WINPROC_TestLBForStr( HWND hwnd
)
529 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
530 return (!(style
& (LBS_OWNERDRAWFIXED
| LBS_OWNERDRAWVARIABLE
)) || (style
& LBS_HASSTRINGS
));
533 /**********************************************************************
534 * WINPROC_MapMsg32ATo32W
536 * Map a message from Ansi to Unicode.
537 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
540 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
541 * the first four bytes are the handle of the icon
542 * when the WM_SETTEXT message has been used to set the icon
544 INT
WINPROC_MapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
549 case WM_ASKCBFORMATNAME
:
551 LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0,
552 *pwparam
* sizeof(WCHAR
) + sizeof(LPARAM
) );
554 *ptr
++ = *plparam
; /* Store previous lParam */
555 *plparam
= (LPARAM
)ptr
;
558 /* lparam is string (0-terminated) */
560 case WM_WININICHANGE
:
561 case WM_DEVMODECHANGE
:
564 case CB_FINDSTRINGEXACT
:
565 case CB_SELECTSTRING
:
569 case LB_FINDSTRINGEXACT
:
570 case LB_SELECTSTRING
:
572 if(!*plparam
) return 0;
573 *plparam
= (LPARAM
)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR
)*plparam
);
574 return (*plparam
? 1 : -1);
575 case WM_GETTEXTLENGTH
:
576 case CB_GETLBTEXTLEN
:
578 return 1; /* need to map result */
583 { CREATESTRUCTW cs
; /* new structure */
584 LPCWSTR lpszName
; /* allocated Name */
585 LPCWSTR lpszClass
; /* allocated Class */
588 struct s
*xs
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct s
));
590 xs
->cs
= *(CREATESTRUCTW
*)*plparam
;
591 if (HIWORD(xs
->cs
.lpszName
))
592 xs
->lpszName
= xs
->cs
.lpszName
= HEAP_strdupAtoW( GetProcessHeap(), 0,
593 (LPCSTR
)xs
->cs
.lpszName
);
594 if (HIWORD(xs
->cs
.lpszClass
))
595 xs
->lpszClass
= xs
->cs
.lpszClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
596 (LPCSTR
)xs
->cs
.lpszClass
);
597 *plparam
= (LPARAM
)xs
;
602 MDICREATESTRUCTW
*cs
=
603 (MDICREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
605 *cs
= *(MDICREATESTRUCTW
*)*plparam
;
606 if (HIWORD(cs
->szClass
))
607 cs
->szClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
608 (LPCSTR
)cs
->szClass
);
609 if (HIWORD(cs
->szTitle
))
610 cs
->szTitle
= HEAP_strdupAtoW( GetProcessHeap(), 0,
611 (LPCSTR
)cs
->szTitle
);
612 *plparam
= (LPARAM
)cs
;
618 case LB_INSERTSTRING
:
619 if(!*plparam
) return 0;
620 if ( WINPROC_TestLBForStr( hwnd
))
621 *plparam
= (LPARAM
)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR
)*plparam
);
622 return (*plparam
? 1 : -1);
624 case LB_GETTEXT
: /* fixme: fixed sized buffer */
625 { if ( WINPROC_TestLBForStr( hwnd
))
626 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR
) + sizeof(LPARAM
) );
628 *ptr
++ = *plparam
; /* Store previous lParam */
629 *plparam
= (LPARAM
)ptr
;
636 case CB_INSERTSTRING
:
637 if(!*plparam
) return 0;
638 if ( WINPROC_TestCBForStr( hwnd
))
639 *plparam
= (LPARAM
)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR
)*plparam
);
640 return (*plparam
? 1 : -1);
642 case CB_GETLBTEXT
: /* fixme: fixed sized buffer */
643 { if ( WINPROC_TestCBForStr( hwnd
))
644 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR
) + sizeof(LPARAM
) );
646 *ptr
++ = *plparam
; /* Store previous lParam */
647 *plparam
= (LPARAM
)ptr
;
654 { WORD len
= (WORD
)*plparam
;
655 LPARAM
*ptr
= (LPARAM
*) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(WCHAR
) );
657 *ptr
++ = *plparam
; /* Store previous lParam */
658 *((WORD
*) ptr
) = len
; /* Store the length */
659 *plparam
= (LPARAM
)ptr
;
669 case EM_SETPASSWORDCHAR
:
671 char ch
= LOWORD(*pwparam
);
673 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wch
, 1);
674 *pwparam
= MAKEWPARAM( wch
, HIWORD(*pwparam
) );
678 case WM_PAINTCLIPBOARD
:
679 case WM_SIZECLIPBOARD
:
680 FIXME_(msg
)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg
, hwnd
), msg
);
682 default: /* No translation needed */
688 /**********************************************************************
689 * WINPROC_UnmapMsg32ATo32W
691 * Unmap a message that was mapped from Ansi to Unicode.
693 LRESULT
WINPROC_UnmapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
699 case WM_ASKCBFORMATNAME
:
701 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
702 if (wParam
> 0 && !WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
703 (LPSTR
)*ptr
, wParam
, NULL
, NULL
))
704 ((LPSTR
)*ptr
)[wParam
-1] = 0;
705 HeapFree( GetProcessHeap(), 0, ptr
);
708 case WM_GETTEXTLENGTH
:
709 case CB_GETLBTEXTLEN
:
711 /* there may be one DBCS char for each Unicode char */
717 { CREATESTRUCTW cs
; /* new structure */
718 LPWSTR lpszName
; /* allocated Name */
719 LPWSTR lpszClass
; /* allocated Class */
721 struct s
*xs
= (struct s
*)lParam
;
722 if (xs
->lpszName
) HeapFree( GetProcessHeap(), 0, xs
->lpszName
);
723 if (xs
->lpszClass
) HeapFree( GetProcessHeap(), 0, xs
->lpszClass
);
724 HeapFree( GetProcessHeap(), 0, xs
);
730 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
731 if (HIWORD(cs
->szTitle
))
732 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
733 if (HIWORD(cs
->szClass
))
734 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
735 HeapFree( GetProcessHeap(), 0, cs
);
740 case WM_WININICHANGE
:
741 case WM_DEVMODECHANGE
:
744 case CB_FINDSTRINGEXACT
:
745 case CB_SELECTSTRING
:
749 case LB_FINDSTRINGEXACT
:
750 case LB_SELECTSTRING
:
752 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
757 case LB_INSERTSTRING
:
758 if ( WINPROC_TestLBForStr( hwnd
))
759 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
763 { if ( WINPROC_TestLBForStr( hwnd
))
764 { LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
765 WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1, (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
);
766 HeapFree( GetProcessHeap(), 0, ptr
);
773 case CB_INSERTSTRING
:
774 if ( WINPROC_TestCBForStr( hwnd
))
775 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
779 { if ( WINPROC_TestCBForStr( hwnd
))
780 { LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
781 WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1, (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
);
782 HeapFree( GetProcessHeap(), 0, ptr
);
789 { LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lParam */
790 WORD len
= *(WORD
*) lParam
;
791 if (len
> 0 && !WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
792 (LPSTR
)*ptr
, len
, NULL
, NULL
))
793 ((LPSTR
)*ptr
)[len
-1] = 0;
794 HeapFree( GetProcessHeap(), 0, ptr
);
802 /**********************************************************************
803 * WINPROC_MapMsg32WTo32A
805 * Map a message from Unicode to Ansi.
806 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
808 INT
WINPROC_MapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
813 case WM_ASKCBFORMATNAME
:
815 LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0,
816 *pwparam
+ sizeof(LPARAM
) );
818 *ptr
++ = *plparam
; /* Store previous lParam */
819 *plparam
= (LPARAM
)ptr
;
824 case WM_WININICHANGE
:
825 case WM_DEVMODECHANGE
:
828 case CB_FINDSTRINGEXACT
:
829 case CB_SELECTSTRING
:
833 case LB_FINDSTRINGEXACT
:
834 case LB_SELECTSTRING
:
836 if(!*plparam
) return 0;
837 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
838 return (*plparam
? 1 : -1);
843 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0,
846 *cs
= *(CREATESTRUCTA
*)*plparam
;
847 if (HIWORD(cs
->lpszName
))
848 cs
->lpszName
= HEAP_strdupWtoA( GetProcessHeap(), 0,
849 (LPCWSTR
)cs
->lpszName
);
850 if (HIWORD(cs
->lpszClass
))
851 cs
->lpszClass
= HEAP_strdupWtoA( GetProcessHeap(), 0,
852 (LPCWSTR
)cs
->lpszClass
);
853 *plparam
= (LPARAM
)cs
;
858 MDICREATESTRUCTA
*cs
=
859 (MDICREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
861 *cs
= *(MDICREATESTRUCTA
*)*plparam
;
862 if (HIWORD(cs
->szTitle
))
863 cs
->szTitle
= HEAP_strdupWtoA( GetProcessHeap(), 0,
864 (LPCWSTR
)cs
->szTitle
);
865 if (HIWORD(cs
->szClass
))
866 cs
->szClass
= HEAP_strdupWtoA( GetProcessHeap(), 0,
867 (LPCWSTR
)cs
->szClass
);
868 *plparam
= (LPARAM
)cs
;
874 case LB_INSERTSTRING
:
875 if(!*plparam
) return 0;
876 if ( WINPROC_TestLBForStr( hwnd
))
877 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
878 return (*plparam
? 1 : -1);
880 case LB_GETTEXT
: /* fixme: fixed sized buffer */
881 { if ( WINPROC_TestLBForStr( hwnd
))
882 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM
) );
884 *ptr
++ = *plparam
; /* Store previous lParam */
885 *plparam
= (LPARAM
)ptr
;
892 case CB_INSERTSTRING
:
893 if(!*plparam
) return 0;
894 if ( WINPROC_TestCBForStr( hwnd
))
895 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
896 return (*plparam
? 1 : -1);
898 case CB_GETLBTEXT
: /* fixme: fixed sized buffer */
899 { if ( WINPROC_TestCBForStr( hwnd
))
900 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM
) );
902 *ptr
++ = *plparam
; /* Store previous lParam */
903 *plparam
= (LPARAM
)ptr
;
910 { WORD len
= (WORD
)*plparam
;
911 LPARAM
*ptr
= (LPARAM
*) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(CHAR
) );
913 *ptr
++ = *plparam
; /* Store previous lParam */
914 *((WORD
*) ptr
) = len
; /* Store the length */
915 *plparam
= (LPARAM
)ptr
;
925 case EM_SETPASSWORDCHAR
:
927 WCHAR wch
= LOWORD(*pwparam
);
929 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
930 *pwparam
= MAKEWPARAM( ch
, HIWORD(*pwparam
) );
934 case WM_PAINTCLIPBOARD
:
935 case WM_SIZECLIPBOARD
:
936 FIXME_(msg
)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg
, hwnd
),msg
);
938 default: /* No translation needed */
944 /**********************************************************************
945 * WINPROC_UnmapMsg32WTo32A
947 * Unmap a message that was mapped from Unicode to Ansi.
949 void WINPROC_UnmapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
954 case WM_ASKCBFORMATNAME
:
956 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
959 if (!MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, wParam
))
960 ((LPWSTR
)*ptr
)[wParam
-1] = 0;
962 HeapFree( GetProcessHeap(), 0, ptr
);
967 case WM_WININICHANGE
:
968 case WM_DEVMODECHANGE
:
971 case CB_FINDSTRINGEXACT
:
972 case CB_SELECTSTRING
:
976 case LB_FINDSTRINGEXACT
:
977 case LB_SELECTSTRING
:
979 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
985 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
986 if (HIWORD(cs
->lpszName
))
987 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszName
);
988 if (HIWORD(cs
->lpszClass
))
989 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszClass
);
990 HeapFree( GetProcessHeap(), 0, cs
);
996 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
997 if (HIWORD(cs
->szTitle
))
998 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
999 if (HIWORD(cs
->szClass
))
1000 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
1001 HeapFree( GetProcessHeap(), 0, cs
);
1007 case LB_INSERTSTRING
:
1008 if ( WINPROC_TestLBForStr( hwnd
))
1009 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1013 if ( WINPROC_TestLBForStr( hwnd
))
1015 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1016 MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff );
1017 HeapFree( GetProcessHeap(), 0, ptr
);
1023 case CB_INSERTSTRING
:
1024 if ( WINPROC_TestCBForStr( hwnd
))
1025 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1029 if ( WINPROC_TestCBForStr( hwnd
))
1031 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1032 MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff );
1033 HeapFree( GetProcessHeap(), 0, ptr
);
1037 /* Multiline edit */
1039 { LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lparam */
1040 WORD len
= *(WORD
*)ptr
;
1043 if (!MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, len
))
1044 ((LPWSTR
)*ptr
)[len
-1] = 0;
1046 HeapFree( GetProcessHeap(), 0, ptr
);
1053 /**********************************************************************
1054 * WINPROC_MapMsg16To32A
1056 * Map a message from 16- to 32-bit Ansi.
1057 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1059 INT
WINPROC_MapMsg16To32A( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1060 WPARAM
*pwparam32
, LPARAM
*plparam
)
1062 *pmsg32
= (UINT
)msg16
;
1063 *pwparam32
= (WPARAM
)wParam16
;
1070 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1071 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1075 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1076 *plparam
= (LPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1079 if ( HIWORD(*plparam
) > CTLCOLOR_STATIC
) return -1;
1080 *pmsg32
= WM_CTLCOLORMSGBOX
+ HIWORD(*plparam
);
1081 *pwparam32
= (WPARAM
)(HDC
)wParam16
;
1082 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1084 case WM_COMPAREITEM
:
1086 COMPAREITEMSTRUCT16
* cis16
= MapSL(*plparam
);
1087 COMPAREITEMSTRUCT
*cis
= (COMPAREITEMSTRUCT
*)
1088 HeapAlloc(GetProcessHeap(), 0, sizeof(*cis
));
1089 if (!cis
) return -1;
1090 cis
->CtlType
= cis16
->CtlType
;
1091 cis
->CtlID
= cis16
->CtlID
;
1092 cis
->hwndItem
= WIN_Handle32( cis16
->hwndItem
);
1093 cis
->itemID1
= cis16
->itemID1
;
1094 cis
->itemData1
= cis16
->itemData1
;
1095 cis
->itemID2
= cis16
->itemID2
;
1096 cis
->itemData2
= cis16
->itemData2
;
1097 cis
->dwLocaleId
= 0; /* FIXME */
1098 *plparam
= (LPARAM
)cis
;
1103 DELETEITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1104 DELETEITEMSTRUCT
*dis
= (DELETEITEMSTRUCT
*)
1105 HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1106 if (!dis
) return -1;
1107 dis
->CtlType
= dis16
->CtlType
;
1108 dis
->CtlID
= dis16
->CtlID
;
1109 dis
->hwndItem
= WIN_Handle32( dis16
->hwndItem
);
1110 dis
->itemData
= dis16
->itemData
;
1111 *plparam
= (LPARAM
)dis
;
1114 case WM_MEASUREITEM
:
1116 MEASUREITEMSTRUCT16
* mis16
= MapSL(*plparam
);
1117 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)
1118 HeapAlloc(GetProcessHeap(), 0,
1119 sizeof(*mis
) + sizeof(LPARAM
));
1120 if (!mis
) return -1;
1121 mis
->CtlType
= mis16
->CtlType
;
1122 mis
->CtlID
= mis16
->CtlID
;
1123 mis
->itemID
= mis16
->itemID
;
1124 mis
->itemWidth
= mis16
->itemWidth
;
1125 mis
->itemHeight
= mis16
->itemHeight
;
1126 mis
->itemData
= mis16
->itemData
;
1127 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1128 *plparam
= (LPARAM
)mis
;
1133 DRAWITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1134 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)HeapAlloc(GetProcessHeap(), 0,
1136 if (!dis
) return -1;
1137 dis
->CtlType
= dis16
->CtlType
;
1138 dis
->CtlID
= dis16
->CtlID
;
1139 dis
->itemID
= dis16
->itemID
;
1140 dis
->itemAction
= dis16
->itemAction
;
1141 dis
->itemState
= dis16
->itemState
;
1142 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND
)(HMENU
)dis16
->hwndItem
1143 : WIN_Handle32( dis16
->hwndItem
);
1144 dis
->hDC
= dis16
->hDC
;
1145 dis
->itemData
= dis16
->itemData
;
1146 CONV_RECT16TO32( &dis16
->rcItem
, &dis
->rcItem
);
1147 *plparam
= (LPARAM
)dis
;
1150 case WM_GETMINMAXINFO
:
1152 MINMAXINFO
*mmi
= (MINMAXINFO
*)HeapAlloc( GetProcessHeap(), 0,
1153 sizeof(*mmi
) + sizeof(LPARAM
));
1154 if (!mmi
) return -1;
1155 STRUCT32_MINMAXINFO16to32( MapSL(*plparam
), mmi
);
1156 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1157 *plparam
= (LPARAM
)mmi
;
1162 case WM_WININICHANGE
:
1163 case WM_DEVMODECHANGE
:
1164 case WM_ASKCBFORMATNAME
:
1165 *plparam
= (LPARAM
)MapSL(*plparam
);
1169 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1170 MDICREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1172 STRUCT32_MDICREATESTRUCT16to32A( cs16
, cs
);
1173 cs
->szTitle
= MapSL(cs16
->szTitle
);
1174 cs
->szClass
= MapSL(cs16
->szClass
);
1175 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1176 *plparam
= (LPARAM
)cs
;
1179 case WM_MDIGETACTIVE
:
1180 *plparam
= (LPARAM
)HeapAlloc( GetProcessHeap(), 0, sizeof(BOOL
) );
1181 *(BOOL
*)(*plparam
) = 0;
1185 *pmsg32
=WM_MDIREFRESHMENU
;
1186 *pwparam32
= (WPARAM
)(HMENU
)LOWORD(*plparam
);
1187 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1190 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1191 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1194 if((LOWORD(*plparam
) & MF_POPUP
) && (LOWORD(*plparam
) != 0xFFFF))
1196 HMENU hmenu
=(HMENU
)HIWORD(*plparam
);
1197 UINT Pos
=MENU_FindSubMenu( &hmenu
, wParam16
);
1198 if(Pos
==0xFFFF) Pos
=0; /* NO_SELECTED_ITEM */
1199 *pwparam32
= MAKEWPARAM( Pos
, LOWORD(*plparam
) );
1201 else *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1202 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1204 case WM_MDIACTIVATE
:
1207 *pwparam32
= (WPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1208 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1210 else /* message sent to MDI client */
1211 *pwparam32
= wParam16
;
1215 NCCALCSIZE_PARAMS16
*nc16
;
1216 NCCALCSIZE_PARAMS
*nc
;
1218 nc
= (NCCALCSIZE_PARAMS
*)HeapAlloc( GetProcessHeap(), 0,
1219 sizeof(*nc
) + sizeof(LPARAM
) );
1221 nc16
= MapSL(*plparam
);
1222 CONV_RECT16TO32( &nc16
->rgrc
[0], &nc
->rgrc
[0] );
1225 nc
->lppos
= (WINDOWPOS
*)HeapAlloc( GetProcessHeap(), 0,
1226 sizeof(*nc
->lppos
) );
1227 CONV_RECT16TO32( &nc16
->rgrc
[1], &nc
->rgrc
[1] );
1228 CONV_RECT16TO32( &nc16
->rgrc
[2], &nc
->rgrc
[2] );
1229 if (nc
->lppos
) STRUCT32_WINDOWPOS16to32( MapSL(nc16
->lppos
), nc
->lppos
);
1231 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1232 *plparam
= (LPARAM
)nc
;
1238 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1239 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0,
1240 sizeof(*cs
) + sizeof(LPARAM
) );
1242 STRUCT32_CREATESTRUCT16to32A( cs16
, cs
);
1243 cs
->lpszName
= MapSL(cs16
->lpszName
);
1244 cs
->lpszClass
= MapSL(cs16
->lpszClass
);
1245 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1246 *plparam
= (LPARAM
)cs
;
1249 case WM_PARENTNOTIFY
:
1250 if ((wParam16
== WM_CREATE
) || (wParam16
== WM_DESTROY
))
1252 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1253 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1256 case WM_WINDOWPOSCHANGING
:
1257 case WM_WINDOWPOSCHANGED
:
1259 WINDOWPOS
*wp
= (WINDOWPOS
*)HeapAlloc( GetProcessHeap(), 0,
1260 sizeof(*wp
) + sizeof(LPARAM
) );
1262 STRUCT32_WINDOWPOS16to32( MapSL(*plparam
), wp
);
1263 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1264 *plparam
= (LPARAM
)wp
;
1270 LPMSG16 msg16
= MapSL(*plparam
);
1271 LPMSG msg32
= (LPMSG
)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1273 if (!msg32
) return -1;
1274 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1275 msg32
->lParam
= msg16
->lParam
;
1276 msg32
->time
= msg16
->time
;
1277 CONV_POINT16TO32(&msg16
->pt
,&msg32
->pt
);
1278 /* this is right, right? */
1279 if (WINPROC_MapMsg16To32A( msg32
->hwnd
, msg16
->message
,msg16
->wParam
,
1280 &msg32
->message
,&msg32
->wParam
,
1281 &msg32
->lParam
)<0) {
1282 HeapFree( GetProcessHeap(), 0, msg32
);
1285 *plparam
= (LPARAM
)msg32
;
1290 *plparam
= (LPARAM
)MapSL(*plparam
);
1292 case WM_ACTIVATEAPP
:
1294 { /* We need this when SetActiveWindow sends a Sendmessage16() to
1295 a 32bit window. Might be superflous with 32bit interprocess
1298 HTASK16 htask
= (HTASK16
) *plparam
;
1299 DWORD idThread
= (DWORD
)TASK_GetPtr(htask
)->teb
->tid
;
1300 *plparam
= (LPARAM
) idThread
;
1305 MDINEXTMENU
*next
= HeapAlloc( GetProcessHeap(), 0, sizeof(*next
) );
1306 if (!next
) return -1;
1307 next
->hmenuIn
= *plparam
;
1308 next
->hmenuNext
= 0;
1310 *plparam
= (LPARAM
)next
;
1313 case WM_PAINTCLIPBOARD
:
1314 case WM_SIZECLIPBOARD
:
1315 FIXME_(msg
)("message %04x needs translation\n",msg16
);
1318 default: /* No translation needed */
1324 /**********************************************************************
1325 * WINPROC_UnmapMsg16To32A
1327 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1329 LRESULT
WINPROC_UnmapMsg16To32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1334 case WM_COMPAREITEM
:
1337 HeapFree( GetProcessHeap(), 0, (LPVOID
)lParam
);
1339 case WM_MEASUREITEM
:
1341 MEASUREITEMSTRUCT16
*mis16
;
1342 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)lParam
;
1343 lParam
= *(LPARAM
*)(mis
+ 1);
1344 mis16
= MapSL(lParam
);
1345 mis16
->itemWidth
= (UINT16
)mis
->itemWidth
;
1346 mis16
->itemHeight
= (UINT16
)mis
->itemHeight
;
1347 HeapFree( GetProcessHeap(), 0, mis
);
1350 case WM_GETMINMAXINFO
:
1352 MINMAXINFO
*mmi
= (MINMAXINFO
*)lParam
;
1353 lParam
= *(LPARAM
*)(mmi
+ 1);
1354 STRUCT32_MINMAXINFO32to16( mmi
, MapSL(lParam
));
1355 HeapFree( GetProcessHeap(), 0, mmi
);
1360 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1361 lParam
= *(LPARAM
*)(cs
+ 1);
1362 STRUCT32_MDICREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1363 HeapFree( GetProcessHeap(), 0, cs
);
1366 case WM_MDIGETACTIVE
:
1367 result
= MAKELONG( LOWORD(result
), (BOOL16
)(*(BOOL
*)lParam
) );
1368 HeapFree( GetProcessHeap(), 0, (BOOL
*)lParam
);
1372 NCCALCSIZE_PARAMS16
*nc16
;
1373 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lParam
;
1374 lParam
= *(LPARAM
*)(nc
+ 1);
1375 nc16
= MapSL(lParam
);
1376 CONV_RECT32TO16( &nc
->rgrc
[0], &nc16
->rgrc
[0] );
1379 CONV_RECT32TO16( &nc
->rgrc
[1], &nc16
->rgrc
[1] );
1380 CONV_RECT32TO16( &nc
->rgrc
[2], &nc16
->rgrc
[2] );
1383 STRUCT32_WINDOWPOS32to16( nc
->lppos
, MapSL(nc16
->lppos
));
1384 HeapFree( GetProcessHeap(), 0, nc
->lppos
);
1387 HeapFree( GetProcessHeap(), 0, nc
);
1393 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
1394 lParam
= *(LPARAM
*)(cs
+ 1);
1395 STRUCT32_CREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1396 HeapFree( GetProcessHeap(), 0, cs
);
1399 case WM_WINDOWPOSCHANGING
:
1400 case WM_WINDOWPOSCHANGED
:
1402 WINDOWPOS
*wp
= (WINDOWPOS
*)lParam
;
1403 lParam
= *(LPARAM
*)(wp
+ 1);
1404 STRUCT32_WINDOWPOS32to16(wp
, MapSL(lParam
));
1405 HeapFree( GetProcessHeap(), 0, wp
);
1411 LPMSG msg32
= (LPMSG
)lParam
;
1413 WINPROC_UnmapMsg16To32A( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1415 HeapFree( GetProcessHeap(), 0, msg32
);
1420 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
1421 result
= MAKELONG( next
->hmenuNext
, WIN_Handle16(next
->hwndNext
) );
1422 HeapFree( GetProcessHeap(), 0, next
);
1430 /**********************************************************************
1431 * WINPROC_MapMsg16To32W
1433 * Map a message from 16- to 32-bit Unicode.
1434 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1436 INT
WINPROC_MapMsg16To32W( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1437 WPARAM
*pwparam32
, LPARAM
*plparam
)
1442 *pmsg32
=(UINT
)msg16
;
1443 *pwparam32
= (WPARAM
)wParam16
;
1448 case WM_WININICHANGE
:
1449 case WM_DEVMODECHANGE
:
1450 case WM_ASKCBFORMATNAME
:
1451 *plparam
= (LPARAM
)MapSL(*plparam
);
1452 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1453 case WM_GETTEXTLENGTH
:
1454 case CB_GETLBTEXTLEN
:
1456 return 1; /* need to map result */
1460 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1461 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0,
1462 sizeof(*cs
) + sizeof(LPARAM
) );
1464 STRUCT32_CREATESTRUCT16to32A( cs16
, (CREATESTRUCTA
*)cs
);
1465 cs
->lpszName
= MapSL(cs16
->lpszName
);
1466 cs
->lpszClass
= MapSL(cs16
->lpszClass
);
1467 if (HIWORD(cs
->lpszName
))
1468 cs
->lpszName
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1469 (LPCSTR
)cs
->lpszName
);
1470 if (HIWORD(cs
->lpszClass
))
1471 cs
->lpszClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1472 (LPCSTR
)cs
->lpszClass
);
1473 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1474 *plparam
= (LPARAM
)cs
;
1479 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1480 MDICREATESTRUCTW
*cs
=
1481 (MDICREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0,
1482 sizeof(*cs
) + sizeof(LPARAM
) );
1484 STRUCT32_MDICREATESTRUCT16to32A( cs16
, (MDICREATESTRUCTA
*)cs
);
1485 cs
->szTitle
= MapSL(cs16
->szTitle
);
1486 cs
->szClass
= MapSL(cs16
->szClass
);
1487 if (HIWORD(cs
->szTitle
))
1488 cs
->szTitle
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1489 (LPCSTR
)cs
->szTitle
);
1490 if (HIWORD(cs
->szClass
))
1491 cs
->szClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1492 (LPCSTR
)cs
->szClass
);
1493 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1494 *plparam
= (LPARAM
)cs
;
1500 LPMSG16 msg16
= MapSL(*plparam
);
1501 LPMSG msg32
= (LPMSG
)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1503 if (!msg32
) return -1;
1504 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1505 msg32
->lParam
= msg16
->lParam
;
1506 msg32
->time
= msg16
->time
;
1507 CONV_POINT16TO32(&msg16
->pt
,&msg32
->pt
);
1508 /* this is right, right? */
1509 if (WINPROC_MapMsg16To32W(hwnd
, msg16
->message
,msg16
->wParam
,
1510 &msg32
->message
,&msg32
->wParam
,
1511 &msg32
->lParam
)<0) {
1512 HeapFree( GetProcessHeap(), 0, msg32
);
1515 *plparam
= (LPARAM
)msg32
;
1522 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1523 *pwparam32
= MAKEWPARAM( wch
, HIWORD(*plparam
) );
1524 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1528 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1529 *pwparam32
= MAKEWPARAM( wch
, LOWORD(*plparam
) );
1530 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1535 case WM_SYSDEADCHAR
:
1537 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1541 default: /* No Unicode translation needed */
1542 return WINPROC_MapMsg16To32A( hwnd
, msg16
, wParam16
, pmsg32
,
1543 pwparam32
, plparam
);
1548 /**********************************************************************
1549 * WINPROC_UnmapMsg16To32W
1551 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1553 LRESULT
WINPROC_UnmapMsg16To32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1560 case WM_GETTEXTLENGTH
:
1561 case CB_GETLBTEXTLEN
:
1563 case WM_ASKCBFORMATNAME
:
1564 return WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
);
1568 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
1569 lParam
= *(LPARAM
*)(cs
+ 1);
1570 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs
, MapSL(lParam
) );
1571 if (HIWORD(cs
->lpszName
))
1572 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszName
);
1573 if (HIWORD(cs
->lpszClass
))
1574 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszClass
);
1575 HeapFree( GetProcessHeap(), 0, cs
);
1580 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
1581 lParam
= *(LPARAM
*)(cs
+ 1);
1582 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs
, MapSL(lParam
) );
1583 if (HIWORD(cs
->szTitle
))
1584 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
1585 if (HIWORD(cs
->szClass
))
1586 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
1587 HeapFree( GetProcessHeap(), 0, cs
);
1593 LPMSG msg32
= (LPMSG
)lParam
;
1595 WINPROC_UnmapMsg16To32W( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1597 HeapFree( GetProcessHeap(), 0, msg32
);
1601 return WINPROC_UnmapMsg16To32A( hwnd
, msg
, wParam
, lParam
, result
);
1607 /**********************************************************************
1608 * WINPROC_MapMsg32ATo16
1610 * Map a message from 32-bit Ansi to 16-bit.
1611 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1613 INT
WINPROC_MapMsg32ATo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
1614 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
1617 *pmsg16
= (UINT16
)msg32
;
1618 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
1626 *pmsg16
= (UINT16
)msg32
+ (BM_GETCHECK16
- BM_GETCHECK
);
1635 case EM_SCROLLCARET
:
1638 case EM_GETLINECOUNT
:
1650 case EM_LINEFROMCHAR
:
1651 case EM_SETTABSTOPS
:
1652 case EM_SETPASSWORDCHAR
:
1653 case EM_EMPTYUNDOBUFFER
:
1654 case EM_GETFIRSTVISIBLELINE
:
1655 case EM_SETREADONLY
:
1656 case EM_SETWORDBREAKPROC
:
1657 case EM_GETWORDBREAKPROC
:
1658 case EM_GETPASSWORDCHAR
:
1659 *pmsg16
= (UINT16
)msg32
+ (EM_GETSEL16
- EM_GETSEL
);
1664 case LB_DELETESTRING
:
1665 case LB_GETANCHORINDEX
:
1666 case LB_GETCARETINDEX
:
1669 case LB_GETHORIZONTALEXTENT
:
1670 case LB_GETITEMDATA
:
1671 case LB_GETITEMHEIGHT
:
1673 case LB_GETSELCOUNT
:
1675 case LB_GETTOPINDEX
:
1676 case LB_RESETCONTENT
:
1677 case LB_SELITEMRANGE
:
1678 case LB_SELITEMRANGEEX
:
1679 case LB_SETANCHORINDEX
:
1680 case LB_SETCARETINDEX
:
1681 case LB_SETCOLUMNWIDTH
:
1683 case LB_SETHORIZONTALEXTENT
:
1684 case LB_SETITEMDATA
:
1685 case LB_SETITEMHEIGHT
:
1687 case LB_SETTOPINDEX
:
1688 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1690 case CB_DELETESTRING
:
1692 case CB_GETLBTEXTLEN
:
1694 case CB_RESETCONTENT
:
1698 case CB_SHOWDROPDOWN
:
1699 case CB_SETITEMDATA
:
1700 case CB_SETITEMHEIGHT
:
1701 case CB_GETITEMHEIGHT
:
1702 case CB_SETEXTENDEDUI
:
1703 case CB_GETEXTENDEDUI
:
1704 case CB_GETDROPPEDSTATE
:
1705 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
1708 *pmsg16
= CB_GETEDITSEL16
;
1713 case LB_FINDSTRINGEXACT
:
1714 case LB_INSERTSTRING
:
1715 case LB_SELECTSTRING
:
1719 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1720 if (!str
) return -1;
1721 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1723 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1728 case CB_FINDSTRINGEXACT
:
1729 case CB_INSERTSTRING
:
1730 case CB_SELECTSTRING
:
1733 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1734 if (!str
) return -1;
1735 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1737 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
1740 case LB_GETITEMRECT
:
1743 rect
= (RECT16
*)SEGPTR_ALLOC( sizeof(RECT16
) + sizeof(LPARAM
) );
1744 if (!rect
) return -1;
1745 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
1746 *plparam
= (LPARAM
)SEGPTR_GET(rect
);
1748 *pmsg16
= LB_GETITEMRECT16
;
1750 case LB_GETSELITEMS
:
1753 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
1754 if (!(items
= SEGPTR_ALLOC( *pwparam16
* sizeof(INT16
)
1755 + sizeof(LPARAM
)))) return -1;
1756 *((LPARAM
*)items
)++ = *plparam
; /* Store the previous lParam */
1757 *plparam
= (LPARAM
)SEGPTR_GET(items
);
1759 *pmsg16
= LB_GETSELITEMS16
;
1761 case LB_SETTABSTOPS
:
1766 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
1767 if (!(stops
= SEGPTR_ALLOC( *pwparam16
* sizeof(INT16
)
1768 + sizeof(LPARAM
)))) return -1;
1769 for (i
= 0; i
< *pwparam16
; i
++) stops
[i
] = *((LPINT
)*plparam
+i
);
1770 *plparam
= (LPARAM
)SEGPTR_GET(stops
);
1773 *pmsg16
= LB_SETTABSTOPS16
;
1776 case CB_GETDROPPEDCONTROLRECT
:
1779 rect
= (RECT16
*)SEGPTR_ALLOC( sizeof(RECT16
) + sizeof(LPARAM
) );
1780 if (!rect
) return -1;
1781 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
1782 *plparam
= (LPARAM
)SEGPTR_GET(rect
);
1784 *pmsg16
= CB_GETDROPPEDCONTROLRECT16
;
1788 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
1789 *pmsg16
= LB_GETTEXT16
;
1793 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
1794 *pmsg16
= CB_GETLBTEXT16
;
1799 *plparam
= MAKELONG( (INT16
)(INT
)wParam32
, (INT16
)*plparam
);
1800 *pmsg16
= EM_SETSEL16
;
1807 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
1811 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HWND16
)*plparam
);
1813 case WM_CTLCOLORMSGBOX
:
1814 case WM_CTLCOLOREDIT
:
1815 case WM_CTLCOLORLISTBOX
:
1816 case WM_CTLCOLORBTN
:
1817 case WM_CTLCOLORDLG
:
1818 case WM_CTLCOLORSCROLLBAR
:
1819 case WM_CTLCOLORSTATIC
:
1820 *pmsg16
= WM_CTLCOLOR
;
1821 *plparam
= MAKELPARAM( (HWND16
)*plparam
,
1822 (WORD
)msg32
- WM_CTLCOLORMSGBOX
);
1824 case WM_COMPAREITEM
:
1826 COMPAREITEMSTRUCT
*cis32
= (COMPAREITEMSTRUCT
*)*plparam
;
1827 COMPAREITEMSTRUCT16
*cis
= SEGPTR_NEW(COMPAREITEMSTRUCT16
);
1828 if (!cis
) return -1;
1829 cis
->CtlType
= (UINT16
)cis32
->CtlType
;
1830 cis
->CtlID
= (UINT16
)cis32
->CtlID
;
1831 cis
->hwndItem
= WIN_Handle16( cis32
->hwndItem
);
1832 cis
->itemID1
= (UINT16
)cis32
->itemID1
;
1833 cis
->itemData1
= cis32
->itemData1
;
1834 cis
->itemID2
= (UINT16
)cis32
->itemID2
;
1835 cis
->itemData2
= cis32
->itemData2
;
1836 *plparam
= (LPARAM
)SEGPTR_GET(cis
);
1841 DELETEITEMSTRUCT
*dis32
= (DELETEITEMSTRUCT
*)*plparam
;
1842 DELETEITEMSTRUCT16
*dis
= SEGPTR_NEW(DELETEITEMSTRUCT16
);
1843 if (!dis
) return -1;
1844 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
1845 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
1846 dis
->itemID
= (UINT16
)dis32
->itemID
;
1847 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND16
)LOWORD(dis32
->hwndItem
)
1848 : WIN_Handle16( dis32
->hwndItem
);
1849 dis
->itemData
= dis32
->itemData
;
1850 *plparam
= (LPARAM
)SEGPTR_GET(dis
);
1855 DRAWITEMSTRUCT
*dis32
= (DRAWITEMSTRUCT
*)*plparam
;
1856 DRAWITEMSTRUCT16
*dis
= SEGPTR_NEW(DRAWITEMSTRUCT16
);
1857 if (!dis
) return -1;
1858 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
1859 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
1860 dis
->itemID
= (UINT16
)dis32
->itemID
;
1861 dis
->itemAction
= (UINT16
)dis32
->itemAction
;
1862 dis
->itemState
= (UINT16
)dis32
->itemState
;
1863 dis
->hwndItem
= WIN_Handle16( dis32
->hwndItem
);
1864 dis
->hDC
= (HDC16
)dis32
->hDC
;
1865 dis
->itemData
= dis32
->itemData
;
1866 CONV_RECT32TO16( &dis32
->rcItem
, &dis
->rcItem
);
1867 *plparam
= (LPARAM
)SEGPTR_GET(dis
);
1870 case WM_MEASUREITEM
:
1872 MEASUREITEMSTRUCT
*mis32
= (MEASUREITEMSTRUCT
*)*plparam
;
1873 MEASUREITEMSTRUCT16
*mis
= (MEASUREITEMSTRUCT16
*)
1874 SEGPTR_ALLOC(sizeof(*mis
)+sizeof(LPARAM
));
1875 if (!mis
) return -1;
1876 mis
->CtlType
= (UINT16
)mis32
->CtlType
;
1877 mis
->CtlID
= (UINT16
)mis32
->CtlID
;
1878 mis
->itemID
= (UINT16
)mis32
->itemID
;
1879 mis
->itemWidth
= (UINT16
)mis32
->itemWidth
;
1880 mis
->itemHeight
= (UINT16
)mis32
->itemHeight
;
1881 mis
->itemData
= mis32
->itemData
;
1882 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1883 *plparam
= (LPARAM
)SEGPTR_GET(mis
);
1886 case WM_GETMINMAXINFO
:
1888 MINMAXINFO16
*mmi
= (MINMAXINFO16
*)SEGPTR_ALLOC( sizeof(*mmi
) +
1890 if (!mmi
) return -1;
1891 STRUCT32_MINMAXINFO32to16( (MINMAXINFO
*)*plparam
, mmi
);
1892 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1893 *plparam
= (LPARAM
)SEGPTR_GET(mmi
);
1897 case WM_ASKCBFORMATNAME
:
1900 *pwparam16
= (WPARAM16
)min( wParam32
, 0xff80 ); /* Must be < 64K */
1901 if (!(str
= SEGPTR_ALLOC(*pwparam16
+ sizeof(LPARAM
)))) return -1;
1902 *((LPARAM
*)str
)++ = *plparam
; /* Store the previous lParam */
1903 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1908 MDICREATESTRUCT16
*cs
;
1909 MDICREATESTRUCTA
*cs32
= (MDICREATESTRUCTA
*)*plparam
;
1912 if (!(cs
= SEGPTR_NEW(MDICREATESTRUCT16
))) return -1;
1913 STRUCT32_MDICREATESTRUCT32Ato16( cs32
, cs
);
1914 name
= SEGPTR_STRDUP( cs32
->szTitle
);
1915 cls
= SEGPTR_STRDUP( cs32
->szClass
);
1916 cs
->szTitle
= SEGPTR_GET(name
);
1917 cs
->szClass
= SEGPTR_GET(cls
);
1918 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
1921 case WM_MDIGETACTIVE
:
1924 *plparam
= MAKELPARAM( (HMENU16
)LOWORD(wParam32
),
1925 (HMENU16
)LOWORD(*plparam
) );
1926 *pwparam16
= (*plparam
== 0);
1929 if(HIWORD(wParam32
) & MF_POPUP
)
1932 if (((UINT
)HIWORD(wParam32
) != 0xFFFF) || (*plparam
))
1934 if((hmenu
= GetSubMenu((HMENU16
)*plparam
, *pwparam16
)))
1940 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
1942 case WM_MDIACTIVATE
:
1943 if (GetWindowLongA( hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1945 *pwparam16
= ((HWND
)*plparam
== hwnd
);
1946 *plparam
= MAKELPARAM( (HWND16
)LOWORD(*plparam
),
1947 (HWND16
)LOWORD(wParam32
) );
1951 *pwparam16
= WIN_Handle16( (HWND
)wParam32
);
1957 NCCALCSIZE_PARAMS
*nc32
= (NCCALCSIZE_PARAMS
*)*plparam
;
1958 NCCALCSIZE_PARAMS16
*nc
= (NCCALCSIZE_PARAMS16
*)SEGPTR_ALLOC( sizeof(*nc
) + sizeof(LPARAM
) );
1961 CONV_RECT32TO16( &nc32
->rgrc
[0], &nc
->rgrc
[0] );
1965 CONV_RECT32TO16( &nc32
->rgrc
[1], &nc
->rgrc
[1] );
1966 CONV_RECT32TO16( &nc32
->rgrc
[2], &nc
->rgrc
[2] );
1967 if (!(wp
= SEGPTR_NEW(WINDOWPOS16
)))
1972 STRUCT32_WINDOWPOS32to16( nc32
->lppos
, wp
);
1973 nc
->lppos
= SEGPTR_GET(wp
);
1975 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1976 *plparam
= (LPARAM
)SEGPTR_GET(nc
);
1983 CREATESTRUCTA
*cs32
= (CREATESTRUCTA
*)*plparam
;
1986 if (!(cs
= SEGPTR_NEW(CREATESTRUCT16
))) return -1;
1987 STRUCT32_CREATESTRUCT32Ato16( cs32
, cs
);
1988 name
= SEGPTR_STRDUP( cs32
->lpszName
);
1989 cls
= SEGPTR_STRDUP( cs32
->lpszClass
);
1990 cs
->lpszName
= SEGPTR_GET(name
);
1991 cs
->lpszClass
= SEGPTR_GET(cls
);
1992 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
1995 case WM_PARENTNOTIFY
:
1996 if ((LOWORD(wParam32
)==WM_CREATE
) || (LOWORD(wParam32
)==WM_DESTROY
))
1997 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
));
1998 /* else nothing to do */
2001 *plparam
= MapLS( (NMHDR
*)*plparam
); /* NMHDR is already 32-bit */
2004 case WM_WININICHANGE
:
2005 case WM_DEVMODECHANGE
:
2007 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
2008 if (!str
) return -1;
2009 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2012 case WM_WINDOWPOSCHANGING
:
2013 case WM_WINDOWPOSCHANGED
:
2015 WINDOWPOS16
*wp
= (WINDOWPOS16
*)SEGPTR_ALLOC( sizeof(*wp
) +
2018 STRUCT32_WINDOWPOS32to16( (WINDOWPOS
*)*plparam
, wp
);
2019 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
2020 *plparam
= (LPARAM
)SEGPTR_GET(wp
);
2025 LPMSG msg32
= (LPMSG
) *plparam
;
2026 LPMSG16 msg16
= (LPMSG16
) SEGPTR_NEW( MSG16
);
2028 if (!msg16
) return -1;
2029 msg16
->hwnd
= WIN_Handle16( msg32
->hwnd
);
2030 msg16
->lParam
= msg32
->lParam
;
2031 msg16
->time
= msg32
->time
;
2032 CONV_POINT32TO16(&msg32
->pt
,&msg16
->pt
);
2033 /* this is right, right? */
2034 if (WINPROC_MapMsg32ATo16(msg32
->hwnd
,msg32
->message
,msg32
->wParam
,
2035 &msg16
->message
,&msg16
->wParam
, &msg16
->lParam
)<0) {
2036 SEGPTR_FREE( msg16
);
2039 *plparam
= (LPARAM
)SEGPTR_GET(msg16
);
2044 case WM_ACTIVATEAPP
:
2045 if (*plparam
) *plparam
= (LPARAM
)THREAD_IdToTEB((DWORD
) *plparam
)->htask16
;
2049 MDINEXTMENU
*next
= (MDINEXTMENU
*)*plparam
;
2050 *plparam
= next
->hmenuIn
;
2053 case WM_PAINTCLIPBOARD
:
2054 case WM_SIZECLIPBOARD
:
2055 FIXME_(msg
)("message %04x needs translation\n", msg32
);
2057 /* following messages should not be sent to 16-bit apps */
2060 case WM_CAPTURECHANGED
:
2061 case WM_STYLECHANGING
:
2062 case WM_STYLECHANGED
:
2064 default: /* No translation needed */
2070 /**********************************************************************
2071 * WINPROC_UnmapMsg32ATo16
2073 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
2075 void WINPROC_UnmapMsg32ATo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2084 case LB_FINDSTRINGEXACT
:
2085 case LB_INSERTSTRING
:
2086 case LB_SELECTSTRING
:
2087 case LB_SETTABSTOPS
:
2090 case CB_FINDSTRINGEXACT
:
2091 case CB_INSERTSTRING
:
2092 case CB_SELECTSTRING
:
2094 case WM_COMPAREITEM
:
2098 case WM_WININICHANGE
:
2099 case WM_DEVMODECHANGE
:
2100 SEGPTR_FREE( MapSL(p16
->lParam
) );
2103 case CB_GETDROPPEDCONTROLRECT
:
2104 case LB_GETITEMRECT
:
2106 RECT16
*rect
= MapSL(p16
->lParam
);
2107 p16
->lParam
= *(LPARAM
*)(rect
+ 1);
2108 CONV_RECT16TO32( rect
, (RECT
*)(p16
->lParam
));
2109 SEGPTR_FREE( rect
);
2112 case LB_GETSELITEMS
:
2115 LPINT16 items
= MapSL(lParam
);
2116 p16
->lParam
= *((LPARAM
*)items
- 1);
2117 for (i
= 0; i
< p16
->wParam
; i
++) *((LPINT
)(p16
->lParam
) + i
) = items
[i
];
2118 SEGPTR_FREE( (LPARAM
*)items
- 1 );
2124 *((LPUINT
)(wParam
)) = LOWORD(p16
->lResult
);
2126 *((LPUINT
)(lParam
)) = HIWORD(p16
->lResult
); /* FIXME: substract 1? */
2131 UnMapLS( (SEGPTR
)(p16
->lParam
) );
2134 case WM_MEASUREITEM
:
2136 MEASUREITEMSTRUCT16
*mis
= MapSL(p16
->lParam
);
2137 MEASUREITEMSTRUCT
*mis32
= *(MEASUREITEMSTRUCT
**)(mis
+ 1);
2138 mis32
->itemWidth
= mis
->itemWidth
;
2139 mis32
->itemHeight
= mis
->itemHeight
;
2143 case WM_GETMINMAXINFO
:
2145 MINMAXINFO16
*mmi
= MapSL(p16
->lParam
);
2146 p16
->lParam
= *(LPARAM
*)(mmi
+ 1);
2147 STRUCT32_MINMAXINFO16to32( mmi
, (MINMAXINFO
*)(p16
->lParam
) );
2152 case WM_ASKCBFORMATNAME
:
2154 LPSTR str
= MapSL(p16
->lParam
);
2155 p16
->lParam
= *((LPARAM
*)str
- 1);
2156 lstrcpynA( (LPSTR
)(p16
->lParam
), str
, p16
->wParam
);
2157 SEGPTR_FREE( (LPARAM
*)str
- 1 );
2162 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2163 SEGPTR_FREE( MapSL(cs
->szTitle
) );
2164 SEGPTR_FREE( MapSL(cs
->szClass
) );
2168 case WM_MDIGETACTIVE
:
2169 if (lParam
) *(BOOL
*)lParam
= (BOOL16
)HIWORD(p16
->lResult
);
2170 p16
->lResult
= (LRESULT
)WIN_Handle32( LOWORD(p16
->lResult
) );
2174 NCCALCSIZE_PARAMS
*nc32
;
2175 NCCALCSIZE_PARAMS16
*nc
= MapSL(p16
->lParam
);
2176 p16
->lParam
= *(LPARAM
*)(nc
+ 1);
2177 nc32
= (NCCALCSIZE_PARAMS
*)(p16
->lParam
);
2178 CONV_RECT16TO32( &nc
->rgrc
[0], &nc32
->rgrc
[0] );
2181 CONV_RECT16TO32( &nc
->rgrc
[1], &nc32
->rgrc
[1] );
2182 CONV_RECT16TO32( &nc
->rgrc
[2], &nc32
->rgrc
[2] );
2183 STRUCT32_WINDOWPOS16to32( MapSL(nc
->lppos
), nc32
->lppos
);
2184 SEGPTR_FREE( MapSL(nc
->lppos
) );
2192 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2193 SEGPTR_FREE( MapSL(cs
->lpszName
) );
2194 SEGPTR_FREE( MapSL(cs
->lpszClass
) );
2198 case WM_WINDOWPOSCHANGING
:
2199 case WM_WINDOWPOSCHANGED
:
2201 WINDOWPOS16
*wp
= MapSL(p16
->lParam
);
2202 p16
->lParam
= *(LPARAM
*)(wp
+ 1);
2203 STRUCT32_WINDOWPOS16to32( wp
, (WINDOWPOS
*)p16
->lParam
);
2208 UnMapLS(p16
->lParam
);
2213 LPMSG16 msg16
= MapSL(p16
->lParam
);
2215 msgp16
.wParam
=msg16
->wParam
;
2216 msgp16
.lParam
=msg16
->lParam
;
2217 WINPROC_UnmapMsg32ATo16(((LPMSG
)lParam
)->hwnd
, ((LPMSG
)lParam
)->message
,
2218 ((LPMSG
)lParam
)->wParam
, ((LPMSG
)lParam
)->lParam
,
2225 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
2226 next
->hmenuNext
= LOWORD(p16
->lResult
);
2227 next
->hwndNext
= WIN_Handle32( HIWORD(p16
->lResult
) );
2235 /**********************************************************************
2236 * WINPROC_MapMsg32WTo16
2238 * Map a message from 32-bit Unicode to 16-bit.
2239 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
2241 INT
WINPROC_MapMsg32WTo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
2242 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
2248 *pmsg16
= LOWORD(msg32
);
2249 *pwparam16
= LOWORD(wParam32
);
2254 case LB_FINDSTRINGEXACT
:
2255 case LB_INSERTSTRING
:
2256 case LB_SELECTSTRING
:
2260 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2261 if (!str
) return -1;
2262 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2264 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2269 case CB_FINDSTRINGEXACT
:
2270 case CB_INSERTSTRING
:
2271 case CB_SELECTSTRING
:
2274 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2275 if (!str
) return -1;
2276 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2278 *pmsg16
= (UINT16
)msg32
+ (CB_ADDSTRING16
- CB_ADDSTRING
);
2285 CREATESTRUCTW
*cs32
= (CREATESTRUCTW
*)*plparam
;
2288 if (!(cs
= SEGPTR_NEW(CREATESTRUCT16
))) return -1;
2289 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs32
, cs
);
2290 name
= SEGPTR_STRDUP_WtoA( cs32
->lpszName
);
2291 cls
= SEGPTR_STRDUP_WtoA( cs32
->lpszClass
);
2292 cs
->lpszName
= SEGPTR_GET(name
);
2293 cs
->lpszClass
= SEGPTR_GET(cls
);
2294 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2299 MDICREATESTRUCT16
*cs
;
2300 MDICREATESTRUCTW
*cs32
= (MDICREATESTRUCTW
*)*plparam
;
2303 if (!(cs
= SEGPTR_NEW(MDICREATESTRUCT16
))) return -1;
2304 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs32
, cs
);
2305 name
= SEGPTR_STRDUP_WtoA( cs32
->szTitle
);
2306 cls
= SEGPTR_STRDUP_WtoA( cs32
->szClass
);
2307 cs
->szTitle
= SEGPTR_GET(name
);
2308 cs
->szClass
= SEGPTR_GET(cls
);
2309 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2314 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2315 if (!str
) return -1;
2316 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2321 if ( WINPROC_TestLBForStr( hwnd
))
2323 LPSTR str
= (LPSTR
) SEGPTR_ALLOC( 256 ); /* fixme: fixed sized buffer */
2324 if (!str
) return -1;
2325 *pmsg16
= (msg32
== LB_GETTEXT
)? LB_GETTEXT16
: CB_GETLBTEXT16
;
2326 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2331 wch
= LOWORD(wParam32
);
2332 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
2334 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
2337 wch
= LOWORD(wParam32
);
2338 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
2340 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2345 case WM_SYSDEADCHAR
:
2347 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
2351 default: /* No Unicode translation needed (?) */
2352 return WINPROC_MapMsg32ATo16( hwnd
, msg32
, wParam32
, pmsg16
,
2353 pwparam16
, plparam
);
2358 /**********************************************************************
2359 * WINPROC_UnmapMsg32WTo16
2361 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2363 void WINPROC_UnmapMsg32WTo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2369 case WM_ASKCBFORMATNAME
:
2371 LPSTR str
= MapSL(p16
->lParam
);
2372 p16
->lParam
= *((LPARAM
*)str
- 1);
2373 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)p16
->lParam
, 0x7fffffff );
2374 SEGPTR_FREE( (LPARAM
*)str
- 1 );
2379 if ( WINPROC_TestLBForStr( hwnd
))
2381 LPSTR str
= MapSL(p16
->lParam
);
2382 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff );
2383 SEGPTR_FREE( (LPARAM
*) str
);
2387 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, p16
);
2393 /**********************************************************************
2394 * WINPROC_CallProc32ATo32W
2396 * Call a window procedure, translating args from Ansi to Unicode.
2398 static LRESULT
WINPROC_CallProc32ATo32W( WNDPROC func
, HWND hwnd
,
2399 UINT msg
, WPARAM wParam
,
2405 if( (unmap
= WINPROC_MapMsg32ATo32W( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
2406 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
2407 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2410 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2411 if (unmap
) result
= WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
);
2416 /**********************************************************************
2417 * WINPROC_CallProc32WTo32A
2419 * Call a window procedure, translating args from Unicode to Ansi.
2421 static LRESULT
WINPROC_CallProc32WTo32A( WNDPROC func
, HWND hwnd
,
2422 UINT msg
, WPARAM wParam
,
2428 if ((unmap
= WINPROC_MapMsg32WTo32A( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
2429 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
2430 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2433 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2434 if( unmap
) WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
);
2439 /**********************************************************************
2440 * WINPROC_CallProc16To32A
2442 * Call a 32-bit window procedure, translating the 16-bit args.
2444 static LRESULT
WINPROC_CallProc16To32A( WNDPROC func
, HWND16 hwnd
,
2445 UINT16 msg
, WPARAM16 wParam
,
2451 HWND hwnd32
= WIN_Handle32( hwnd
);
2453 if (WINPROC_MapMsg16To32A( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
2455 result
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
2456 return WINPROC_UnmapMsg16To32A( hwnd32
, msg32
, wParam32
, lParam
, result
);
2459 /**********************************************************************
2460 * WINPROC_Thunk16To32A
2462 static LRESULT WINAPI
WINPROC_Thunk16To32A( WNDPROC func
, LPBYTE args
)
2464 HWND16 hwnd
= *(HWND16
*)( args
+8 );
2465 UINT16 msg
= *(HWND16
*)( args
+6 );
2466 WPARAM16 wParam
= *(HWND16
*)( args
+4 );
2467 LPARAM lParam
= *(LPARAM
*)( args
+0 );
2469 return WINPROC_CallProc16To32A( func
, hwnd
, msg
, wParam
, lParam
);
2473 /**********************************************************************
2474 * WINPROC_CallProc16To32W
2476 * Call a 32-bit window procedure, translating the 16-bit args.
2478 static LRESULT
WINPROC_CallProc16To32W( WNDPROC func
, HWND16 hwnd
,
2479 UINT16 msg
, WPARAM16 wParam
,
2485 HWND hwnd32
= WIN_Handle32( hwnd
);
2487 if (WINPROC_MapMsg16To32W( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
2489 result
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
2490 return WINPROC_UnmapMsg16To32W( hwnd32
, msg32
, wParam32
, lParam
, result
);
2493 /**********************************************************************
2494 * WINPROC_Thunk16To32W
2496 static LRESULT WINAPI
WINPROC_Thunk16To32W( WNDPROC func
, LPBYTE args
)
2498 HWND16 hwnd
= *(HWND16
*)( args
+8 );
2499 UINT16 msg
= *(HWND16
*)( args
+6 );
2500 WPARAM16 wParam
= *(HWND16
*)( args
+4 );
2501 LPARAM lParam
= *(LPARAM
*)( args
+0 );
2503 return WINPROC_CallProc16To32W( func
, hwnd
, msg
, wParam
, lParam
);
2506 /**********************************************************************
2507 * WINPROC_CallProc32ATo16
2509 * Call a 16-bit window procedure, translating the 32-bit args.
2511 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
2512 UINT msg
, WPARAM wParam
,
2518 mp16
.lParam
= lParam
;
2519 if (WINPROC_MapMsg32ATo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
2521 mp16
.lResult
= WINPROC_CallWndProc16( func
, WIN_Handle16(hwnd
), msg16
,
2522 mp16
.wParam
, mp16
.lParam
);
2523 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
2524 return mp16
.lResult
;
2528 /**********************************************************************
2529 * WINPROC_CallProc32WTo16
2531 * Call a 16-bit window procedure, translating the 32-bit args.
2533 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
2534 UINT msg
, WPARAM wParam
,
2540 mp16
.lParam
= lParam
;
2541 if (WINPROC_MapMsg32WTo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
,
2542 &mp16
.lParam
) == -1)
2544 mp16
.lResult
= WINPROC_CallWndProc16( func
, WIN_Handle16(hwnd
), msg16
,
2545 mp16
.wParam
, mp16
.lParam
);
2546 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
2547 return mp16
.lResult
;
2551 /**********************************************************************
2552 * CallWindowProc (USER.122)
2553 * CallWindowProc16 (USER32.@)
2555 LRESULT WINAPI
CallWindowProc16( WNDPROC16 func
, HWND16 hwnd
, UINT16 msg
,
2556 WPARAM16 wParam
, LPARAM lParam
)
2558 WINDOWPROC
*proc
= WINPROC_GetPtr( func
);
2561 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
2564 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_16
);
2565 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
2571 if (!proc
->thunk
.t_from32
.proc
) return 0;
2572 return WINPROC_CallWndProc16( proc
->thunk
.t_from32
.proc
,
2573 hwnd
, msg
, wParam
, lParam
);
2575 if (!proc
->thunk
.t_from16
.proc
) return 0;
2576 return WINPROC_CallProc16To32A( proc
->thunk
.t_from16
.proc
,
2577 hwnd
, msg
, wParam
, lParam
);
2579 if (!proc
->thunk
.t_from16
.proc
) return 0;
2580 return WINPROC_CallProc16To32W( proc
->thunk
.t_from16
.proc
,
2581 hwnd
, msg
, wParam
, lParam
);
2583 WARN_(relay
)("Invalid proc %p\n", proc
);
2589 /**********************************************************************
2590 * CallWindowProcA (USER32.@)
2592 * The CallWindowProc() function invokes the windows procedure _func_,
2593 * with _hwnd_ as the target window, the message specified by _msg_, and
2594 * the message parameters _wParam_ and _lParam_.
2596 * Some kinds of argument conversion may be done, I'm not sure what.
2598 * CallWindowProc() may be used for windows subclassing. Use
2599 * SetWindowLong() to set a new windows procedure for windows of the
2600 * subclass, and handle subclassed messages in the new windows
2601 * procedure. The new windows procedure may then use CallWindowProc()
2602 * with _func_ set to the parent class's windows procedure to dispatch
2603 * the message to the superclass.
2607 * The return value is message dependent.
2613 LRESULT WINAPI
CallWindowProcA(
2614 WNDPROC func
, /* [in] window procedure */
2615 HWND hwnd
, /* [in] target window */
2616 UINT msg
, /* [in] message */
2617 WPARAM wParam
, /* [in] message dependent parameter */
2618 LPARAM lParam
/* [in] message dependent parameter */
2620 WINDOWPROC
*proc
= WINPROC_GetPtr( (WNDPROC16
)func
);
2622 if (!proc
) return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2625 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_32A
);
2626 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2632 if (!proc
->thunk
.t_from32
.proc
) return 0;
2633 return WINPROC_CallProc32ATo16( proc
->thunk
.t_from32
.proc
,
2634 hwnd
, msg
, wParam
, lParam
);
2636 if (!proc
->thunk
.t_from16
.proc
) return 0;
2637 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
2638 hwnd
, msg
, wParam
, lParam
);
2640 if (!proc
->thunk
.t_from16
.proc
) return 0;
2641 return WINPROC_CallProc32ATo32W( proc
->thunk
.t_from16
.proc
,
2642 hwnd
, msg
, wParam
, lParam
);
2644 WARN_(relay
)("Invalid proc %p\n", proc
);
2650 /**********************************************************************
2651 * CallWindowProcW (USER32.@)
2653 LRESULT WINAPI
CallWindowProcW( WNDPROC func
, HWND hwnd
, UINT msg
,
2654 WPARAM wParam
, LPARAM lParam
)
2656 WINDOWPROC
*proc
= WINPROC_GetPtr( (WNDPROC16
)func
);
2658 if (!proc
) return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2661 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_32W
);
2662 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2668 if (!proc
->thunk
.t_from32
.proc
) return 0;
2669 return WINPROC_CallProc32WTo16( proc
->thunk
.t_from32
.proc
,
2670 hwnd
, msg
, wParam
, lParam
);
2672 if (!proc
->thunk
.t_from16
.proc
) return 0;
2673 return WINPROC_CallProc32WTo32A( proc
->thunk
.t_from16
.proc
,
2674 hwnd
, msg
, wParam
, lParam
);
2676 if (!proc
->thunk
.t_from16
.proc
) return 0;
2677 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
2678 hwnd
, msg
, wParam
, lParam
);
2680 WARN_(relay
)("Invalid proc %p\n", proc
);