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"
37 #include "user_private.h"
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
43 WINE_DECLARE_DEBUG_CHANNEL(msg
);
44 WINE_DECLARE_DEBUG_CHANNEL(relay
);
45 WINE_DEFAULT_DEBUG_CHANNEL(win
);
51 /* Window procedure 16-to-32-bit thunk */
54 BYTE popl_eax
; /* popl %eax (return address) */
55 BYTE pushl_func
; /* pushl $proc */
57 BYTE pushl_eax
; /* pushl %eax */
58 BYTE ljmp
; /* ljmp relay*/
59 DWORD relay_offset
; /* __wine_call_wndproc_32A/W */
61 } WINPROC_THUNK_FROM16
;
63 /* Window procedure 32-to-16-bit thunk */
66 BYTE popl_eax
; /* popl %eax (return address) */
67 BYTE pushl_func
; /* pushl $proc */
69 BYTE pushl_eax
; /* pushl %eax */
70 BYTE jmp
; /* jmp relay (relative jump)*/
71 void (*relay
)(); /* WINPROC_CallProc32ATo16() */
72 } WINPROC_THUNK_FROM32
;
74 /* Simple jmp to call 32-bit procedure directly */
77 BYTE jmp
; /* jmp proc (relative jump) */
88 } WINPROC_THUNK_FROM16
;
93 } WINPROC_THUNK_FROM32
;
100 #endif /* __i386__ */
104 WINPROC_THUNK_FROM16 t_from16
;
105 WINPROC_THUNK_FROM32 t_from32
;
108 typedef struct tagWINDOWPROC
110 WINPROC_THUNK thunk
; /* Thunk */
111 WINPROC_JUMP jmp
; /* Jump */
112 BYTE type
; /* Function type */
115 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
116 UINT msg
, WPARAM wParam
,
118 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
119 UINT msg
, WPARAM wParam
,
122 #define MAX_WINPROCS (0x10000 / sizeof(WINDOWPROC))
124 static WINDOWPROC winproc_array
[MAX_WINPROCS
];
125 static UINT winproc_used
;
127 static CRITICAL_SECTION winproc_cs
;
128 static CRITICAL_SECTION_DEBUG critsect_debug
=
131 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
132 0, 0, { (DWORD_PTR
)(__FILE__
": winproc_cs") }
134 static CRITICAL_SECTION winproc_cs
= { &critsect_debug
, -1, 0, 0, 0, 0 };
136 static BOOL
is_valid_winproc( WINDOWPROC
*proc
)
138 /* check alignment */
139 if (((BYTE
*)proc
- (BYTE
*)winproc_array
) % sizeof(*proc
)) return FALSE
;
140 /* check array limits */
141 if (proc
< winproc_array
|| proc
>= winproc_array
+ winproc_used
) return FALSE
;
142 return (proc
->type
!= WIN_PROC_INVALID
);
145 /* find an existing winproc for a given function and type */
146 /* FIXME: probably should do something more clever than a linear search */
147 static inline WINDOWPROC
*find_winproc( WNDPROC func
, WINDOWPROCTYPE type
)
151 if (type
== WIN_PROC_16
)
153 for (i
= 0; i
< winproc_used
; i
++)
155 if (winproc_array
[i
].type
== type
&&
156 winproc_array
[i
].thunk
.t_from32
.proc
== (WNDPROC16
)func
)
157 return &winproc_array
[i
];
162 for (i
= 0; i
< winproc_used
; i
++)
164 if (winproc_array
[i
].type
== type
&&
165 winproc_array
[i
].thunk
.t_from16
.proc
== func
)
166 return &winproc_array
[i
];
172 /* initialize a new winproc */
173 static inline void set_winproc( WINDOWPROC
*proc
, WNDPROC func
, WINDOWPROCTYPE type
)
176 static FARPROC16 relay_32A
, relay_32W
;
181 proc
->thunk
.t_from32
.popl_eax
= 0x58; /* popl %eax */
182 proc
->thunk
.t_from32
.pushl_func
= 0x68; /* pushl $proc */
183 proc
->thunk
.t_from32
.proc
= (WNDPROC16
)func
;
184 proc
->thunk
.t_from32
.pushl_eax
= 0x50; /* pushl %eax */
185 proc
->thunk
.t_from32
.jmp
= 0xe9; /* jmp relay*/
186 proc
->thunk
.t_from32
.relay
= /* relative jump */
187 (void(*)())((DWORD
)WINPROC_CallProc32ATo16
-
188 (DWORD
)(&proc
->thunk
.t_from32
.relay
+ 1));
191 if (!relay_32A
) relay_32A
= GetProcAddress16( GetModuleHandle16("user"),
192 "__wine_call_wndproc_32A" );
193 proc
->thunk
.t_from16
.popl_eax
= 0x58; /* popl %eax */
194 proc
->thunk
.t_from16
.pushl_func
= 0x68; /* pushl $proc */
195 proc
->thunk
.t_from16
.proc
= func
;
196 proc
->thunk
.t_from16
.pushl_eax
= 0x50; /* pushl %eax */
197 proc
->thunk
.t_from16
.ljmp
= 0xea; /* ljmp relay*/
198 proc
->thunk
.t_from16
.relay_offset
= OFFSETOF(relay_32A
);
199 proc
->thunk
.t_from16
.relay_sel
= SELECTOROF(relay_32A
);
200 proc
->jmp
.jmp
= 0xe9;
201 /* Fixup relative jump */
202 proc
->jmp
.proc
= (WNDPROC
)((DWORD
)func
- (DWORD
)(&proc
->jmp
.proc
+ 1));
205 if (!relay_32W
) relay_32W
= GetProcAddress16( GetModuleHandle16("user"),
206 "__wine_call_wndproc_32W" );
207 proc
->thunk
.t_from16
.popl_eax
= 0x58; /* popl %eax */
208 proc
->thunk
.t_from16
.pushl_func
= 0x68; /* pushl $proc */
209 proc
->thunk
.t_from16
.proc
= func
;
210 proc
->thunk
.t_from16
.pushl_eax
= 0x50; /* pushl %eax */
211 proc
->thunk
.t_from16
.ljmp
= 0xea; /* ljmp relay*/
212 proc
->thunk
.t_from16
.relay_offset
= OFFSETOF(relay_32W
);
213 proc
->thunk
.t_from16
.relay_sel
= SELECTOROF(relay_32W
);
214 proc
->jmp
.jmp
= 0xe9;
215 /* Fixup relative jump */
216 proc
->jmp
.proc
= (WNDPROC
)((char *)func
- (char *)(&proc
->jmp
.proc
+ 1));
219 /* Should not happen */
226 proc
->thunk
.t_from32
.proc
= (WNDPROC16
)func
;
230 proc
->thunk
.t_from16
.proc
= func
;
233 /* Should not happen */
236 #endif /* __i386__ */
241 static WORD
get_winproc_selector(void)
243 static LONG winproc_selector
;
246 if (!(ret
= winproc_selector
))
249 WORD sel
= wine_ldt_alloc_entries(1);
250 wine_ldt_set_base( &entry
, winproc_array
);
251 wine_ldt_set_limit( &entry
, sizeof(winproc_array
) - 1 );
252 wine_ldt_set_flags( &entry
, WINE_LDT_FLAGS_CODE
| WINE_LDT_FLAGS_32BIT
);
253 wine_ldt_set_entry( sel
, &entry
);
254 if (!(ret
= InterlockedCompareExchange( &winproc_selector
, sel
, 0 ))) ret
= sel
;
255 else wine_ldt_free_entries( sel
, 1 ); /* somebody beat us to it */
262 /* Some window procedures modify register they shouldn't, or are not
263 * properly declared stdcall; so we need a small assembly wrapper to
265 extern LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
266 WPARAM wParam
, LPARAM lParam
);
267 __ASM_GLOBAL_FUNC( WINPROC_wrapper
,
277 "movl 8(%ebp),%eax\n\t"
279 "leal -12(%ebp),%esp\n\t"
286 static inline LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
287 WPARAM wParam
, LPARAM lParam
)
289 return proc( hwnd
, msg
, wParam
, lParam
);
291 #endif /* __i386__ */
294 static void MINMAXINFO32to16( const MINMAXINFO
*from
, MINMAXINFO16
*to
)
296 to
->ptReserved
.x
= from
->ptReserved
.x
;
297 to
->ptReserved
.y
= from
->ptReserved
.y
;
298 to
->ptMaxSize
.x
= from
->ptMaxSize
.x
;
299 to
->ptMaxSize
.y
= from
->ptMaxSize
.y
;
300 to
->ptMaxPosition
.x
= from
->ptMaxPosition
.x
;
301 to
->ptMaxPosition
.y
= from
->ptMaxPosition
.y
;
302 to
->ptMinTrackSize
.x
= from
->ptMinTrackSize
.x
;
303 to
->ptMinTrackSize
.y
= from
->ptMinTrackSize
.y
;
304 to
->ptMaxTrackSize
.x
= from
->ptMaxTrackSize
.x
;
305 to
->ptMaxTrackSize
.y
= from
->ptMaxTrackSize
.y
;
308 static void MINMAXINFO16to32( const MINMAXINFO16
*from
, MINMAXINFO
*to
)
310 to
->ptReserved
.x
= from
->ptReserved
.x
;
311 to
->ptReserved
.y
= from
->ptReserved
.y
;
312 to
->ptMaxSize
.x
= from
->ptMaxSize
.x
;
313 to
->ptMaxSize
.y
= from
->ptMaxSize
.y
;
314 to
->ptMaxPosition
.x
= from
->ptMaxPosition
.x
;
315 to
->ptMaxPosition
.y
= from
->ptMaxPosition
.y
;
316 to
->ptMinTrackSize
.x
= from
->ptMinTrackSize
.x
;
317 to
->ptMinTrackSize
.y
= from
->ptMinTrackSize
.y
;
318 to
->ptMaxTrackSize
.x
= from
->ptMaxTrackSize
.x
;
319 to
->ptMaxTrackSize
.y
= from
->ptMaxTrackSize
.y
;
322 static void WINDOWPOS32to16( const WINDOWPOS
* from
, WINDOWPOS16
* to
)
324 to
->hwnd
= HWND_16(from
->hwnd
);
325 to
->hwndInsertAfter
= HWND_16(from
->hwndInsertAfter
);
330 to
->flags
= from
->flags
;
333 static void WINDOWPOS16to32( const WINDOWPOS16
* from
, WINDOWPOS
* to
)
335 to
->hwnd
= WIN_Handle32(from
->hwnd
);
336 to
->hwndInsertAfter
= (from
->hwndInsertAfter
== (HWND16
)-1) ?
337 HWND_TOPMOST
: WIN_Handle32(from
->hwndInsertAfter
);
342 to
->flags
= from
->flags
;
345 /* The strings are not copied */
346 static void CREATESTRUCT32Ato16( const CREATESTRUCTA
* from
, CREATESTRUCT16
* to
)
348 to
->lpCreateParams
= (SEGPTR
)from
->lpCreateParams
;
349 to
->hInstance
= HINSTANCE_16(from
->hInstance
);
350 to
->hMenu
= HMENU_16(from
->hMenu
);
351 to
->hwndParent
= HWND_16(from
->hwndParent
);
356 to
->style
= from
->style
;
357 to
->dwExStyle
= from
->dwExStyle
;
360 static void CREATESTRUCT16to32A( const CREATESTRUCT16
* from
, CREATESTRUCTA
*to
)
363 to
->lpCreateParams
= (LPVOID
)from
->lpCreateParams
;
364 to
->hInstance
= HINSTANCE_32(from
->hInstance
);
365 to
->hMenu
= HMENU_32(from
->hMenu
);
366 to
->hwndParent
= WIN_Handle32(from
->hwndParent
);
371 to
->style
= from
->style
;
372 to
->dwExStyle
= from
->dwExStyle
;
375 /* The strings are not copied */
376 static void MDICREATESTRUCT32Ato16( const MDICREATESTRUCTA
* from
, MDICREATESTRUCT16
* to
)
378 to
->hOwner
= HINSTANCE_16(from
->hOwner
);
383 to
->style
= from
->style
;
384 to
->lParam
= from
->lParam
;
387 static void MDICREATESTRUCT16to32A( const MDICREATESTRUCT16
* from
, MDICREATESTRUCTA
*to
)
389 to
->hOwner
= HINSTANCE_32(from
->hOwner
);
394 to
->style
= from
->style
;
395 to
->lParam
= from
->lParam
;
398 /**********************************************************************
399 * WINPROC_CallWndProc32
401 * Call a 32-bit WndProc.
403 static LRESULT
WINPROC_CallWndProc( WNDPROC proc
, HWND hwnd
, UINT msg
,
404 WPARAM wParam
, LPARAM lParam
)
410 hwnd
= WIN_GetFullHandle( hwnd
);
412 DPRINTF( "%04lx:Call window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
413 GetCurrentThreadId(), proc
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
415 retvalue
= WINPROC_wrapper( proc
, hwnd
, msg
, wParam
, lParam
);
418 DPRINTF( "%04lx:Ret window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx) retval=%08lx\n",
419 GetCurrentThreadId(), proc
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
, retvalue
);
423 /***********************************************************************
424 * WINPROC_CallWndProc16
426 * Call a 16-bit window procedure
428 static LRESULT WINAPI
WINPROC_CallWndProc16( WNDPROC16 proc
, HWND16 hwnd
,
429 UINT16 msg
, WPARAM16 wParam
,
440 DRAWITEMSTRUCT16 dis16
;
441 COMPAREITEMSTRUCT16 cis16
;
447 /* Window procedures want ax = hInstance, ds = es = ss */
449 memset(&context
, 0, sizeof(context
));
450 context
.SegDs
= context
.SegEs
= SELECTOROF(NtCurrentTeb()->WOW32Reserved
);
451 context
.SegFs
= wine_get_fs();
452 context
.SegGs
= wine_get_gs();
453 if (!(context
.Eax
= GetWindowWord( HWND_32(hwnd
), GWLP_HINSTANCE
))) context
.Eax
= context
.SegDs
;
454 context
.SegCs
= SELECTOROF(proc
);
455 context
.Eip
= OFFSETOF(proc
);
456 context
.Ebp
= OFFSETOF(NtCurrentTeb()->WOW32Reserved
) + (WORD
)&((STACK16FRAME
*)0)->bp
;
460 /* Some programs (eg. the "Undocumented Windows" examples, JWP) only
461 work if structures passed in lParam are placed in the stack/data
462 segment. Programmers easily make the mistake of converting lParam
463 to a near rather than a far pointer, since Windows apparently
464 allows this. We copy the structures to the 16 bit stack; this is
465 ugly but makes these programs work. */
470 size
= sizeof(CREATESTRUCT16
); break;
472 size
= sizeof(DRAWITEMSTRUCT16
); break;
474 size
= sizeof(COMPAREITEMSTRUCT16
); break;
478 memcpy( &args
.u
, MapSL(lParam
), size
);
479 lParam
= (SEGPTR
)NtCurrentTeb()->WOW32Reserved
- size
;
483 args
.params
[4] = hwnd
;
484 args
.params
[3] = msg
;
485 args
.params
[2] = wParam
;
486 args
.params
[1] = HIWORD(lParam
);
487 args
.params
[0] = LOWORD(lParam
);
488 WOWCallback16Ex( 0, WCB16_REGS
, sizeof(args
.params
) + size
, &args
, (DWORD
*)&context
);
489 return MAKELONG( LOWORD(context
.Eax
), LOWORD(context
.Edx
) );
493 /**********************************************************************
496 * Return a pointer to the win proc.
498 static WINDOWPROC
*WINPROC_GetPtr( WNDPROC handle
)
503 /* ptr cannot be < 64K */
504 if (!HIWORD(handle
)) return NULL
;
506 /* Check for a linear pointer */
508 ptr
= (BYTE
*)handle
;
509 /* First check if it is the jmp address */
510 proc
= (WINDOWPROC
*)(ptr
- FIELD_OFFSET(WINDOWPROC
,jmp
));
511 if (is_valid_winproc(proc
)) return proc
;
513 /* Now it must be the thunk address */
514 proc
= (WINDOWPROC
*)(ptr
- FIELD_OFFSET(WINDOWPROC
,thunk
));
515 if (is_valid_winproc(proc
)) return proc
;
517 /* Check for a segmented pointer */
519 if (HIWORD(handle
) == get_winproc_selector())
521 ptr
= (BYTE
*)winproc_array
+ LOWORD(handle
);
522 /* It must be the thunk address */
523 proc
= (WINDOWPROC
*)(ptr
- FIELD_OFFSET(WINDOWPROC
,thunk
));
524 if (is_valid_winproc(proc
)) return proc
;
530 /**********************************************************************
533 * Get a window procedure pointer that can be passed to the Windows program.
535 WNDPROC16
WINPROC_GetProc( WNDPROC proc
, WINDOWPROCTYPE type
)
537 WINDOWPROC
*ptr
= (WINDOWPROC
*)proc
;
539 if (!proc
) return NULL
;
540 if (type
== WIN_PROC_16
) /* We want a 16:16 address */
542 if (ptr
->type
== WIN_PROC_16
)
543 return ptr
->thunk
.t_from32
.proc
;
545 return (WNDPROC16
)MAKESEGPTR( get_winproc_selector(),
546 (char *)&ptr
->thunk
- (char *)winproc_array
);
548 else /* We want a 32-bit address */
550 if (ptr
->type
== WIN_PROC_16
)
551 return (WNDPROC16
)&ptr
->thunk
;
552 else if (type
!= ptr
->type
)
553 /* Have to return the jmp address if types don't match */
554 return (WNDPROC16
)&ptr
->jmp
;
556 /* Some Win16 programs want to get back the proc they set */
557 return (WNDPROC16
)ptr
->thunk
.t_from16
.proc
;
562 /**********************************************************************
565 * Allocate a window procedure for a window or class.
567 * Note that allocated winprocs are never freed; the idea is that even if an app creates a
568 * lot of windows, it will usually only have a limited number of window procedures, so the
569 * array won't grow too large, and this way we avoid the need to track allocations per window.
571 WNDPROC
WINPROC_AllocProc( WNDPROC func
, WINDOWPROCTYPE type
)
575 if (!func
) return NULL
;
577 EnterCriticalSection( &winproc_cs
);
579 /* check if the function is already a win proc */
580 if (!(proc
= WINPROC_GetPtr( func
)))
582 /* then check if we already have a winproc for that function */
583 if (!(proc
= find_winproc( func
, type
)))
585 if (winproc_used
>= MAX_WINPROCS
)
586 FIXME( "too many winprocs, cannot allocate one for %p/%d\n", func
, type
);
589 proc
= &winproc_array
[winproc_used
++];
590 set_winproc( proc
, func
, type
);
591 TRACE( "allocated %p for %p/%d (%d/%d used)\n",
592 proc
, func
, type
, winproc_used
, MAX_WINPROCS
);
595 else TRACE( "reusing %p for %p/%d\n", proc
, func
, type
);
598 LeaveCriticalSection( &winproc_cs
);
599 return (WNDPROC
)proc
;
603 /**********************************************************************
604 * WINPROC_GetProcType
606 * Return the window procedure type.
608 WINDOWPROCTYPE
WINPROC_GetProcType( WNDPROC proc
)
610 if (!proc
) return WIN_PROC_INVALID
;
611 return ((WINDOWPROC
*)proc
)->type
;
613 /**********************************************************************
614 * WINPROC_TestCBForStr
616 * Return TRUE if the lparam is a string
618 inline static BOOL
WINPROC_TestCBForStr( HWND hwnd
)
620 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
621 return (!(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) || (style
& CBS_HASSTRINGS
));
623 /**********************************************************************
624 * WINPROC_TestLBForStr
626 * Return TRUE if the lparam is a string
628 inline static BOOL
WINPROC_TestLBForStr( HWND hwnd
)
630 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
631 return (!(style
& (LBS_OWNERDRAWFIXED
| LBS_OWNERDRAWVARIABLE
)) || (style
& LBS_HASSTRINGS
));
634 /**********************************************************************
635 * WINPROC_MapMsg32ATo32W
637 * Map a message from Ansi to Unicode.
638 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
641 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
642 * the first four bytes are the handle of the icon
643 * when the WM_SETTEXT message has been used to set the icon
645 INT
WINPROC_MapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
650 case WM_ASKCBFORMATNAME
:
652 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0,
653 *pwparam
* sizeof(WCHAR
) + sizeof(LPARAM
) );
655 *ptr
++ = *plparam
; /* Store previous lParam */
656 *plparam
= (LPARAM
)ptr
;
659 /* lparam is string (0-terminated) */
661 case WM_WININICHANGE
:
662 case WM_DEVMODECHANGE
:
667 if (!*plparam
) return 0;
670 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*plparam
, -1, NULL
, 0);
671 WCHAR
*buf
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
672 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*plparam
, -1, buf
, len
);
673 *plparam
= (LPARAM
)buf
;
674 return (*plparam
? 1 : -1);
676 case WM_GETTEXTLENGTH
:
677 case CB_GETLBTEXTLEN
:
679 return 1; /* need to map result */
683 UNICODE_STRING usBuffer
;
685 { CREATESTRUCTW cs
; /* new structure */
686 LPCWSTR lpszName
; /* allocated Name */
687 LPCWSTR lpszClass
; /* allocated Class */
690 struct s
*xs
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct s
));
692 xs
->cs
= *(CREATESTRUCTW
*)*plparam
;
693 if (HIWORD(xs
->cs
.lpszName
))
695 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)xs
->cs
.lpszName
);
696 xs
->lpszName
= xs
->cs
.lpszName
= usBuffer
.Buffer
;
698 if (HIWORD(xs
->cs
.lpszClass
))
700 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)xs
->cs
.lpszClass
);
701 xs
->lpszClass
= xs
->cs
.lpszClass
= usBuffer
.Buffer
;
704 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
706 MDICREATESTRUCTW
*mdi_cs
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs
));
707 *mdi_cs
= *(MDICREATESTRUCTW
*)xs
->cs
.lpCreateParams
;
708 if (HIWORD(mdi_cs
->szTitle
))
710 RtlCreateUnicodeStringFromAsciiz(&usBuffer
, (LPCSTR
)mdi_cs
->szTitle
);
711 mdi_cs
->szTitle
= usBuffer
.Buffer
;
713 if (HIWORD(mdi_cs
->szClass
))
715 RtlCreateUnicodeStringFromAsciiz(&usBuffer
, (LPCSTR
)mdi_cs
->szClass
);
716 mdi_cs
->szClass
= usBuffer
.Buffer
;
718 xs
->cs
.lpCreateParams
= mdi_cs
;
721 *plparam
= (LPARAM
)xs
;
726 MDICREATESTRUCTW
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
728 *cs
= *(MDICREATESTRUCTW
*)*plparam
;
729 if (HIWORD(cs
->szClass
))
731 UNICODE_STRING usBuffer
;
732 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)cs
->szClass
);
733 cs
->szClass
= usBuffer
.Buffer
;
735 if (HIWORD(cs
->szTitle
))
737 UNICODE_STRING usBuffer
;
738 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)cs
->szTitle
);
739 cs
->szTitle
= usBuffer
.Buffer
;
741 *plparam
= (LPARAM
)cs
;
747 case LB_INSERTSTRING
:
749 case LB_FINDSTRINGEXACT
:
750 case LB_SELECTSTRING
:
751 if(!*plparam
) return 0;
752 if ( WINPROC_TestLBForStr( hwnd
))
754 UNICODE_STRING usBuffer
;
755 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)*plparam
);
756 *plparam
= (LPARAM
)usBuffer
.Buffer
;
758 return (*plparam
? 1 : -1);
760 case LB_GETTEXT
: /* FIXME: fixed sized buffer */
761 { if ( WINPROC_TestLBForStr( hwnd
))
762 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 * sizeof(WCHAR
) + sizeof(LPARAM
) );
764 *ptr
++ = *plparam
; /* Store previous lParam */
765 *plparam
= (LPARAM
)ptr
;
772 case CB_INSERTSTRING
:
773 case CB_FINDSTRINGEXACT
:
775 case CB_SELECTSTRING
:
776 if(!*plparam
) return 0;
777 if ( WINPROC_TestCBForStr( hwnd
))
779 UNICODE_STRING usBuffer
;
780 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)*plparam
);
781 *plparam
= (LPARAM
)usBuffer
.Buffer
;
783 return (*plparam
? 1 : -1);
785 case CB_GETLBTEXT
: /* FIXME: fixed sized buffer */
786 { if ( WINPROC_TestCBForStr( hwnd
))
787 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 * sizeof(WCHAR
) + sizeof(LPARAM
) );
789 *ptr
++ = *plparam
; /* Store previous lParam */
790 *plparam
= (LPARAM
)ptr
;
797 { WORD len
= (WORD
)*plparam
;
798 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(WCHAR
) );
800 *ptr
++ = *plparam
; /* Store previous lParam */
801 *((WORD
*) ptr
) = len
; /* Store the length */
802 *plparam
= (LPARAM
)ptr
;
812 case EM_SETPASSWORDCHAR
:
814 CHAR ch
= LOWORD(*pwparam
);
816 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wch
, 1);
817 *pwparam
= MAKEWPARAM( wch
, HIWORD(*pwparam
) );
825 ch
[0] = (*pwparam
>> 8);
826 ch
[1] = *pwparam
& 0xff;
828 MultiByteToWideChar(CP_ACP
, 0, ch
, 2, &wch
, 1);
830 MultiByteToWideChar(CP_ACP
, 0, &ch
[1], 1, &wch
, 1);
831 *pwparam
= MAKEWPARAM( wch
, HIWORD(*pwparam
) );
835 case WM_PAINTCLIPBOARD
:
836 case WM_SIZECLIPBOARD
:
837 FIXME_(msg
)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg
, hwnd
), msg
);
839 default: /* No translation needed */
845 /**********************************************************************
846 * WINPROC_UnmapMsg32ATo32W
848 * Unmap a message that was mapped from Ansi to Unicode.
850 LRESULT
WINPROC_UnmapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
851 LRESULT result
, WNDPROC dispatch
)
856 case WM_ASKCBFORMATNAME
:
858 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
859 if (!wParam
) result
= 0;
860 else if (!(result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
861 (LPSTR
)*ptr
, wParam
, NULL
, NULL
)))
863 ((LPSTR
)*ptr
)[wParam
-1] = 0;
866 else result
--; /* do not count terminating null */
867 HeapFree( GetProcessHeap(), 0, ptr
);
870 case WM_GETTEXTLENGTH
:
871 case CB_GETLBTEXTLEN
:
875 /* Determine respective GETTEXT message */
877 (msg
== WM_GETTEXTLENGTH
) ? WM_GETTEXT
:
878 ((msg
== CB_GETLBTEXTLEN
) ? CB_GETLBTEXT
: LB_GETTEXT
);
879 /* wParam differs between the messages */
880 WPARAM wp
= (msg
== WM_GETTEXTLENGTH
) ? (WPARAM
)(result
+ 1) : wParam
;
882 WCHAR
* p
= HeapAlloc (GetProcessHeap(), 0, (result
+ 1) * sizeof(WCHAR
));
889 n
= WINPROC_CallWndProc(dispatch
, hwnd
, msgGetText
, wp
, (LPARAM
)p
);
891 n
= SendMessageW (hwnd
, msgGetText
, wp
, (LPARAM
)p
);
893 result
= WideCharToMultiByte( CP_ACP
, 0, p
, n
, NULL
, 0, 0, NULL
);
894 HeapFree (GetProcessHeap(), 0, p
);
902 { CREATESTRUCTW cs
; /* new structure */
903 LPWSTR lpszName
; /* allocated Name */
904 LPWSTR lpszClass
; /* allocated Class */
906 struct s
*xs
= (struct s
*)lParam
;
907 HeapFree( GetProcessHeap(), 0, xs
->lpszName
);
908 HeapFree( GetProcessHeap(), 0, xs
->lpszClass
);
910 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
912 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)xs
->cs
.lpCreateParams
;
913 if (HIWORD(mdi_cs
->szTitle
))
914 HeapFree(GetProcessHeap(), 0, (LPVOID
)mdi_cs
->szTitle
);
915 if (HIWORD(mdi_cs
->szClass
))
916 HeapFree(GetProcessHeap(), 0, (LPVOID
)mdi_cs
->szClass
);
917 HeapFree(GetProcessHeap(), 0, mdi_cs
);
919 HeapFree( GetProcessHeap(), 0, xs
);
925 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
926 if (HIWORD(cs
->szTitle
))
927 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
928 if (HIWORD(cs
->szClass
))
929 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
930 HeapFree( GetProcessHeap(), 0, cs
);
935 case WM_WININICHANGE
:
936 case WM_DEVMODECHANGE
:
941 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
946 case LB_INSERTSTRING
:
948 case LB_FINDSTRINGEXACT
:
949 case LB_SELECTSTRING
:
950 if ( WINPROC_TestLBForStr( hwnd
))
951 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
955 if ( WINPROC_TestLBForStr( hwnd
))
957 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
958 result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
959 (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
) - 1;
960 HeapFree( GetProcessHeap(), 0, ptr
);
966 case CB_INSERTSTRING
:
968 case CB_FINDSTRINGEXACT
:
969 case CB_SELECTSTRING
:
970 if ( WINPROC_TestCBForStr( hwnd
))
971 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
975 if ( result
< 0) /* CB_ERR and CB_ERRSPACE */
977 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
978 HeapFree( GetProcessHeap(), 0, ptr
);
980 else if ( WINPROC_TestCBForStr( hwnd
))
982 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
983 result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
984 (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
) - 1;
985 HeapFree( GetProcessHeap(), 0, ptr
);
992 LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lParam */
993 WORD len
= *(WORD
*) lParam
;
994 result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, result
,
995 (LPSTR
)*ptr
, len
, NULL
, NULL
);
996 if (result
< len
) ((LPSTR
)*ptr
)[result
] = 0;
997 HeapFree( GetProcessHeap(), 0, ptr
);
1005 /**********************************************************************
1006 * WINPROC_MapMsg32WTo32A
1008 * Map a message from Unicode to Ansi.
1009 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1011 static INT
WINPROC_MapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
1016 case WM_ASKCBFORMATNAME
:
1018 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, *pwparam
+ sizeof(LPARAM
) );
1019 if (!ptr
) return -1;
1020 *ptr
++ = *plparam
; /* Store previous lParam */
1021 *plparam
= (LPARAM
)ptr
;
1026 case WM_WININICHANGE
:
1027 case WM_DEVMODECHANGE
:
1034 LPCWSTR str
= (LPCWSTR
)*plparam
;
1035 int len
= WideCharToMultiByte(CP_ACP
, 0, str
, -1, NULL
, 0, 0, 0);
1036 *plparam
= (LPARAM
)HeapAlloc(GetProcessHeap(), 0, len
);
1037 if (!*plparam
) return -1;
1038 WideCharToMultiByte(CP_ACP
, 0, str
, -1, (LPSTR
)*plparam
, len
, 0, 0);
1045 MDICREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
1047 *cs
= *(MDICREATESTRUCTA
*)*plparam
;
1048 if (HIWORD(cs
->szTitle
))
1050 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szTitle
, -1, NULL
, 0, 0, 0);
1051 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1052 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szTitle
, -1, buf
, len
, 0, 0);
1055 if (HIWORD(cs
->szClass
))
1057 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szClass
, -1, NULL
, 0, 0, 0);
1058 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1059 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szClass
, -1, buf
, len
, 0, 0);
1062 *plparam
= (LPARAM
)cs
;
1068 case LB_INSERTSTRING
:
1070 case LB_FINDSTRINGEXACT
:
1071 case LB_SELECTSTRING
:
1072 if(!*plparam
) return 0;
1073 if ( WINPROC_TestLBForStr( hwnd
))
1075 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, NULL
, 0, 0, 0);
1076 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1077 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, buf
, len
, 0, 0);
1078 *plparam
= (LPARAM
)buf
;
1080 return (*plparam
? 1 : -1);
1082 case LB_GETTEXT
: /* FIXME: fixed sized buffer */
1083 { if ( WINPROC_TestLBForStr( hwnd
))
1084 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 + sizeof(LPARAM
) );
1085 if (!ptr
) return -1;
1086 *ptr
++ = *plparam
; /* Store previous lParam */
1087 *plparam
= (LPARAM
)ptr
;
1094 case CB_INSERTSTRING
:
1096 case CB_FINDSTRINGEXACT
:
1097 case CB_SELECTSTRING
:
1098 if(!*plparam
) return 0;
1099 if ( WINPROC_TestCBForStr( hwnd
))
1101 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, NULL
, 0, 0, 0);
1102 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1103 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, buf
, len
, 0, 0);
1104 *plparam
= (LPARAM
)buf
;
1106 return (*plparam
? 1 : -1);
1108 case CB_GETLBTEXT
: /* FIXME: fixed sized buffer */
1109 { if ( WINPROC_TestCBForStr( hwnd
))
1110 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 + sizeof(LPARAM
) );
1111 if (!ptr
) return -1;
1112 *ptr
++ = *plparam
; /* Store previous lParam */
1113 *plparam
= (LPARAM
)ptr
;
1118 /* Multiline edit */
1120 { WORD len
= (WORD
)*plparam
;
1121 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(CHAR
) );
1122 if (!ptr
) return -1;
1123 *ptr
++ = *plparam
; /* Store previous lParam */
1124 *((WORD
*) ptr
) = len
; /* Store the length */
1125 *plparam
= (LPARAM
)ptr
;
1134 case WM_SYSDEADCHAR
:
1135 case EM_SETPASSWORDCHAR
:
1137 WCHAR wch
= LOWORD(*pwparam
);
1139 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
1140 *pwparam
= MAKEWPARAM( ch
, HIWORD(*pwparam
) );
1146 WCHAR wch
= LOWORD(*pwparam
);
1149 if (WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)ch
, 2, NULL
, NULL
) == 2)
1150 *pwparam
= MAKEWPARAM( (ch
[0] << 8) | ch
[1], HIWORD(*pwparam
) );
1152 *pwparam
= MAKEWPARAM( ch
[0], HIWORD(*pwparam
) );
1156 case WM_PAINTCLIPBOARD
:
1157 case WM_SIZECLIPBOARD
:
1158 FIXME_(msg
)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg
, hwnd
),msg
);
1160 default: /* No translation needed */
1166 /**********************************************************************
1167 * WINPROC_UnmapMsg32WTo32A
1169 * Unmap a message that was mapped from Unicode to Ansi.
1171 static LRESULT
WINPROC_UnmapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
, LRESULT result
)
1176 case WM_ASKCBFORMATNAME
:
1178 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1179 if (!wParam
) result
= 0;
1180 else if (!(result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1,
1181 (LPWSTR
)*ptr
, wParam
)))
1183 ((LPWSTR
)*ptr
)[wParam
-1] = 0;
1184 result
= wParam
- 1;
1186 else result
--; /* do not count terminating null */
1187 HeapFree( GetProcessHeap(), 0, ptr
);
1192 case WM_WININICHANGE
:
1193 case WM_DEVMODECHANGE
:
1198 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1203 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1204 if (HIWORD(cs
->szTitle
))
1205 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
1206 if (HIWORD(cs
->szClass
))
1207 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
1208 HeapFree( GetProcessHeap(), 0, cs
);
1214 case LB_INSERTSTRING
:
1216 case LB_FINDSTRINGEXACT
:
1217 case LB_SELECTSTRING
:
1218 if ( WINPROC_TestLBForStr( hwnd
))
1219 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1223 if ( WINPROC_TestLBForStr( hwnd
))
1225 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1226 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff ) - 1;
1227 HeapFree( GetProcessHeap(), 0, ptr
);
1233 case CB_INSERTSTRING
:
1235 case CB_FINDSTRINGEXACT
:
1236 case CB_SELECTSTRING
:
1237 if ( WINPROC_TestCBForStr( hwnd
))
1238 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1242 if ( result
< 0) /* CB_ERR and CB_ERRSPACE */
1244 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1245 HeapFree( GetProcessHeap(), 0, ptr
);
1247 else if ( WINPROC_TestCBForStr( hwnd
))
1249 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1250 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff ) - 1;
1251 HeapFree( GetProcessHeap(), 0, ptr
);
1255 /* Multiline edit */
1258 LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lparam */
1259 WORD len
= *(WORD
*)ptr
;
1262 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, result
, (LPWSTR
)*ptr
, len
);
1263 if (result
< len
) ((LPWSTR
)*ptr
)[result
] = 0;
1265 HeapFree( GetProcessHeap(), 0, ptr
);
1272 static UINT
convert_handle_16_to_32(HANDLE16 src
, unsigned int flags
)
1275 UINT sz
= GlobalSize16(src
);
1278 if (!(dst
= GlobalAlloc(flags
, sz
)))
1280 ptr16
= GlobalLock16(src
);
1281 ptr32
= GlobalLock(dst
);
1282 if (ptr16
!= NULL
&& ptr32
!= NULL
) memcpy(ptr32
, ptr16
, sz
);
1283 GlobalUnlock16(src
);
1289 /**********************************************************************
1290 * WINPROC_MapMsg16To32A
1292 * Map a message from 16- to 32-bit Ansi.
1293 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1295 INT
WINPROC_MapMsg16To32A( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1296 WPARAM
*pwparam32
, LPARAM
*plparam
)
1298 *pmsg32
= (UINT
)msg16
;
1299 *pwparam32
= (WPARAM
)wParam16
;
1306 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1307 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1311 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1312 *plparam
= (LPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1315 if ( HIWORD(*plparam
) > CTLCOLOR_STATIC
) return -1;
1316 *pmsg32
= WM_CTLCOLORMSGBOX
+ HIWORD(*plparam
);
1317 *pwparam32
= (WPARAM
)HDC_32(wParam16
);
1318 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1320 case WM_COMPAREITEM
:
1322 COMPAREITEMSTRUCT16
* cis16
= MapSL(*plparam
);
1323 COMPAREITEMSTRUCT
*cis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cis
));
1324 if (!cis
) return -1;
1325 cis
->CtlType
= cis16
->CtlType
;
1326 cis
->CtlID
= cis16
->CtlID
;
1327 cis
->hwndItem
= WIN_Handle32( cis16
->hwndItem
);
1328 cis
->itemID1
= cis16
->itemID1
;
1329 cis
->itemData1
= cis16
->itemData1
;
1330 cis
->itemID2
= cis16
->itemID2
;
1331 cis
->itemData2
= cis16
->itemData2
;
1332 cis
->dwLocaleId
= 0; /* FIXME */
1333 *plparam
= (LPARAM
)cis
;
1338 PCOPYDATASTRUCT16 pcds16
= MapSL(*plparam
);
1339 PCOPYDATASTRUCT pcds
= HeapAlloc ( GetProcessHeap(), 0, sizeof(*pcds
));
1340 pcds
->dwData
= pcds16
->dwData
;
1341 pcds
->cbData
= pcds16
->cbData
;
1342 pcds
->lpData
= MapSL( pcds16
->lpData
);
1343 *plparam
= (LPARAM
)pcds
;
1348 DELETEITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1349 DELETEITEMSTRUCT
*dis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1350 if (!dis
) return -1;
1351 dis
->CtlType
= dis16
->CtlType
;
1352 dis
->CtlID
= dis16
->CtlID
;
1353 dis
->hwndItem
= WIN_Handle32( dis16
->hwndItem
);
1354 dis
->itemData
= dis16
->itemData
;
1355 *plparam
= (LPARAM
)dis
;
1358 case WM_MEASUREITEM
:
1360 MEASUREITEMSTRUCT16
* mis16
= MapSL(*plparam
);
1361 MEASUREITEMSTRUCT
*mis
= HeapAlloc(GetProcessHeap(), 0,
1362 sizeof(*mis
) + sizeof(LPARAM
));
1363 if (!mis
) return -1;
1364 mis
->CtlType
= mis16
->CtlType
;
1365 mis
->CtlID
= mis16
->CtlID
;
1366 mis
->itemID
= mis16
->itemID
;
1367 mis
->itemWidth
= mis16
->itemWidth
;
1368 mis
->itemHeight
= mis16
->itemHeight
;
1369 mis
->itemData
= mis16
->itemData
;
1370 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1371 *plparam
= (LPARAM
)mis
;
1376 DRAWITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1377 DRAWITEMSTRUCT
*dis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1378 if (!dis
) return -1;
1379 dis
->CtlType
= dis16
->CtlType
;
1380 dis
->CtlID
= dis16
->CtlID
;
1381 dis
->itemID
= dis16
->itemID
;
1382 dis
->itemAction
= dis16
->itemAction
;
1383 dis
->itemState
= dis16
->itemState
;
1384 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND
)HMENU_32(dis16
->hwndItem
)
1385 : WIN_Handle32( dis16
->hwndItem
);
1386 dis
->hDC
= HDC_32(dis16
->hDC
);
1387 dis
->itemData
= dis16
->itemData
;
1388 dis
->rcItem
.left
= dis16
->rcItem
.left
;
1389 dis
->rcItem
.top
= dis16
->rcItem
.top
;
1390 dis
->rcItem
.right
= dis16
->rcItem
.right
;
1391 dis
->rcItem
.bottom
= dis16
->rcItem
.bottom
;
1392 *plparam
= (LPARAM
)dis
;
1395 case WM_GETMINMAXINFO
:
1397 MINMAXINFO
*mmi
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mmi
) + sizeof(LPARAM
));
1398 if (!mmi
) return -1;
1399 MINMAXINFO16to32( MapSL(*plparam
), mmi
);
1400 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1401 *plparam
= (LPARAM
)mmi
;
1406 case WM_WININICHANGE
:
1407 case WM_DEVMODECHANGE
:
1408 case WM_ASKCBFORMATNAME
:
1409 *plparam
= (LPARAM
)MapSL(*plparam
);
1413 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1414 MDICREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1416 MDICREATESTRUCT16to32A( cs16
, cs
);
1417 cs
->szTitle
= MapSL(cs16
->szTitle
);
1418 cs
->szClass
= MapSL(cs16
->szClass
);
1419 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1420 *plparam
= (LPARAM
)cs
;
1423 case WM_MDIGETACTIVE
:
1424 *plparam
= (LPARAM
)HeapAlloc( GetProcessHeap(), 0, sizeof(BOOL
) );
1425 *(BOOL
*)(*plparam
) = 0;
1428 if(wParam16
) *pmsg32
=WM_MDIREFRESHMENU
;
1429 *pwparam32
= (WPARAM
)HMENU_32(LOWORD(*plparam
));
1430 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1433 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1434 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1437 if((LOWORD(*plparam
) & MF_POPUP
) && (LOWORD(*plparam
) != 0xFFFF))
1439 HMENU hmenu
=HMENU_32(HIWORD(*plparam
));
1440 UINT Pos
=MENU_FindSubMenu( &hmenu
, HMENU_32(wParam16
));
1441 if(Pos
==0xFFFF) Pos
=0; /* NO_SELECTED_ITEM */
1442 *pwparam32
= MAKEWPARAM( Pos
, LOWORD(*plparam
) );
1444 else *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1445 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1447 case WM_MDIACTIVATE
:
1450 *pwparam32
= (WPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1451 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1453 else /* message sent to MDI client */
1454 *pwparam32
= wParam16
;
1458 NCCALCSIZE_PARAMS16
*nc16
;
1459 NCCALCSIZE_PARAMS
*nc
;
1461 nc
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
) + sizeof(LPARAM
) );
1463 nc16
= MapSL(*plparam
);
1464 nc
->rgrc
[0].left
= nc16
->rgrc
[0].left
;
1465 nc
->rgrc
[0].top
= nc16
->rgrc
[0].top
;
1466 nc
->rgrc
[0].right
= nc16
->rgrc
[0].right
;
1467 nc
->rgrc
[0].bottom
= nc16
->rgrc
[0].bottom
;
1470 nc
->lppos
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
->lppos
) );
1471 nc
->rgrc
[1].left
= nc16
->rgrc
[1].left
;
1472 nc
->rgrc
[1].top
= nc16
->rgrc
[1].top
;
1473 nc
->rgrc
[1].right
= nc16
->rgrc
[1].right
;
1474 nc
->rgrc
[1].bottom
= nc16
->rgrc
[1].bottom
;
1475 nc
->rgrc
[2].left
= nc16
->rgrc
[2].left
;
1476 nc
->rgrc
[2].top
= nc16
->rgrc
[2].top
;
1477 nc
->rgrc
[2].right
= nc16
->rgrc
[2].right
;
1478 nc
->rgrc
[2].bottom
= nc16
->rgrc
[2].bottom
;
1479 if (nc
->lppos
) WINDOWPOS16to32( MapSL(nc16
->lppos
), nc
->lppos
);
1481 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1482 *plparam
= (LPARAM
)nc
;
1488 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1489 CREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1491 CREATESTRUCT16to32A( cs16
, cs
);
1492 cs
->lpszName
= MapSL(cs16
->lpszName
);
1493 cs
->lpszClass
= MapSL(cs16
->lpszClass
);
1495 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1497 MDICREATESTRUCT16
*mdi_cs16
;
1498 MDICREATESTRUCTA
*mdi_cs
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs
));
1501 HeapFree(GetProcessHeap(), 0, cs
);
1504 mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs16
->lpCreateParams
);
1505 MDICREATESTRUCT16to32A(mdi_cs16
, mdi_cs
);
1506 mdi_cs
->szTitle
= MapSL(mdi_cs16
->szTitle
);
1507 mdi_cs
->szClass
= MapSL(mdi_cs16
->szClass
);
1509 cs
->lpCreateParams
= mdi_cs
;
1511 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1512 *plparam
= (LPARAM
)cs
;
1515 case WM_PARENTNOTIFY
:
1516 if ((wParam16
== WM_CREATE
) || (wParam16
== WM_DESTROY
))
1518 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1519 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1522 case WM_WINDOWPOSCHANGING
:
1523 case WM_WINDOWPOSCHANGED
:
1525 WINDOWPOS
*wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*wp
) + sizeof(LPARAM
) );
1527 WINDOWPOS16to32( MapSL(*plparam
), wp
);
1528 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1529 *plparam
= (LPARAM
)wp
;
1535 LPMSG16 msg16
= MapSL(*plparam
);
1536 LPMSG msg32
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1538 if (!msg32
) return -1;
1539 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1540 msg32
->lParam
= msg16
->lParam
;
1541 msg32
->time
= msg16
->time
;
1542 msg32
->pt
.x
= msg16
->pt
.x
;
1543 msg32
->pt
.y
= msg16
->pt
.y
;
1544 /* this is right, right? */
1545 if (WINPROC_MapMsg16To32A( msg32
->hwnd
, msg16
->message
,msg16
->wParam
,
1546 &msg32
->message
,&msg32
->wParam
,
1547 &msg32
->lParam
)<0) {
1548 HeapFree( GetProcessHeap(), 0, msg32
);
1551 *plparam
= (LPARAM
)msg32
;
1556 *plparam
= (LPARAM
)MapSL(*plparam
);
1558 case WM_ACTIVATEAPP
:
1559 /* We need this when SetActiveWindow sends a Sendmessage16() to
1560 * a 32bit window. Might be superflous with 32bit interprocess
1561 * message queues. */
1562 if (*plparam
) *plparam
= HTASK_32( *plparam
);
1566 MDINEXTMENU
*next
= HeapAlloc( GetProcessHeap(), 0, sizeof(*next
) );
1567 if (!next
) return -1;
1568 next
->hmenuIn
= (HMENU
)*plparam
;
1569 next
->hmenuNext
= 0;
1571 *plparam
= (LPARAM
)next
;
1574 case WM_PAINTCLIPBOARD
:
1575 case WM_SIZECLIPBOARD
:
1576 FIXME_(msg
)("message %04x needs translation\n",msg16
);
1578 case WM_DDE_INITIATE
:
1579 case WM_DDE_TERMINATE
:
1580 case WM_DDE_UNADVISE
:
1581 case WM_DDE_REQUEST
:
1582 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1592 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1593 lo16
= LOWORD(*plparam
);
1594 hi
= HIWORD(*plparam
);
1595 if (lo16
&& !(lo32
= convert_handle_16_to_32(lo16
, GMEM_DDESHARE
)))
1597 *plparam
= PackDDElParam(msg16
, lo32
, hi
);
1599 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1606 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1608 lo
= LOWORD(*plparam
);
1609 hi
= HIWORD(*plparam
);
1611 if (GlobalGetAtomNameA(hi
, buf
, 2) > 0) flag
|= 1;
1612 if (GlobalSize16(hi
) != 0) flag
|= 2;
1618 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
1623 break; /* atom, nothing to do */
1625 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi
);
1628 hi
= convert_handle_16_to_32(hi
, GMEM_DDESHARE
);
1631 *plparam
= PackDDElParam(WM_DDE_ACK
, lo
, hi
);
1633 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1634 case WM_DDE_EXECUTE
:
1635 *plparam
= convert_handle_16_to_32(*plparam
, GMEM_DDESHARE
);
1636 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1637 default: /* No translation needed */
1643 /**********************************************************************
1644 * WINPROC_UnmapMsg16To32A
1646 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1648 LRESULT
WINPROC_UnmapMsg16To32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1653 case WM_COMPAREITEM
:
1657 HeapFree( GetProcessHeap(), 0, (LPVOID
)lParam
);
1659 case WM_MEASUREITEM
:
1661 MEASUREITEMSTRUCT16
*mis16
;
1662 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)lParam
;
1663 lParam
= *(LPARAM
*)(mis
+ 1);
1664 mis16
= MapSL(lParam
);
1665 mis16
->itemWidth
= (UINT16
)mis
->itemWidth
;
1666 mis16
->itemHeight
= (UINT16
)mis
->itemHeight
;
1667 HeapFree( GetProcessHeap(), 0, mis
);
1670 case WM_GETMINMAXINFO
:
1672 MINMAXINFO
*mmi
= (MINMAXINFO
*)lParam
;
1673 lParam
= *(LPARAM
*)(mmi
+ 1);
1674 MINMAXINFO32to16( mmi
, MapSL(lParam
));
1675 HeapFree( GetProcessHeap(), 0, mmi
);
1680 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1681 lParam
= *(LPARAM
*)(cs
+ 1);
1682 MDICREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1683 HeapFree( GetProcessHeap(), 0, cs
);
1686 case WM_MDIGETACTIVE
:
1687 result
= MAKELONG( LOWORD(result
), (BOOL16
)(*(BOOL
*)lParam
) );
1688 HeapFree( GetProcessHeap(), 0, (BOOL
*)lParam
);
1692 NCCALCSIZE_PARAMS16
*nc16
;
1693 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lParam
;
1694 lParam
= *(LPARAM
*)(nc
+ 1);
1695 nc16
= MapSL(lParam
);
1696 nc16
->rgrc
[0].left
= nc
->rgrc
[0].left
;
1697 nc16
->rgrc
[0].top
= nc
->rgrc
[0].top
;
1698 nc16
->rgrc
[0].right
= nc
->rgrc
[0].right
;
1699 nc16
->rgrc
[0].bottom
= nc
->rgrc
[0].bottom
;
1702 nc16
->rgrc
[1].left
= nc
->rgrc
[1].left
;
1703 nc16
->rgrc
[1].top
= nc
->rgrc
[1].top
;
1704 nc16
->rgrc
[1].right
= nc
->rgrc
[1].right
;
1705 nc16
->rgrc
[1].bottom
= nc
->rgrc
[1].bottom
;
1706 nc16
->rgrc
[2].left
= nc
->rgrc
[2].left
;
1707 nc16
->rgrc
[2].top
= nc
->rgrc
[2].top
;
1708 nc16
->rgrc
[2].right
= nc
->rgrc
[2].right
;
1709 nc16
->rgrc
[2].bottom
= nc
->rgrc
[2].bottom
;
1712 WINDOWPOS32to16( nc
->lppos
, MapSL(nc16
->lppos
));
1713 HeapFree( GetProcessHeap(), 0, nc
->lppos
);
1716 HeapFree( GetProcessHeap(), 0, nc
);
1722 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
1723 lParam
= *(LPARAM
*)(cs
+ 1);
1724 CREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1726 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1727 HeapFree(GetProcessHeap(), 0, cs
->lpCreateParams
);
1729 HeapFree( GetProcessHeap(), 0, cs
);
1732 case WM_WINDOWPOSCHANGING
:
1733 case WM_WINDOWPOSCHANGED
:
1735 WINDOWPOS
*wp
= (WINDOWPOS
*)lParam
;
1736 lParam
= *(LPARAM
*)(wp
+ 1);
1737 WINDOWPOS32to16(wp
, MapSL(lParam
));
1738 HeapFree( GetProcessHeap(), 0, wp
);
1744 LPMSG msg32
= (LPMSG
)lParam
;
1746 WINPROC_UnmapMsg16To32A( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1748 HeapFree( GetProcessHeap(), 0, msg32
);
1753 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
1754 result
= MAKELONG( HMENU_16(next
->hmenuNext
), HWND_16(next
->hwndNext
) );
1755 HeapFree( GetProcessHeap(), 0, next
);
1763 /**********************************************************************
1764 * WINPROC_MapMsg16To32W
1766 * Map a message from 16- to 32-bit Unicode.
1767 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1769 INT
WINPROC_MapMsg16To32W( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1770 WPARAM
*pwparam32
, LPARAM
*plparam
)
1775 *pmsg32
=(UINT
)msg16
;
1776 *pwparam32
= (WPARAM
)wParam16
;
1781 case WM_WININICHANGE
:
1782 case WM_DEVMODECHANGE
:
1783 case WM_ASKCBFORMATNAME
:
1784 *plparam
= (LPARAM
)MapSL(*plparam
);
1785 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1786 case WM_GETTEXTLENGTH
:
1787 case CB_GETLBTEXTLEN
:
1789 return 1; /* need to map result */
1793 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1794 CREATESTRUCTW
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1796 CREATESTRUCT16to32A( cs16
, (CREATESTRUCTA
*)cs
);
1797 cs
->lpszName
= map_str_16_to_32W(cs16
->lpszName
);
1798 cs
->lpszClass
= map_str_16_to_32W(cs16
->lpszClass
);
1800 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1802 MDICREATESTRUCT16
*mdi_cs16
;
1803 MDICREATESTRUCTW
*mdi_cs
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs
));
1806 HeapFree(GetProcessHeap(), 0, cs
);
1809 mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs16
->lpCreateParams
);
1810 MDICREATESTRUCT16to32A(mdi_cs16
, (MDICREATESTRUCTA
*)mdi_cs
);
1811 mdi_cs
->szTitle
= map_str_16_to_32W(mdi_cs16
->szTitle
);
1812 mdi_cs
->szClass
= map_str_16_to_32W(mdi_cs16
->szClass
);
1814 cs
->lpCreateParams
= mdi_cs
;
1816 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1817 *plparam
= (LPARAM
)cs
;
1822 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1823 MDICREATESTRUCTW
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1825 MDICREATESTRUCT16to32A( cs16
, (MDICREATESTRUCTA
*)cs
);
1826 cs
->szTitle
= map_str_16_to_32W(cs16
->szTitle
);
1827 cs
->szClass
= map_str_16_to_32W(cs16
->szClass
);
1828 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1829 *plparam
= (LPARAM
)cs
;
1835 LPMSG16 msg16
= MapSL(*plparam
);
1836 LPMSG msg32
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1838 if (!msg32
) return -1;
1839 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1840 msg32
->lParam
= msg16
->lParam
;
1841 msg32
->time
= msg16
->time
;
1842 msg32
->pt
.x
= msg16
->pt
.x
;
1843 msg32
->pt
.y
= msg16
->pt
.y
;
1844 /* this is right, right? */
1845 if (WINPROC_MapMsg16To32W(hwnd
, msg16
->message
,msg16
->wParam
,
1846 &msg32
->message
,&msg32
->wParam
,
1847 &msg32
->lParam
)<0) {
1848 HeapFree( GetProcessHeap(), 0, msg32
);
1851 *plparam
= (LPARAM
)msg32
;
1858 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1859 *pwparam32
= MAKEWPARAM( wch
, HIWORD(*plparam
) );
1860 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1864 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1865 *pwparam32
= MAKEWPARAM( wch
, LOWORD(*plparam
) );
1866 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1871 case WM_SYSDEADCHAR
:
1873 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1877 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1879 default: /* No Unicode translation needed */
1880 return WINPROC_MapMsg16To32A( hwnd
, msg16
, wParam16
, pmsg32
,
1881 pwparam32
, plparam
);
1886 /**********************************************************************
1887 * WINPROC_UnmapMsg16To32W
1889 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1891 LRESULT
WINPROC_UnmapMsg16To32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1892 LRESULT result
, WNDPROC dispatch
)
1898 case WM_GETTEXTLENGTH
:
1899 case CB_GETLBTEXTLEN
:
1901 case WM_ASKCBFORMATNAME
:
1902 return WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
, dispatch
);
1906 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
1907 lParam
= *(LPARAM
*)(cs
+ 1);
1908 CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs
, MapSL(lParam
) );
1909 unmap_str_16_to_32W( cs
->lpszName
);
1910 unmap_str_16_to_32W( cs
->lpszClass
);
1912 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1914 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)cs
->lpCreateParams
;
1915 unmap_str_16_to_32W( mdi_cs
->szTitle
);
1916 unmap_str_16_to_32W( mdi_cs
->szClass
);
1917 HeapFree(GetProcessHeap(), 0, cs
->lpCreateParams
);
1919 HeapFree( GetProcessHeap(), 0, cs
);
1924 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
1925 lParam
= *(LPARAM
*)(cs
+ 1);
1926 MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs
, MapSL(lParam
) );
1927 unmap_str_16_to_32W( cs
->szTitle
);
1928 unmap_str_16_to_32W( cs
->szClass
);
1929 HeapFree( GetProcessHeap(), 0, cs
);
1935 LPMSG msg32
= (LPMSG
)lParam
;
1937 WINPROC_UnmapMsg16To32W( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1939 HeapFree( GetProcessHeap(), 0, msg32
);
1943 return WINPROC_UnmapMsg16To32A( hwnd
, msg
, wParam
, lParam
, result
);
1948 static HANDLE16
convert_handle_32_to_16(UINT src
, unsigned int flags
)
1951 UINT sz
= GlobalSize((HANDLE
)src
);
1954 if (!(dst
= GlobalAlloc16(flags
, sz
)))
1956 ptr32
= GlobalLock((HANDLE
)src
);
1957 ptr16
= GlobalLock16(dst
);
1958 if (ptr16
!= NULL
&& ptr32
!= NULL
) memcpy(ptr16
, ptr32
, sz
);
1959 GlobalUnlock((HANDLE
)src
);
1960 GlobalUnlock16(dst
);
1966 /**********************************************************************
1967 * WINPROC_MapMsg32ATo16
1969 * Map a message from 32-bit Ansi to 16-bit.
1970 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1972 INT
WINPROC_MapMsg32ATo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
1973 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
1976 *pmsg16
= (UINT16
)msg32
;
1977 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
1981 *pmsg16
= SBM_SETRANGE16
;
1982 *plparam
= MAKELPARAM(wParam32
, *plparam
);
1987 *pmsg16
= SBM_GETRANGE16
;
1995 *pmsg16
= (UINT16
)msg32
+ (BM_GETCHECK16
- BM_GETCHECK
);
2004 case EM_SCROLLCARET
:
2007 case EM_GETLINECOUNT
:
2019 case EM_LINEFROMCHAR
:
2020 case EM_SETTABSTOPS
:
2021 case EM_SETPASSWORDCHAR
:
2022 case EM_EMPTYUNDOBUFFER
:
2023 case EM_GETFIRSTVISIBLELINE
:
2024 case EM_SETREADONLY
:
2025 case EM_SETWORDBREAKPROC
:
2026 case EM_GETWORDBREAKPROC
:
2027 case EM_GETPASSWORDCHAR
:
2028 *pmsg16
= (UINT16
)msg32
+ (EM_GETSEL16
- EM_GETSEL
);
2033 case LB_DELETESTRING
:
2034 case LB_GETANCHORINDEX
:
2035 case LB_GETCARETINDEX
:
2038 case LB_GETHORIZONTALEXTENT
:
2039 case LB_GETITEMDATA
:
2040 case LB_GETITEMHEIGHT
:
2042 case LB_GETSELCOUNT
:
2044 case LB_GETTOPINDEX
:
2045 case LB_RESETCONTENT
:
2046 case LB_SELITEMRANGE
:
2047 case LB_SELITEMRANGEEX
:
2048 case LB_SETANCHORINDEX
:
2049 case LB_SETCARETINDEX
:
2050 case LB_SETCOLUMNWIDTH
:
2052 case LB_SETHORIZONTALEXTENT
:
2053 case LB_SETITEMDATA
:
2054 case LB_SETITEMHEIGHT
:
2056 case LB_SETTOPINDEX
:
2057 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2059 case CB_DELETESTRING
:
2061 case CB_GETLBTEXTLEN
:
2063 case CB_RESETCONTENT
:
2067 case CB_SHOWDROPDOWN
:
2068 case CB_SETITEMDATA
:
2069 case CB_SETITEMHEIGHT
:
2070 case CB_GETITEMHEIGHT
:
2071 case CB_SETEXTENDEDUI
:
2072 case CB_GETEXTENDEDUI
:
2073 case CB_GETDROPPEDSTATE
:
2074 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
2077 *pmsg16
= CB_GETEDITSEL16
;
2082 case LB_FINDSTRINGEXACT
:
2083 case LB_INSERTSTRING
:
2084 case LB_SELECTSTRING
:
2087 *plparam
= (LPARAM
)MapLS( (LPSTR
)*plparam
);
2088 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2093 case CB_FINDSTRINGEXACT
:
2094 case CB_INSERTSTRING
:
2095 case CB_SELECTSTRING
:
2097 *plparam
= (LPARAM
)MapLS( (LPSTR
)*plparam
);
2098 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
2101 case LB_GETITEMRECT
:
2103 RECT16
*rect
= HeapAlloc( GetProcessHeap(), 0, sizeof(RECT16
) + sizeof(LPARAM
) );
2104 if (!rect
) return -1;
2105 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
2106 *plparam
= MapLS( rect
);
2108 *pmsg16
= LB_GETITEMRECT16
;
2110 case LB_GETSELITEMS
:
2112 LPARAM
*items
; /* old LPARAM first, then *pwparam16 x INT16 entries */
2114 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
2115 if (!(items
= HeapAlloc( GetProcessHeap(), 0,
2116 *pwparam16
* sizeof(INT16
) + sizeof(LPARAM
)))) return -1;
2117 *items
++ = *plparam
; /* Store the previous lParam */
2118 *plparam
= MapLS( items
);
2120 *pmsg16
= LB_GETSELITEMS16
;
2122 case LB_SETTABSTOPS
:
2127 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
2128 if (!(stops
= HeapAlloc( GetProcessHeap(), 0,
2129 *pwparam16
* sizeof(INT16
) + sizeof(LPARAM
)))) return -1;
2130 for (i
= 0; i
< *pwparam16
; i
++) stops
[i
] = *((LPINT
)*plparam
+i
);
2131 *plparam
= MapLS( stops
);
2134 *pmsg16
= LB_SETTABSTOPS16
;
2137 case CB_GETDROPPEDCONTROLRECT
:
2139 RECT16
*rect
= HeapAlloc( GetProcessHeap(), 0, sizeof(RECT16
) + sizeof(LPARAM
) );
2140 if (!rect
) return -1;
2141 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
2142 *plparam
= (LPARAM
)MapLS(rect
);
2144 *pmsg16
= CB_GETDROPPEDCONTROLRECT16
;
2148 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
2149 *pmsg16
= LB_GETTEXT16
;
2153 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
2154 *pmsg16
= CB_GETLBTEXT16
;
2159 *plparam
= MAKELONG( (INT16
)(INT
)wParam32
, (INT16
)*plparam
);
2160 *pmsg16
= EM_SETSEL16
;
2167 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
2171 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HWND16
)*plparam
);
2175 PCOPYDATASTRUCT pcds32
= (PCOPYDATASTRUCT
) *plparam
;
2176 PCOPYDATASTRUCT16 pcds
= HeapAlloc( GetProcessHeap(), 0, sizeof( *pcds
));
2177 pcds
->dwData
= pcds32
->dwData
;
2178 pcds
->cbData
= pcds32
->cbData
;
2179 pcds
->lpData
= MapLS( pcds32
->lpData
);
2180 *plparam
= MapLS( pcds
);
2183 case WM_CTLCOLORMSGBOX
:
2184 case WM_CTLCOLOREDIT
:
2185 case WM_CTLCOLORLISTBOX
:
2186 case WM_CTLCOLORBTN
:
2187 case WM_CTLCOLORDLG
:
2188 case WM_CTLCOLORSCROLLBAR
:
2189 case WM_CTLCOLORSTATIC
:
2190 *pmsg16
= WM_CTLCOLOR
;
2191 *plparam
= MAKELPARAM( (HWND16
)*plparam
,
2192 (WORD
)msg32
- WM_CTLCOLORMSGBOX
);
2194 case WM_COMPAREITEM
:
2196 COMPAREITEMSTRUCT
*cis32
= (COMPAREITEMSTRUCT
*)*plparam
;
2197 COMPAREITEMSTRUCT16
*cis
= HeapAlloc( GetProcessHeap(), 0, sizeof(COMPAREITEMSTRUCT16
));
2198 if (!cis
) return -1;
2199 cis
->CtlType
= (UINT16
)cis32
->CtlType
;
2200 cis
->CtlID
= (UINT16
)cis32
->CtlID
;
2201 cis
->hwndItem
= HWND_16( cis32
->hwndItem
);
2202 cis
->itemID1
= (UINT16
)cis32
->itemID1
;
2203 cis
->itemData1
= cis32
->itemData1
;
2204 cis
->itemID2
= (UINT16
)cis32
->itemID2
;
2205 cis
->itemData2
= cis32
->itemData2
;
2206 *plparam
= MapLS( cis
);
2211 DELETEITEMSTRUCT
*dis32
= (DELETEITEMSTRUCT
*)*plparam
;
2212 DELETEITEMSTRUCT16
*dis
= HeapAlloc( GetProcessHeap(), 0, sizeof(DELETEITEMSTRUCT16
) );
2213 if (!dis
) return -1;
2214 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
2215 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
2216 dis
->itemID
= (UINT16
)dis32
->itemID
;
2217 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND16
)LOWORD(dis32
->hwndItem
)
2218 : HWND_16( dis32
->hwndItem
);
2219 dis
->itemData
= dis32
->itemData
;
2220 *plparam
= MapLS( dis
);
2225 DRAWITEMSTRUCT
*dis32
= (DRAWITEMSTRUCT
*)*plparam
;
2226 DRAWITEMSTRUCT16
*dis
= HeapAlloc( GetProcessHeap(), 0, sizeof(DRAWITEMSTRUCT16
) );
2227 if (!dis
) return -1;
2228 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
2229 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
2230 dis
->itemID
= (UINT16
)dis32
->itemID
;
2231 dis
->itemAction
= (UINT16
)dis32
->itemAction
;
2232 dis
->itemState
= (UINT16
)dis32
->itemState
;
2233 dis
->hwndItem
= HWND_16( dis32
->hwndItem
);
2234 dis
->hDC
= HDC_16(dis32
->hDC
);
2235 dis
->itemData
= dis32
->itemData
;
2236 dis
->rcItem
.left
= dis32
->rcItem
.left
;
2237 dis
->rcItem
.top
= dis32
->rcItem
.top
;
2238 dis
->rcItem
.right
= dis32
->rcItem
.right
;
2239 dis
->rcItem
.bottom
= dis32
->rcItem
.bottom
;
2240 *plparam
= MapLS( dis
);
2243 case WM_MEASUREITEM
:
2245 MEASUREITEMSTRUCT
*mis32
= (MEASUREITEMSTRUCT
*)*plparam
;
2246 MEASUREITEMSTRUCT16
*mis
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mis
)+sizeof(LPARAM
));
2247 if (!mis
) return -1;
2248 mis
->CtlType
= (UINT16
)mis32
->CtlType
;
2249 mis
->CtlID
= (UINT16
)mis32
->CtlID
;
2250 mis
->itemID
= (UINT16
)mis32
->itemID
;
2251 mis
->itemWidth
= (UINT16
)mis32
->itemWidth
;
2252 mis
->itemHeight
= (UINT16
)mis32
->itemHeight
;
2253 mis
->itemData
= mis32
->itemData
;
2254 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
2255 *plparam
= MapLS( mis
);
2258 case WM_GETMINMAXINFO
:
2260 MINMAXINFO16
*mmi
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mmi
) + sizeof(LPARAM
) );
2261 if (!mmi
) return -1;
2262 MINMAXINFO32to16( (MINMAXINFO
*)*plparam
, mmi
);
2263 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
2264 *plparam
= MapLS( mmi
);
2268 case WM_ASKCBFORMATNAME
:
2270 LPARAM
*str
; /* store LPARAM, then *pwparam16 char space */
2271 *pwparam16
= (WPARAM16
)min( wParam32
, 0xff80 ); /* Must be < 64K */
2272 if (!(str
= HeapAlloc( GetProcessHeap(), 0, *pwparam16
+ sizeof(LPARAM
)))) return -1;
2273 *str
++ = *plparam
; /* Store the previous lParam */
2274 *plparam
= MapLS( str
);
2279 MDICREATESTRUCT16
*cs
;
2280 MDICREATESTRUCTA
*cs32
= (MDICREATESTRUCTA
*)*plparam
;
2282 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16
) ))) return -1;
2283 MDICREATESTRUCT32Ato16( cs32
, cs
);
2284 cs
->szTitle
= MapLS( cs32
->szTitle
);
2285 cs
->szClass
= MapLS( cs32
->szClass
);
2286 *plparam
= MapLS( cs
);
2289 case WM_MDIGETACTIVE
:
2292 *plparam
= MAKELPARAM( (HMENU16
)LOWORD(wParam32
),
2293 (HMENU16
)LOWORD(*plparam
) );
2294 *pwparam16
= (*plparam
== 0);
2297 if(HIWORD(wParam32
) & MF_POPUP
)
2300 if (((UINT
)HIWORD(wParam32
) != 0xFFFF) || (*plparam
))
2302 if((hmenu
= GetSubMenu((HMENU
)*plparam
, *pwparam16
)))
2303 *pwparam16
=HMENU_16(hmenu
);
2308 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2310 case WM_MDIACTIVATE
:
2311 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2313 *pwparam16
= ((HWND
)*plparam
== hwnd
);
2314 *plparam
= MAKELPARAM( (HWND16
)LOWORD(*plparam
),
2315 (HWND16
)LOWORD(wParam32
) );
2319 *pwparam16
= HWND_16( (HWND
)wParam32
);
2325 NCCALCSIZE_PARAMS
*nc32
= (NCCALCSIZE_PARAMS
*)*plparam
;
2326 NCCALCSIZE_PARAMS16
*nc
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
) + sizeof(LPARAM
));
2329 nc
->rgrc
[0].left
= nc32
->rgrc
[0].left
;
2330 nc
->rgrc
[0].top
= nc32
->rgrc
[0].top
;
2331 nc
->rgrc
[0].right
= nc32
->rgrc
[0].right
;
2332 nc
->rgrc
[0].bottom
= nc32
->rgrc
[0].bottom
;
2336 nc
->rgrc
[1].left
= nc32
->rgrc
[1].left
;
2337 nc
->rgrc
[1].top
= nc32
->rgrc
[1].top
;
2338 nc
->rgrc
[1].right
= nc32
->rgrc
[1].right
;
2339 nc
->rgrc
[1].bottom
= nc32
->rgrc
[1].bottom
;
2340 nc
->rgrc
[2].left
= nc32
->rgrc
[2].left
;
2341 nc
->rgrc
[2].top
= nc32
->rgrc
[2].top
;
2342 nc
->rgrc
[2].right
= nc32
->rgrc
[2].right
;
2343 nc
->rgrc
[2].bottom
= nc32
->rgrc
[2].bottom
;
2344 if (!(wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(WINDOWPOS16
) )))
2346 HeapFree( GetProcessHeap(), 0, nc
);
2349 WINDOWPOS32to16( nc32
->lppos
, wp
);
2350 nc
->lppos
= MapLS( wp
);
2352 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
2353 *plparam
= MapLS( nc
);
2360 CREATESTRUCTA
*cs32
= (CREATESTRUCTA
*)*plparam
;
2362 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16
) ))) return -1;
2363 CREATESTRUCT32Ato16( cs32
, cs
);
2364 cs
->lpszName
= MapLS( cs32
->lpszName
);
2365 cs
->lpszClass
= MapLS( cs32
->lpszClass
);
2367 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2369 MDICREATESTRUCT16
*mdi_cs16
;
2370 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)cs32
->lpCreateParams
;
2371 mdi_cs16
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs16
));
2374 HeapFree(GetProcessHeap(), 0, cs
);
2377 MDICREATESTRUCT32Ato16(mdi_cs
, mdi_cs16
);
2378 mdi_cs16
->szTitle
= MapLS( mdi_cs
->szTitle
);
2379 mdi_cs16
->szClass
= MapLS( mdi_cs
->szClass
);
2380 cs
->lpCreateParams
= MapLS( mdi_cs16
);
2382 *plparam
= MapLS( cs
);
2385 case WM_PARENTNOTIFY
:
2386 if ((LOWORD(wParam32
)==WM_CREATE
) || (LOWORD(wParam32
)==WM_DESTROY
))
2387 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
));
2388 /* else nothing to do */
2391 *plparam
= MapLS( (NMHDR
*)*plparam
); /* NMHDR is already 32-bit */
2394 case WM_WININICHANGE
:
2395 case WM_DEVMODECHANGE
:
2396 *plparam
= MapLS( (LPSTR
)*plparam
);
2398 case WM_WINDOWPOSCHANGING
:
2399 case WM_WINDOWPOSCHANGED
:
2401 WINDOWPOS16
*wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*wp
) + sizeof(LPARAM
) );
2403 WINDOWPOS32to16( (WINDOWPOS
*)*plparam
, wp
);
2404 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
2405 *plparam
= MapLS( wp
);
2410 LPMSG msg32
= (LPMSG
) *plparam
;
2411 LPMSG16 msg16
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG16
) );
2413 if (!msg16
) return -1;
2414 msg16
->hwnd
= HWND_16( msg32
->hwnd
);
2415 msg16
->lParam
= msg32
->lParam
;
2416 msg16
->time
= msg32
->time
;
2417 msg16
->pt
.x
= msg32
->pt
.x
;
2418 msg16
->pt
.y
= msg32
->pt
.y
;
2419 /* this is right, right? */
2420 if (WINPROC_MapMsg32ATo16(msg32
->hwnd
,msg32
->message
,msg32
->wParam
,
2421 &msg16
->message
,&msg16
->wParam
, &msg16
->lParam
)<0)
2423 HeapFree( GetProcessHeap(), 0, msg16
);
2426 *plparam
= MapLS( msg16
);
2431 case WM_ACTIVATEAPP
:
2432 if (*plparam
) *plparam
= HTASK_16( (HANDLE
)*plparam
);
2436 MDINEXTMENU
*next
= (MDINEXTMENU
*)*plparam
;
2437 *plparam
= (LPARAM
)next
->hmenuIn
;
2441 if (IsIconic( hwnd
) && GetClassLongPtrW( hwnd
, GCLP_HICON
))
2443 *pmsg16
= WM_PAINTICON
;
2448 if (IsIconic( hwnd
) && GetClassLongPtrW( hwnd
, GCLP_HICON
))
2449 *pmsg16
= WM_ICONERASEBKGND
;
2451 case WM_PAINTCLIPBOARD
:
2452 case WM_SIZECLIPBOARD
:
2453 FIXME_(msg
)("message %04x needs translation\n", msg32
);
2455 /* following messages should not be sent to 16-bit apps */
2458 case WM_CAPTURECHANGED
:
2459 case WM_STYLECHANGING
:
2460 case WM_STYLECHANGED
:
2462 case WM_DDE_INITIATE
:
2463 case WM_DDE_TERMINATE
:
2464 case WM_DDE_UNADVISE
:
2465 case WM_DDE_REQUEST
:
2466 *pwparam16
= HWND_16((HWND
)wParam32
);
2475 *pwparam16
= HWND_16((HWND
)wParam32
);
2476 UnpackDDElParam(msg32
, *plparam
, &lo32
, &hi
);
2477 if (lo32
&& !(lo16
= convert_handle_32_to_16(lo32
, GMEM_DDESHARE
)))
2479 *plparam
= MAKELPARAM(lo16
, hi
);
2481 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2488 *pwparam16
= HWND_16((HWND
)wParam32
);
2490 UnpackDDElParam(msg32
, *plparam
, &lo
, &hi
);
2492 if (GlobalGetAtomNameA((ATOM
)hi
, buf
, sizeof(buf
)) > 0) flag
|= 1;
2493 if (GlobalSize((HANDLE
)hi
) != 0) flag
|= 2;
2499 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
2504 break; /* atom, nothing to do */
2506 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi
);
2509 hi
= convert_handle_32_to_16(hi
, GMEM_DDESHARE
);
2512 *plparam
= MAKELPARAM(lo
, hi
);
2514 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2515 case WM_DDE_EXECUTE
:
2516 *plparam
= convert_handle_32_to_16(*plparam
, GMEM_DDESHARE
);
2517 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2518 default: /* No translation needed */
2524 /**********************************************************************
2525 * WINPROC_UnmapMsg32ATo16
2527 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
2529 void WINPROC_UnmapMsg32ATo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2535 *(LPINT
)wParam
= LOWORD(p16
->lResult
);
2536 *(LPINT
)lParam
= HIWORD(p16
->lResult
);
2543 case LB_FINDSTRINGEXACT
:
2544 case LB_INSERTSTRING
:
2545 case LB_SELECTSTRING
:
2549 case CB_FINDSTRINGEXACT
:
2550 case CB_INSERTSTRING
:
2551 case CB_SELECTSTRING
:
2555 case WM_WININICHANGE
:
2556 case WM_DEVMODECHANGE
:
2557 UnMapLS( (SEGPTR
)p16
->lParam
);
2559 case LB_SETTABSTOPS
:
2560 case WM_COMPAREITEM
:
2564 void *ptr
= MapSL( p16
->lParam
);
2565 UnMapLS( p16
->lParam
);
2566 HeapFree( GetProcessHeap(), 0, ptr
);
2571 PCOPYDATASTRUCT16 pcds
= MapSL( p16
->lParam
);
2572 UnMapLS( p16
->lParam
);
2573 UnMapLS( pcds
->lpData
);
2574 HeapFree( GetProcessHeap(), 0, pcds
);
2577 case CB_GETDROPPEDCONTROLRECT
:
2578 case LB_GETITEMRECT
:
2581 RECT16
*rect
= MapSL(p16
->lParam
);
2582 UnMapLS( p16
->lParam
);
2583 p16
->lParam
= *(LPARAM
*)(rect
+ 1);
2584 r32
= (RECT
*)p16
->lParam
;
2585 r32
->left
= rect
->left
;
2586 r32
->top
= rect
->top
;
2587 r32
->right
= rect
->right
;
2588 r32
->bottom
= rect
->bottom
;
2589 HeapFree( GetProcessHeap(), 0, rect
);
2592 case LB_GETSELITEMS
:
2595 LPINT16 items
= MapSL(p16
->lParam
);
2596 UnMapLS( p16
->lParam
);
2597 p16
->lParam
= *((LPARAM
*)items
- 1);
2598 for (i
= 0; i
< p16
->wParam
; i
++) *((LPINT
)(p16
->lParam
) + i
) = items
[i
];
2599 HeapFree( GetProcessHeap(), 0, (LPARAM
*)items
- 1 );
2605 *((PUINT
)(wParam
)) = LOWORD(p16
->lResult
);
2607 *((PUINT
)(lParam
)) = HIWORD(p16
->lResult
); /* FIXME: substract 1? */
2610 case WM_MEASUREITEM
:
2612 MEASUREITEMSTRUCT16
*mis
= MapSL(p16
->lParam
);
2613 MEASUREITEMSTRUCT
*mis32
= *(MEASUREITEMSTRUCT
**)(mis
+ 1);
2614 mis32
->itemWidth
= mis
->itemWidth
;
2615 mis32
->itemHeight
= mis
->itemHeight
;
2616 UnMapLS( p16
->lParam
);
2617 HeapFree( GetProcessHeap(), 0, mis
);
2620 case WM_GETMINMAXINFO
:
2622 MINMAXINFO16
*mmi
= MapSL(p16
->lParam
);
2623 UnMapLS( p16
->lParam
);
2624 p16
->lParam
= *(LPARAM
*)(mmi
+ 1);
2625 MINMAXINFO16to32( mmi
, (MINMAXINFO
*)(p16
->lParam
) );
2626 HeapFree( GetProcessHeap(), 0, mmi
);
2630 case WM_ASKCBFORMATNAME
:
2632 LPSTR str
= MapSL(p16
->lParam
);
2633 UnMapLS( p16
->lParam
);
2634 p16
->lParam
= *((LPARAM
*)str
- 1);
2635 lstrcpynA( (LPSTR
)(p16
->lParam
), str
, p16
->wParam
);
2636 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
- 1 );
2641 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2642 UnMapLS( cs
->szTitle
);
2643 UnMapLS( cs
->szClass
);
2644 UnMapLS( p16
->lParam
);
2645 HeapFree( GetProcessHeap(), 0, cs
);
2648 case WM_MDIGETACTIVE
:
2649 if (lParam
) *(BOOL
*)lParam
= (BOOL16
)HIWORD(p16
->lResult
);
2650 p16
->lResult
= (LRESULT
)WIN_Handle32( LOWORD(p16
->lResult
) );
2654 NCCALCSIZE_PARAMS
*nc32
;
2655 NCCALCSIZE_PARAMS16
*nc
= MapSL(p16
->lParam
);
2656 UnMapLS( p16
->lParam
);
2657 p16
->lParam
= *(LPARAM
*)(nc
+ 1);
2658 nc32
= (NCCALCSIZE_PARAMS
*)(p16
->lParam
);
2659 nc32
->rgrc
[0].left
= nc
->rgrc
[0].left
;
2660 nc32
->rgrc
[0].top
= nc
->rgrc
[0].top
;
2661 nc32
->rgrc
[0].right
= nc
->rgrc
[0].right
;
2662 nc32
->rgrc
[0].bottom
= nc
->rgrc
[0].bottom
;
2665 WINDOWPOS16
*pos
= MapSL(nc
->lppos
);
2666 UnMapLS( nc
->lppos
);
2667 nc32
->rgrc
[1].left
= nc
->rgrc
[1].left
;
2668 nc32
->rgrc
[1].top
= nc
->rgrc
[1].top
;
2669 nc32
->rgrc
[1].right
= nc
->rgrc
[1].right
;
2670 nc32
->rgrc
[1].bottom
= nc
->rgrc
[1].bottom
;
2671 nc32
->rgrc
[2].left
= nc
->rgrc
[2].left
;
2672 nc32
->rgrc
[2].top
= nc
->rgrc
[2].top
;
2673 nc32
->rgrc
[2].right
= nc
->rgrc
[2].right
;
2674 nc32
->rgrc
[2].bottom
= nc
->rgrc
[2].bottom
;
2675 WINDOWPOS16to32( pos
, nc32
->lppos
);
2676 HeapFree( GetProcessHeap(), 0, pos
);
2678 HeapFree( GetProcessHeap(), 0, nc
);
2684 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2685 UnMapLS( p16
->lParam
);
2686 UnMapLS( cs
->lpszName
);
2687 UnMapLS( cs
->lpszClass
);
2688 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2690 MDICREATESTRUCT16
*mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs
->lpCreateParams
);
2691 UnMapLS( cs
->lpCreateParams
);
2692 UnMapLS( mdi_cs16
->szTitle
);
2693 UnMapLS( mdi_cs16
->szClass
);
2694 HeapFree(GetProcessHeap(), 0, mdi_cs16
);
2696 HeapFree( GetProcessHeap(), 0, cs
);
2699 case WM_WINDOWPOSCHANGING
:
2700 case WM_WINDOWPOSCHANGED
:
2702 WINDOWPOS16
*wp
= MapSL(p16
->lParam
);
2703 UnMapLS( p16
->lParam
);
2704 p16
->lParam
= *(LPARAM
*)(wp
+ 1);
2705 WINDOWPOS16to32( wp
, (WINDOWPOS
*)p16
->lParam
);
2706 HeapFree( GetProcessHeap(), 0, wp
);
2710 UnMapLS(p16
->lParam
);
2715 LPMSG16 msg16
= MapSL(p16
->lParam
);
2717 UnMapLS( p16
->lParam
);
2718 msgp16
.wParam
=msg16
->wParam
;
2719 msgp16
.lParam
=msg16
->lParam
;
2720 WINPROC_UnmapMsg32ATo16(((LPMSG
)lParam
)->hwnd
, ((LPMSG
)lParam
)->message
,
2721 ((LPMSG
)lParam
)->wParam
, ((LPMSG
)lParam
)->lParam
,
2723 HeapFree( GetProcessHeap(), 0, msg16
);
2728 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
2729 next
->hmenuNext
= HMENU_32( LOWORD(p16
->lResult
) );
2730 next
->hwndNext
= WIN_Handle32( HIWORD(p16
->lResult
) );
2738 /**********************************************************************
2739 * WINPROC_MapMsg32WTo16
2741 * Map a message from 32-bit Unicode to 16-bit.
2742 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
2744 INT
WINPROC_MapMsg32WTo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
2745 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
2751 *pmsg16
= LOWORD(msg32
);
2752 *pwparam16
= LOWORD(wParam32
);
2757 case LB_FINDSTRINGEXACT
:
2758 case LB_INSERTSTRING
:
2759 case LB_SELECTSTRING
:
2762 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2763 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2768 case CB_FINDSTRINGEXACT
:
2769 case CB_INSERTSTRING
:
2770 case CB_SELECTSTRING
:
2772 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2773 *pmsg16
= (UINT16
)msg32
+ (CB_ADDSTRING16
- CB_ADDSTRING
);
2780 CREATESTRUCTW
*cs32
= (CREATESTRUCTW
*)*plparam
;
2782 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16
) ))) return -1;
2783 CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs32
, cs
);
2784 cs
->lpszName
= map_str_32W_to_16( cs32
->lpszName
);
2785 cs
->lpszClass
= map_str_32W_to_16( cs32
->lpszClass
);
2787 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2789 MDICREATESTRUCT16
*mdi_cs16
;
2790 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)cs32
->lpCreateParams
;
2791 mdi_cs16
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs16
));
2794 HeapFree(GetProcessHeap(), 0, cs
);
2797 MDICREATESTRUCT32Ato16((MDICREATESTRUCTA
*)mdi_cs
, mdi_cs16
);
2798 mdi_cs16
->szTitle
= map_str_32W_to_16(mdi_cs
->szTitle
);
2799 mdi_cs16
->szClass
= map_str_32W_to_16(mdi_cs
->szClass
);
2800 cs
->lpCreateParams
= MapLS(mdi_cs16
);
2802 *plparam
= MapLS(cs
);
2807 MDICREATESTRUCT16
*cs
;
2808 MDICREATESTRUCTW
*cs32
= (MDICREATESTRUCTW
*)*plparam
;
2810 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16
) ))) return -1;
2811 MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs32
, cs
);
2812 cs
->szTitle
= map_str_32W_to_16( cs32
->szTitle
);
2813 cs
->szClass
= map_str_32W_to_16( cs32
->szClass
);
2814 *plparam
= MapLS(cs
);
2818 case WM_WININICHANGE
:
2819 case WM_DEVMODECHANGE
:
2820 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2823 if ( WINPROC_TestLBForStr( hwnd
))
2825 LPSTR str
= HeapAlloc( GetProcessHeap(), 0, 512 ); /* FIXME: fixed sized buffer */
2826 if (!str
) return -1;
2827 *pmsg16
= LB_GETTEXT16
;
2828 *plparam
= (LPARAM
)MapLS(str
);
2832 if ( WINPROC_TestCBForStr( hwnd
))
2834 LPSTR str
= HeapAlloc( GetProcessHeap(), 0, 512 ); /* FIXME: fixed sized buffer */
2835 if (!str
) return -1;
2836 *pmsg16
= CB_GETLBTEXT16
;
2837 *plparam
= (LPARAM
)MapLS(str
);
2842 wch
= LOWORD(wParam32
);
2843 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2845 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
2848 wch
= LOWORD(wParam32
);
2849 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2851 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2856 case WM_SYSDEADCHAR
:
2858 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2866 if (WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)ch
, 2, NULL
, NULL
) == 2)
2867 *pwparam16
= (ch
[0] << 8) | ch
[1];
2873 default: /* No Unicode translation needed (?) */
2874 return WINPROC_MapMsg32ATo16( hwnd
, msg32
, wParam32
, pmsg16
,
2875 pwparam16
, plparam
);
2880 /**********************************************************************
2881 * WINPROC_UnmapMsg32WTo16
2883 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2885 void WINPROC_UnmapMsg32WTo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2892 case LB_FINDSTRINGEXACT
:
2893 case LB_INSERTSTRING
:
2894 case LB_SELECTSTRING
:
2899 case CB_FINDSTRINGEXACT
:
2900 case CB_INSERTSTRING
:
2901 case CB_SELECTSTRING
:
2904 case WM_WININICHANGE
:
2905 case WM_DEVMODECHANGE
:
2906 unmap_str_32W_to_16( p16
->lParam
);
2911 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2912 UnMapLS( p16
->lParam
);
2913 unmap_str_32W_to_16( cs
->lpszName
);
2914 unmap_str_32W_to_16( cs
->lpszClass
);
2916 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2918 MDICREATESTRUCT16
*mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs
->lpCreateParams
);
2919 UnMapLS( cs
->lpCreateParams
);
2920 unmap_str_32W_to_16(mdi_cs16
->szTitle
);
2921 unmap_str_32W_to_16(mdi_cs16
->szClass
);
2922 HeapFree(GetProcessHeap(), 0, mdi_cs16
);
2924 HeapFree( GetProcessHeap(), 0, cs
);
2929 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2930 UnMapLS( p16
->lParam
);
2931 unmap_str_32W_to_16( cs
->szTitle
);
2932 unmap_str_32W_to_16( cs
->szClass
);
2933 HeapFree( GetProcessHeap(), 0, cs
);
2937 case WM_ASKCBFORMATNAME
:
2939 LPSTR str
= MapSL(p16
->lParam
);
2940 UnMapLS( p16
->lParam
);
2941 p16
->lParam
= *((LPARAM
*)str
- 1);
2942 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)p16
->lParam
, 0x7fffffff );
2943 p16
->lResult
= strlenW( (LPWSTR
)p16
->lParam
);
2944 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
- 1 );
2948 if ( WINPROC_TestLBForStr( hwnd
))
2950 LPSTR str
= MapSL(p16
->lParam
);
2951 UnMapLS( p16
->lParam
);
2952 p16
->lResult
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff ) - 1;
2953 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
);
2957 if ( WINPROC_TestCBForStr( hwnd
))
2959 LPSTR str
= MapSL(p16
->lParam
);
2960 UnMapLS( p16
->lParam
);
2961 p16
->lResult
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff ) - 1;
2962 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
);
2966 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, p16
);
2972 /**********************************************************************
2973 * WINPROC_CallProc32ATo32W
2975 * Call a window procedure, translating args from Ansi to Unicode.
2977 static LRESULT
WINPROC_CallProc32ATo32W( WNDPROC func
, HWND hwnd
,
2978 UINT msg
, WPARAM wParam
,
2984 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2985 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2987 if( (unmap
= WINPROC_MapMsg32ATo32W( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
2988 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
2989 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2992 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2993 if (unmap
) result
= WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
, func
);
2998 /**********************************************************************
2999 * WINPROC_CallProc32WTo32A_fast
3002 static BOOL
WINPROC_CallProc32WTo32A_fast( WNDPROC func
, HWND hwnd
,
3003 UINT msg
, WPARAM wParam
,
3004 LPARAM lParam
, LRESULT
*result
)
3010 { /* csW->lpszName and csW->lpszClass are NOT supposed to be atoms
3014 char *cls
= buffer
, *name
;
3015 CREATESTRUCTW
*csW
= (CREATESTRUCTW
*)lParam
;
3016 CREATESTRUCTA csA
= *(CREATESTRUCTA
*)csW
;
3017 DWORD name_lenA
, name_lenW
, class_lenA
, class_lenW
;
3019 class_lenW
= strlenW(csW
->lpszClass
) * sizeof(WCHAR
);
3020 RtlUnicodeToMultiByteSize(&class_lenA
, csW
->lpszClass
, class_lenW
);
3024 name_lenW
= strlenW(csW
->lpszName
) * sizeof(WCHAR
);
3025 RtlUnicodeToMultiByteSize(&name_lenA
, csW
->lpszName
, name_lenW
);
3028 name_lenW
= name_lenA
= 0;
3030 if (class_lenA
+ name_lenA
+ 2 > sizeof(buffer
))
3032 cls
= HeapAlloc(GetProcessHeap(), 0, class_lenA
+ name_lenA
+ 2);
3033 if (!cls
) return FALSE
;
3036 RtlUnicodeToMultiByteN(cls
, class_lenA
, NULL
, csW
->lpszClass
, class_lenW
);
3037 cls
[class_lenA
] = 0;
3038 csA
.lpszClass
= cls
;
3042 name
= cls
+ class_lenA
+ 1;
3043 RtlUnicodeToMultiByteN(name
, name_lenA
, NULL
, csW
->lpszName
, name_lenW
);
3044 name
[name_lenA
] = 0;
3045 csA
.lpszName
= name
;
3048 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
3050 MDICREATESTRUCTA mdi_cs
;
3052 mdi_cs
= *(MDICREATESTRUCTA
*)csW
->lpCreateParams
;
3053 mdi_cs
.szTitle
= csA
.lpszName
;
3054 mdi_cs
.szClass
= csA
.lpszClass
;
3055 csA
.lpCreateParams
= &mdi_cs
;
3058 lParam
= (LPARAM
)&csA
;
3059 *result
= WINPROC_CallWndProc(func
, hwnd
, msg
, wParam
, lParam
);
3061 if (cls
!= buffer
) HeapFree(GetProcessHeap(), 0, cls
);
3070 /**********************************************************************
3071 * WINPROC_CallProc32WTo32A
3073 * Call a window procedure, translating args from Unicode to Ansi.
3075 static LRESULT
WINPROC_CallProc32WTo32A( WNDPROC func
, HWND hwnd
,
3076 UINT msg
, WPARAM wParam
,
3082 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3083 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3085 if (WINPROC_CallProc32WTo32A_fast( func
, hwnd
, msg
, wParam
, lParam
, &result
))
3088 if ((unmap
= WINPROC_MapMsg32WTo32A( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
3089 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
3090 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3093 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3094 if( unmap
) result
= WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
, result
);
3099 /**********************************************************************
3100 * __wine_call_wndproc_32A (USER.1010)
3102 LRESULT WINAPI
__wine_call_wndproc_32A( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
,
3108 HWND hwnd32
= WIN_Handle32( hwnd
);
3110 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3111 func
, hwnd32
, SPY_GetMsgName(msg
, hwnd32
), wParam
, lParam
);
3113 if (WINPROC_MapMsg16To32A( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
3115 result
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
3116 return WINPROC_UnmapMsg16To32A( hwnd32
, msg32
, wParam32
, lParam
, result
);
3120 /**********************************************************************
3121 * __wine_call_wndproc_32W (USER.1011)
3123 LRESULT WINAPI
__wine_call_wndproc_32W( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
,
3129 HWND hwnd32
= WIN_Handle32( hwnd
);
3131 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3132 func
, hwnd32
, SPY_GetMsgName(msg
, hwnd32
), wParam
, lParam
);
3134 if (WINPROC_MapMsg16To32W( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
3136 result
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
3137 return WINPROC_UnmapMsg16To32W( hwnd32
, msg32
, wParam32
, lParam
, result
,
3142 /**********************************************************************
3143 * WINPROC_CallProc32ATo16
3145 * Call a 16-bit window procedure, translating the 32-bit args.
3147 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
3148 UINT msg
, WPARAM wParam
,
3154 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3155 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3157 mp16
.lParam
= lParam
;
3158 if (WINPROC_MapMsg32ATo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
3160 mp16
.lResult
= WINPROC_CallWndProc16( func
, HWND_16(hwnd
), msg16
,
3161 mp16
.wParam
, mp16
.lParam
);
3162 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3163 return mp16
.lResult
;
3167 /**********************************************************************
3168 * WINPROC_CallProc32WTo16
3170 * Call a 16-bit window procedure, translating the 32-bit args.
3172 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
3173 UINT msg
, WPARAM wParam
,
3179 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3180 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3182 mp16
.lParam
= lParam
;
3183 if (WINPROC_MapMsg32WTo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
,
3184 &mp16
.lParam
) == -1)
3186 mp16
.lResult
= WINPROC_CallWndProc16( func
, HWND_16(hwnd
), msg16
,
3187 mp16
.wParam
, mp16
.lParam
);
3188 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3189 return mp16
.lResult
;
3193 /**********************************************************************
3194 * CallWindowProc (USER.122)
3196 LRESULT WINAPI
CallWindowProc16( WNDPROC16 func
, HWND16 hwnd
, UINT16 msg
,
3197 WPARAM16 wParam
, LPARAM lParam
)
3201 if (!func
) return 0;
3203 if (!(proc
= WINPROC_GetPtr( (WNDPROC
)func
)))
3204 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
3207 func
= WINPROC_GetProc( (WNDPROC
)proc
, WIN_PROC_16
);
3208 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
3214 if (!proc
->thunk
.t_from32
.proc
) return 0;
3215 return WINPROC_CallWndProc16( proc
->thunk
.t_from32
.proc
,
3216 hwnd
, msg
, wParam
, lParam
);
3218 if (!proc
->thunk
.t_from16
.proc
) return 0;
3219 return __wine_call_wndproc_32A( hwnd
, msg
, wParam
, lParam
, proc
->thunk
.t_from16
.proc
);
3221 if (!proc
->thunk
.t_from16
.proc
) return 0;
3222 return __wine_call_wndproc_32W( hwnd
, msg
, wParam
, lParam
, proc
->thunk
.t_from16
.proc
);
3224 WARN_(relay
)("Invalid proc %p\n", proc
);
3230 /**********************************************************************
3231 * CallWindowProcA (USER32.@)
3233 * The CallWindowProc() function invokes the windows procedure _func_,
3234 * with _hwnd_ as the target window, the message specified by _msg_, and
3235 * the message parameters _wParam_ and _lParam_.
3237 * Some kinds of argument conversion may be done, I'm not sure what.
3239 * CallWindowProc() may be used for windows subclassing. Use
3240 * SetWindowLong() to set a new windows procedure for windows of the
3241 * subclass, and handle subclassed messages in the new windows
3242 * procedure. The new windows procedure may then use CallWindowProc()
3243 * with _func_ set to the parent class's windows procedure to dispatch
3244 * the message to the superclass.
3248 * The return value is message dependent.
3254 LRESULT WINAPI
CallWindowProcA(
3255 WNDPROC func
, /* [in] window procedure */
3256 HWND hwnd
, /* [in] target window */
3257 UINT msg
, /* [in] message */
3258 WPARAM wParam
, /* [in] message dependent parameter */
3259 LPARAM lParam
/* [in] message dependent parameter */
3263 if (!func
) return 0;
3265 if (!(proc
= WINPROC_GetPtr( func
)))
3266 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3269 func
= WINPROC_GetProc( (WNDPROC
)proc
, WIN_PROC_32A
);
3270 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3276 if (!proc
->thunk
.t_from32
.proc
) return 0;
3277 return WINPROC_CallProc32ATo16( proc
->thunk
.t_from32
.proc
,
3278 hwnd
, msg
, wParam
, lParam
);
3280 if (!proc
->thunk
.t_from16
.proc
) return 0;
3281 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
3282 hwnd
, msg
, wParam
, lParam
);
3284 if (!proc
->thunk
.t_from16
.proc
) return 0;
3285 return WINPROC_CallProc32ATo32W( proc
->thunk
.t_from16
.proc
,
3286 hwnd
, msg
, wParam
, lParam
);
3288 WARN_(relay
)("Invalid proc %p\n", proc
);
3294 /**********************************************************************
3295 * CallWindowProcW (USER32.@)
3297 * See CallWindowProcA.
3299 LRESULT WINAPI
CallWindowProcW( WNDPROC func
, HWND hwnd
, UINT msg
,
3300 WPARAM wParam
, LPARAM lParam
)
3304 if (!func
) return 0;
3306 if (!(proc
= WINPROC_GetPtr( (WNDPROC
)func
)))
3307 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3310 func
= WINPROC_GetProc( (WNDPROC
)proc
, WIN_PROC_32W
);
3311 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3317 if (!proc
->thunk
.t_from32
.proc
) return 0;
3318 return WINPROC_CallProc32WTo16( proc
->thunk
.t_from32
.proc
,
3319 hwnd
, msg
, wParam
, lParam
);
3321 if (!proc
->thunk
.t_from16
.proc
) return 0;
3322 return WINPROC_CallProc32WTo32A( proc
->thunk
.t_from16
.proc
,
3323 hwnd
, msg
, wParam
, lParam
);
3325 if (!proc
->thunk
.t_from16
.proc
) return 0;
3326 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
3327 hwnd
, msg
, wParam
, lParam
);
3329 WARN_(relay
)("Invalid proc %p\n", proc
);