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"
33 #include "wine/winbase16.h"
34 #include "wine/winuser16.h"
38 #include "user_private.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
44 WINE_DECLARE_DEBUG_CHANNEL(msg
);
45 WINE_DECLARE_DEBUG_CHANNEL(relay
);
46 WINE_DEFAULT_DEBUG_CHANNEL(win
);
48 typedef struct tagWINDOWPROC
50 WNDPROC16 proc16
; /* 16-bit window proc */
51 WNDPROC procA
; /* ASCII window proc */
52 WNDPROC procW
; /* Unicode window proc */
55 #define WINPROC_HANDLE (~0UL >> 16)
56 #define MAX_WINPROCS 8192
58 static WINDOWPROC winproc_array
[MAX_WINPROCS
];
59 static UINT winproc_used
;
61 static CRITICAL_SECTION winproc_cs
;
62 static CRITICAL_SECTION_DEBUG critsect_debug
=
65 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
66 0, 0, { (DWORD_PTR
)(__FILE__
": winproc_cs") }
68 static CRITICAL_SECTION winproc_cs
= { &critsect_debug
, -1, 0, 0, 0, 0 };
70 /* find an existing winproc for a given 16-bit function and type */
71 /* FIXME: probably should do something more clever than a linear search */
72 static inline WINDOWPROC
*find_winproc16( WNDPROC16 func
)
76 for (i
= 0; i
< winproc_used
; i
++)
78 if (winproc_array
[i
].proc16
== func
) return &winproc_array
[i
];
83 /* find an existing winproc for a given function and type */
84 /* FIXME: probably should do something more clever than a linear search */
85 static inline WINDOWPROC
*find_winproc( WNDPROC funcA
, WNDPROC funcW
)
89 for (i
= 0; i
< winproc_used
; i
++)
91 if (funcA
&& winproc_array
[i
].procA
!= funcA
) continue;
92 if (funcW
&& winproc_array
[i
].procW
!= funcW
) continue;
93 return &winproc_array
[i
];
98 /* return the window proc for a given handle, or NULL for an invalid handle */
99 static inline WINDOWPROC
*handle_to_proc( WNDPROC handle
)
101 UINT index
= LOWORD(handle
);
102 if ((ULONG_PTR
)handle
>> 16 != WINPROC_HANDLE
) return NULL
;
103 if (index
>= winproc_used
) return NULL
;
104 return &winproc_array
[index
];
107 /* create a handle for a given window proc */
108 static inline WNDPROC
proc_to_handle( WINDOWPROC
*proc
)
110 return (WNDPROC
)(ULONG_PTR
)((proc
- winproc_array
) | (WINPROC_HANDLE
<< 16));
113 /* allocate and initialize a new winproc */
114 static inline WINDOWPROC
*alloc_winproc( WNDPROC funcA
, WNDPROC funcW
)
118 /* check if the function is already a win proc */
119 if (funcA
&& (proc
= handle_to_proc( funcA
))) return proc
;
120 if (funcW
&& (proc
= handle_to_proc( funcW
))) return proc
;
121 if (!funcA
&& !funcW
) return NULL
;
123 EnterCriticalSection( &winproc_cs
);
125 /* check if we already have a winproc for that function */
126 if (!(proc
= find_winproc( funcA
, funcW
)))
128 if (winproc_used
< MAX_WINPROCS
)
130 proc
= &winproc_array
[winproc_used
++];
133 TRACE( "allocated %p for %p/%p (%d/%d used)\n",
134 proc_to_handle(proc
), funcA
, funcW
, winproc_used
, MAX_WINPROCS
);
136 else FIXME( "too many winprocs, cannot allocate one for %p/%p\n", funcA
, funcW
);
138 else TRACE( "reusing %p for %p/%p\n", proc_to_handle(proc
), funcA
, funcW
);
140 LeaveCriticalSection( &winproc_cs
);
147 #include "pshpack1.h"
149 /* Window procedure 16-to-32-bit thunk */
152 BYTE popl_eax
; /* popl %eax (return address) */
153 BYTE pushl_func
; /* pushl $proc */
155 BYTE pushl_eax
; /* pushl %eax */
156 BYTE ljmp
; /* ljmp relay*/
157 DWORD relay_offset
; /* __wine_call_wndproc */
163 #define MAX_THUNKS (0x10000 / sizeof(WINPROC_THUNK))
165 static WINPROC_THUNK
*thunk_array
;
166 static UINT thunk_selector
;
167 static UINT thunk_used
;
169 /* return the window proc for a given handle, or NULL for an invalid handle */
170 static inline WINDOWPROC
*handle16_to_proc( WNDPROC16 handle
)
172 if (HIWORD(handle
) == thunk_selector
)
174 UINT index
= LOWORD(handle
) / sizeof(WINPROC_THUNK
);
175 /* check alignment */
176 if (index
* sizeof(WINPROC_THUNK
) != LOWORD(handle
)) return NULL
;
177 /* check array limits */
178 if (index
>= thunk_used
) return NULL
;
179 return thunk_array
[index
].proc
;
181 return handle_to_proc( (WNDPROC
)handle
);
184 /* allocate a 16-bit thunk for an existing window proc */
185 static WNDPROC16
alloc_win16_thunk( WINDOWPROC
*proc
)
187 static FARPROC16 relay
;
190 if (proc
->proc16
) return proc
->proc16
;
192 EnterCriticalSection( &winproc_cs
);
194 if (!thunk_array
) /* allocate the array and its selector */
198 if (!(thunk_selector
= wine_ldt_alloc_entries(1))) goto done
;
199 if (!(thunk_array
= VirtualAlloc( NULL
, MAX_THUNKS
* sizeof(WINPROC_THUNK
), MEM_COMMIT
,
200 PAGE_EXECUTE_READWRITE
))) goto done
;
201 wine_ldt_set_base( &entry
, thunk_array
);
202 wine_ldt_set_limit( &entry
, MAX_THUNKS
* sizeof(WINPROC_THUNK
) - 1 );
203 wine_ldt_set_flags( &entry
, WINE_LDT_FLAGS_CODE
| WINE_LDT_FLAGS_32BIT
);
204 wine_ldt_set_entry( thunk_selector
, &entry
);
205 relay
= GetProcAddress16( GetModuleHandle16("user"), "__wine_call_wndproc" );
208 /* check if it already exists */
209 for (i
= 0; i
< thunk_used
; i
++) if (thunk_array
[i
].proc
== proc
) break;
211 if (i
== thunk_used
) /* create a new one */
213 WINPROC_THUNK
*thunk
;
215 if (thunk_used
>= MAX_THUNKS
) goto done
;
216 thunk
= &thunk_array
[thunk_used
++];
217 thunk
->popl_eax
= 0x58; /* popl %eax */
218 thunk
->pushl_func
= 0x68; /* pushl $proc */
220 thunk
->pushl_eax
= 0x50; /* pushl %eax */
221 thunk
->ljmp
= 0xea; /* ljmp relay*/
222 thunk
->relay_offset
= OFFSETOF(relay
);
223 thunk
->relay_sel
= SELECTOROF(relay
);
225 proc
->proc16
= (WNDPROC16
)MAKESEGPTR( thunk_selector
, i
* sizeof(WINPROC_THUNK
) );
227 LeaveCriticalSection( &winproc_cs
);
233 static inline WINDOWPROC
*handle16_to_proc( WNDPROC16 handle
)
235 return handle_to_proc( (WNDPROC
)handle
);
238 static inline WNDPROC16
alloc_win16_thunk( WINDOWPROC
*proc
)
243 #endif /* __i386__ */
247 /* Some window procedures modify register they shouldn't, or are not
248 * properly declared stdcall; so we need a small assembly wrapper to
250 extern LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
251 WPARAM wParam
, LPARAM lParam
);
252 __ASM_GLOBAL_FUNC( WINPROC_wrapper
,
263 "movl 8(%ebp),%eax\n\t"
265 "leal -12(%ebp),%esp\n\t"
272 static inline LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
273 WPARAM wParam
, LPARAM lParam
)
275 return proc( hwnd
, msg
, wParam
, lParam
);
277 #endif /* __i386__ */
280 static void MINMAXINFO32to16( const MINMAXINFO
*from
, MINMAXINFO16
*to
)
282 to
->ptReserved
.x
= from
->ptReserved
.x
;
283 to
->ptReserved
.y
= from
->ptReserved
.y
;
284 to
->ptMaxSize
.x
= from
->ptMaxSize
.x
;
285 to
->ptMaxSize
.y
= from
->ptMaxSize
.y
;
286 to
->ptMaxPosition
.x
= from
->ptMaxPosition
.x
;
287 to
->ptMaxPosition
.y
= from
->ptMaxPosition
.y
;
288 to
->ptMinTrackSize
.x
= from
->ptMinTrackSize
.x
;
289 to
->ptMinTrackSize
.y
= from
->ptMinTrackSize
.y
;
290 to
->ptMaxTrackSize
.x
= from
->ptMaxTrackSize
.x
;
291 to
->ptMaxTrackSize
.y
= from
->ptMaxTrackSize
.y
;
294 static void MINMAXINFO16to32( const MINMAXINFO16
*from
, MINMAXINFO
*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 WINDOWPOS32to16( const WINDOWPOS
* from
, WINDOWPOS16
* to
)
310 to
->hwnd
= HWND_16(from
->hwnd
);
311 to
->hwndInsertAfter
= HWND_16(from
->hwndInsertAfter
);
316 to
->flags
= from
->flags
;
319 static void WINDOWPOS16to32( const WINDOWPOS16
* from
, WINDOWPOS
* to
)
321 to
->hwnd
= WIN_Handle32(from
->hwnd
);
322 to
->hwndInsertAfter
= (from
->hwndInsertAfter
== (HWND16
)-1) ?
323 HWND_TOPMOST
: WIN_Handle32(from
->hwndInsertAfter
);
328 to
->flags
= from
->flags
;
331 /* The strings are not copied */
332 static void CREATESTRUCT32Ato16( const CREATESTRUCTA
* from
, CREATESTRUCT16
* to
)
334 to
->lpCreateParams
= (SEGPTR
)from
->lpCreateParams
;
335 to
->hInstance
= HINSTANCE_16(from
->hInstance
);
336 to
->hMenu
= HMENU_16(from
->hMenu
);
337 to
->hwndParent
= HWND_16(from
->hwndParent
);
342 to
->style
= from
->style
;
343 to
->dwExStyle
= from
->dwExStyle
;
346 static void CREATESTRUCT16to32A( const CREATESTRUCT16
* from
, CREATESTRUCTA
*to
)
349 to
->lpCreateParams
= (LPVOID
)from
->lpCreateParams
;
350 to
->hInstance
= HINSTANCE_32(from
->hInstance
);
351 to
->hMenu
= HMENU_32(from
->hMenu
);
352 to
->hwndParent
= WIN_Handle32(from
->hwndParent
);
357 to
->style
= from
->style
;
358 to
->dwExStyle
= from
->dwExStyle
;
361 /* The strings are not copied */
362 static void MDICREATESTRUCT32Ato16( const MDICREATESTRUCTA
* from
, MDICREATESTRUCT16
* to
)
364 to
->hOwner
= HINSTANCE_16(from
->hOwner
);
369 to
->style
= from
->style
;
370 to
->lParam
= from
->lParam
;
373 static void MDICREATESTRUCT16to32A( const MDICREATESTRUCT16
* from
, MDICREATESTRUCTA
*to
)
375 to
->hOwner
= HINSTANCE_32(from
->hOwner
);
380 to
->style
= from
->style
;
381 to
->lParam
= from
->lParam
;
384 /**********************************************************************
385 * WINPROC_CallWndProc32
387 * Call a 32-bit WndProc.
389 static LRESULT
WINPROC_CallWndProc( WNDPROC proc
, HWND hwnd
, UINT msg
,
390 WPARAM wParam
, LPARAM lParam
)
396 hwnd
= WIN_GetFullHandle( hwnd
);
398 DPRINTF( "%04lx:Call window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
399 GetCurrentThreadId(), proc
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
401 retvalue
= WINPROC_wrapper( proc
, hwnd
, msg
, wParam
, lParam
);
404 DPRINTF( "%04lx:Ret window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx) retval=%08lx\n",
405 GetCurrentThreadId(), proc
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
, retvalue
);
409 /***********************************************************************
410 * WINPROC_CallWndProc16
412 * Call a 16-bit window procedure
414 static LRESULT WINAPI
WINPROC_CallWndProc16( WNDPROC16 proc
, HWND16 hwnd
,
415 UINT16 msg
, WPARAM16 wParam
,
426 DRAWITEMSTRUCT16 dis16
;
427 COMPAREITEMSTRUCT16 cis16
;
433 /* Window procedures want ax = hInstance, ds = es = ss */
435 memset(&context
, 0, sizeof(context
));
436 context
.SegDs
= context
.SegEs
= SELECTOROF(NtCurrentTeb()->WOW32Reserved
);
437 context
.SegFs
= wine_get_fs();
438 context
.SegGs
= wine_get_gs();
439 if (!(context
.Eax
= GetWindowWord( HWND_32(hwnd
), GWLP_HINSTANCE
))) context
.Eax
= context
.SegDs
;
440 context
.SegCs
= SELECTOROF(proc
);
441 context
.Eip
= OFFSETOF(proc
);
442 context
.Ebp
= OFFSETOF(NtCurrentTeb()->WOW32Reserved
) + (WORD
)&((STACK16FRAME
*)0)->bp
;
446 /* Some programs (eg. the "Undocumented Windows" examples, JWP) only
447 work if structures passed in lParam are placed in the stack/data
448 segment. Programmers easily make the mistake of converting lParam
449 to a near rather than a far pointer, since Windows apparently
450 allows this. We copy the structures to the 16 bit stack; this is
451 ugly but makes these programs work. */
456 size
= sizeof(CREATESTRUCT16
); break;
458 size
= sizeof(DRAWITEMSTRUCT16
); break;
460 size
= sizeof(COMPAREITEMSTRUCT16
); break;
464 memcpy( &args
.u
, MapSL(lParam
), size
);
465 lParam
= (SEGPTR
)NtCurrentTeb()->WOW32Reserved
- size
;
469 args
.params
[4] = hwnd
;
470 args
.params
[3] = msg
;
471 args
.params
[2] = wParam
;
472 args
.params
[1] = HIWORD(lParam
);
473 args
.params
[0] = LOWORD(lParam
);
474 WOWCallback16Ex( 0, WCB16_REGS
, sizeof(args
.params
) + size
, &args
, (DWORD
*)&context
);
475 return MAKELONG( LOWORD(context
.Eax
), LOWORD(context
.Edx
) );
479 /**********************************************************************
482 * Get a window procedure pointer that can be passed to the Windows program.
484 WNDPROC16
WINPROC_GetProc16( WNDPROC proc
, BOOL unicode
)
488 if (unicode
) ptr
= alloc_winproc( NULL
, proc
);
489 else ptr
= alloc_winproc( proc
, NULL
);
492 return alloc_win16_thunk( ptr
);
496 /**********************************************************************
499 * Get a window procedure pointer that can be passed to the Windows program.
501 WNDPROC
WINPROC_GetProc( WNDPROC proc
, BOOL unicode
)
503 WINDOWPROC
*ptr
= handle_to_proc( proc
);
505 if (!ptr
) return proc
;
508 if (ptr
->procW
) return ptr
->procW
;
513 if (ptr
->procA
) return ptr
->procA
;
519 /**********************************************************************
520 * WINPROC_AllocProc16
522 * Allocate a window procedure for a window or class.
524 * Note that allocated winprocs are never freed; the idea is that even if an app creates a
525 * lot of windows, it will usually only have a limited number of window procedures, so the
526 * array won't grow too large, and this way we avoid the need to track allocations per window.
528 WNDPROC
WINPROC_AllocProc16( WNDPROC16 func
)
532 if (!func
) return NULL
;
534 /* check if the function is already a win proc */
535 if (!(proc
= handle16_to_proc( func
)))
537 EnterCriticalSection( &winproc_cs
);
539 /* then check if we already have a winproc for that function */
540 if (!(proc
= find_winproc16( func
)))
542 if (winproc_used
< MAX_WINPROCS
)
544 proc
= &winproc_array
[winproc_used
++];
546 TRACE( "allocated %p for %p/16-bit (%d/%d used)\n",
547 proc_to_handle(proc
), func
, winproc_used
, MAX_WINPROCS
);
549 else FIXME( "too many winprocs, cannot allocate one for 16-bit %p\n", func
);
551 else TRACE( "reusing %p for %p/16-bit\n", proc_to_handle(proc
), func
);
553 LeaveCriticalSection( &winproc_cs
);
555 return proc_to_handle( proc
);
559 /**********************************************************************
562 * Allocate a window procedure for a window or class.
564 * Note that allocated winprocs are never freed; the idea is that even if an app creates a
565 * lot of windows, it will usually only have a limited number of window procedures, so the
566 * array won't grow too large, and this way we avoid the need to track allocations per window.
568 WNDPROC
WINPROC_AllocProc( WNDPROC funcA
, WNDPROC funcW
)
572 if (!(proc
= alloc_winproc( funcA
, funcW
))) return NULL
;
573 return proc_to_handle( proc
);
577 /**********************************************************************
580 * Return the window procedure type, or the default value if not a winproc handle.
582 BOOL
WINPROC_IsUnicode( WNDPROC proc
, BOOL def_val
)
584 WINDOWPROC
*ptr
= handle_to_proc( proc
);
586 if (!ptr
) return def_val
;
587 if (ptr
->procA
&& ptr
->procW
) return def_val
; /* can be both */
588 return (ptr
->procW
!= NULL
);
592 /**********************************************************************
593 * WINPROC_TestCBForStr
595 * Return TRUE if the lparam is a string
597 inline static BOOL
WINPROC_TestCBForStr( HWND hwnd
)
599 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
600 return (!(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) || (style
& CBS_HASSTRINGS
));
602 /**********************************************************************
603 * WINPROC_TestLBForStr
605 * Return TRUE if the lparam is a string
607 inline static BOOL
WINPROC_TestLBForStr( HWND hwnd
)
609 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
610 return (!(style
& (LBS_OWNERDRAWFIXED
| LBS_OWNERDRAWVARIABLE
)) || (style
& LBS_HASSTRINGS
));
613 /**********************************************************************
614 * WINPROC_MapMsg32ATo32W
616 * Map a message from Ansi to Unicode.
617 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
620 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
621 * the first four bytes are the handle of the icon
622 * when the WM_SETTEXT message has been used to set the icon
624 INT
WINPROC_MapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
629 case WM_ASKCBFORMATNAME
:
631 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0,
632 *pwparam
* sizeof(WCHAR
) + sizeof(LPARAM
) );
634 *ptr
++ = *plparam
; /* Store previous lParam */
635 *plparam
= (LPARAM
)ptr
;
638 /* lparam is string (0-terminated) */
640 case WM_WININICHANGE
:
641 case WM_DEVMODECHANGE
:
646 if (!*plparam
) return 0;
649 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*plparam
, -1, NULL
, 0);
650 WCHAR
*buf
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
651 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*plparam
, -1, buf
, len
);
652 *plparam
= (LPARAM
)buf
;
653 return (*plparam
? 1 : -1);
655 case WM_GETTEXTLENGTH
:
656 case CB_GETLBTEXTLEN
:
658 return 1; /* need to map result */
662 UNICODE_STRING usBuffer
;
664 { CREATESTRUCTW cs
; /* new structure */
665 LPCWSTR lpszName
; /* allocated Name */
666 LPCWSTR lpszClass
; /* allocated Class */
669 struct s
*xs
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct s
));
671 xs
->cs
= *(CREATESTRUCTW
*)*plparam
;
672 if (HIWORD(xs
->cs
.lpszName
))
674 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)xs
->cs
.lpszName
);
675 xs
->lpszName
= xs
->cs
.lpszName
= usBuffer
.Buffer
;
677 if (HIWORD(xs
->cs
.lpszClass
))
679 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)xs
->cs
.lpszClass
);
680 xs
->lpszClass
= xs
->cs
.lpszClass
= usBuffer
.Buffer
;
683 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
685 MDICREATESTRUCTW
*mdi_cs
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs
));
686 *mdi_cs
= *(MDICREATESTRUCTW
*)xs
->cs
.lpCreateParams
;
687 if (HIWORD(mdi_cs
->szTitle
))
689 RtlCreateUnicodeStringFromAsciiz(&usBuffer
, (LPCSTR
)mdi_cs
->szTitle
);
690 mdi_cs
->szTitle
= usBuffer
.Buffer
;
692 if (HIWORD(mdi_cs
->szClass
))
694 RtlCreateUnicodeStringFromAsciiz(&usBuffer
, (LPCSTR
)mdi_cs
->szClass
);
695 mdi_cs
->szClass
= usBuffer
.Buffer
;
697 xs
->cs
.lpCreateParams
= mdi_cs
;
700 *plparam
= (LPARAM
)xs
;
705 MDICREATESTRUCTW
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
707 *cs
= *(MDICREATESTRUCTW
*)*plparam
;
708 if (HIWORD(cs
->szClass
))
710 UNICODE_STRING usBuffer
;
711 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)cs
->szClass
);
712 cs
->szClass
= usBuffer
.Buffer
;
714 if (HIWORD(cs
->szTitle
))
716 UNICODE_STRING usBuffer
;
717 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)cs
->szTitle
);
718 cs
->szTitle
= usBuffer
.Buffer
;
720 *plparam
= (LPARAM
)cs
;
726 case LB_INSERTSTRING
:
728 case LB_FINDSTRINGEXACT
:
729 case LB_SELECTSTRING
:
730 if(!*plparam
) return 0;
731 if ( WINPROC_TestLBForStr( hwnd
))
733 UNICODE_STRING usBuffer
;
734 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)*plparam
);
735 *plparam
= (LPARAM
)usBuffer
.Buffer
;
737 return (*plparam
? 1 : -1);
739 case LB_GETTEXT
: /* FIXME: fixed sized buffer */
740 { if ( WINPROC_TestLBForStr( hwnd
))
741 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 * sizeof(WCHAR
) + sizeof(LPARAM
) );
743 *ptr
++ = *plparam
; /* Store previous lParam */
744 *plparam
= (LPARAM
)ptr
;
751 case CB_INSERTSTRING
:
752 case CB_FINDSTRINGEXACT
:
754 case CB_SELECTSTRING
:
755 if(!*plparam
) return 0;
756 if ( WINPROC_TestCBForStr( hwnd
))
758 UNICODE_STRING usBuffer
;
759 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)*plparam
);
760 *plparam
= (LPARAM
)usBuffer
.Buffer
;
762 return (*plparam
? 1 : -1);
764 case CB_GETLBTEXT
: /* FIXME: fixed sized buffer */
765 { if ( WINPROC_TestCBForStr( hwnd
))
766 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 * sizeof(WCHAR
) + sizeof(LPARAM
) );
768 *ptr
++ = *plparam
; /* Store previous lParam */
769 *plparam
= (LPARAM
)ptr
;
776 { WORD len
= (WORD
)*plparam
;
777 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(WCHAR
) );
779 *ptr
++ = *plparam
; /* Store previous lParam */
780 *((WORD
*) ptr
) = len
; /* Store the length */
781 *plparam
= (LPARAM
)ptr
;
791 case EM_SETPASSWORDCHAR
:
793 CHAR ch
= LOWORD(*pwparam
);
795 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wch
, 1);
796 *pwparam
= MAKEWPARAM( wch
, HIWORD(*pwparam
) );
804 ch
[0] = (*pwparam
>> 8);
805 ch
[1] = *pwparam
& 0xff;
807 MultiByteToWideChar(CP_ACP
, 0, ch
, 2, &wch
, 1);
809 MultiByteToWideChar(CP_ACP
, 0, &ch
[1], 1, &wch
, 1);
810 *pwparam
= MAKEWPARAM( wch
, HIWORD(*pwparam
) );
814 case WM_PAINTCLIPBOARD
:
815 case WM_SIZECLIPBOARD
:
816 FIXME_(msg
)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg
, hwnd
), msg
);
818 default: /* No translation needed */
824 /**********************************************************************
825 * WINPROC_UnmapMsg32ATo32W
827 * Unmap a message that was mapped from Ansi to Unicode.
829 LRESULT
WINPROC_UnmapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
830 LRESULT result
, WNDPROC dispatch
)
835 case WM_ASKCBFORMATNAME
:
837 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
838 if (!wParam
) result
= 0;
839 else if (!(result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
840 (LPSTR
)*ptr
, wParam
, NULL
, NULL
)))
842 ((LPSTR
)*ptr
)[wParam
-1] = 0;
845 else result
--; /* do not count terminating null */
846 HeapFree( GetProcessHeap(), 0, ptr
);
849 case WM_GETTEXTLENGTH
:
850 case CB_GETLBTEXTLEN
:
854 /* Determine respective GETTEXT message */
856 (msg
== WM_GETTEXTLENGTH
) ? WM_GETTEXT
:
857 ((msg
== CB_GETLBTEXTLEN
) ? CB_GETLBTEXT
: LB_GETTEXT
);
858 /* wParam differs between the messages */
859 WPARAM wp
= (msg
== WM_GETTEXTLENGTH
) ? (WPARAM
)(result
+ 1) : wParam
;
861 WCHAR
* p
= HeapAlloc (GetProcessHeap(), 0, (result
+ 1) * sizeof(WCHAR
));
868 n
= WINPROC_CallWndProc(dispatch
, hwnd
, msgGetText
, wp
, (LPARAM
)p
);
870 n
= SendMessageW (hwnd
, msgGetText
, wp
, (LPARAM
)p
);
872 result
= WideCharToMultiByte( CP_ACP
, 0, p
, n
, NULL
, 0, 0, NULL
);
873 HeapFree (GetProcessHeap(), 0, p
);
881 { CREATESTRUCTW cs
; /* new structure */
882 LPWSTR lpszName
; /* allocated Name */
883 LPWSTR lpszClass
; /* allocated Class */
885 struct s
*xs
= (struct s
*)lParam
;
886 HeapFree( GetProcessHeap(), 0, xs
->lpszName
);
887 HeapFree( GetProcessHeap(), 0, xs
->lpszClass
);
889 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
891 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)xs
->cs
.lpCreateParams
;
892 if (HIWORD(mdi_cs
->szTitle
))
893 HeapFree(GetProcessHeap(), 0, (LPVOID
)mdi_cs
->szTitle
);
894 if (HIWORD(mdi_cs
->szClass
))
895 HeapFree(GetProcessHeap(), 0, (LPVOID
)mdi_cs
->szClass
);
896 HeapFree(GetProcessHeap(), 0, mdi_cs
);
898 HeapFree( GetProcessHeap(), 0, xs
);
904 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
905 if (HIWORD(cs
->szTitle
))
906 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
907 if (HIWORD(cs
->szClass
))
908 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
909 HeapFree( GetProcessHeap(), 0, cs
);
914 case WM_WININICHANGE
:
915 case WM_DEVMODECHANGE
:
920 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
925 case LB_INSERTSTRING
:
927 case LB_FINDSTRINGEXACT
:
928 case LB_SELECTSTRING
:
929 if ( WINPROC_TestLBForStr( hwnd
))
930 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
934 if ( WINPROC_TestLBForStr( hwnd
))
936 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
938 result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
939 (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
) - 1;
940 HeapFree( GetProcessHeap(), 0, ptr
);
946 case CB_INSERTSTRING
:
948 case CB_FINDSTRINGEXACT
:
949 case CB_SELECTSTRING
:
950 if ( WINPROC_TestCBForStr( hwnd
))
951 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
955 if ( result
< 0) /* CB_ERR and CB_ERRSPACE */
957 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
958 HeapFree( GetProcessHeap(), 0, ptr
);
960 else if ( WINPROC_TestCBForStr( hwnd
))
962 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
963 result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
964 (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
) - 1;
965 HeapFree( GetProcessHeap(), 0, ptr
);
972 LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lParam */
973 WORD len
= *(WORD
*) lParam
;
974 result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, result
,
975 (LPSTR
)*ptr
, len
, NULL
, NULL
);
976 if (result
< len
) ((LPSTR
)*ptr
)[result
] = 0;
977 HeapFree( GetProcessHeap(), 0, ptr
);
985 /**********************************************************************
986 * WINPROC_MapMsg32WTo32A
988 * Map a message from Unicode to Ansi.
989 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
991 static INT
WINPROC_MapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
996 case WM_WININICHANGE
:
997 case WM_DEVMODECHANGE
:
1004 LPCWSTR str
= (LPCWSTR
)*plparam
;
1005 int len
= WideCharToMultiByte(CP_ACP
, 0, str
, -1, NULL
, 0, 0, 0);
1006 *plparam
= (LPARAM
)HeapAlloc(GetProcessHeap(), 0, len
);
1007 if (!*plparam
) return -1;
1008 WideCharToMultiByte(CP_ACP
, 0, str
, -1, (LPSTR
)*plparam
, len
, 0, 0);
1015 MDICREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
1017 *cs
= *(MDICREATESTRUCTA
*)*plparam
;
1018 if (HIWORD(cs
->szTitle
))
1020 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szTitle
, -1, NULL
, 0, 0, 0);
1021 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1022 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szTitle
, -1, buf
, len
, 0, 0);
1025 if (HIWORD(cs
->szClass
))
1027 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szClass
, -1, NULL
, 0, 0, 0);
1028 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1029 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szClass
, -1, buf
, len
, 0, 0);
1032 *plparam
= (LPARAM
)cs
;
1038 case LB_INSERTSTRING
:
1040 case LB_FINDSTRINGEXACT
:
1041 case LB_SELECTSTRING
:
1042 if(!*plparam
) return 0;
1043 if ( WINPROC_TestLBForStr( hwnd
))
1045 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, NULL
, 0, 0, 0);
1046 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1047 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, buf
, len
, 0, 0);
1048 *plparam
= (LPARAM
)buf
;
1050 return (*plparam
? 1 : -1);
1052 case LB_GETTEXT
: /* FIXME: fixed sized buffer */
1053 { if ( WINPROC_TestLBForStr( hwnd
))
1054 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 + sizeof(LPARAM
) );
1055 if (!ptr
) return -1;
1056 *ptr
++ = *plparam
; /* Store previous lParam */
1057 *plparam
= (LPARAM
)ptr
;
1064 case CB_INSERTSTRING
:
1066 case CB_FINDSTRINGEXACT
:
1067 case CB_SELECTSTRING
:
1068 if(!*plparam
) return 0;
1069 if ( WINPROC_TestCBForStr( hwnd
))
1071 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, NULL
, 0, 0, 0);
1072 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1073 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, buf
, len
, 0, 0);
1074 *plparam
= (LPARAM
)buf
;
1076 return (*plparam
? 1 : -1);
1078 case CB_GETLBTEXT
: /* FIXME: fixed sized buffer */
1079 { if ( WINPROC_TestCBForStr( hwnd
))
1080 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 + sizeof(LPARAM
) );
1081 if (!ptr
) return -1;
1082 *ptr
++ = *plparam
; /* Store previous lParam */
1083 *plparam
= (LPARAM
)ptr
;
1088 /* Multiline edit */
1090 { WORD len
= (WORD
)*plparam
;
1091 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(CHAR
) );
1092 if (!ptr
) return -1;
1093 *ptr
++ = *plparam
; /* Store previous lParam */
1094 *((WORD
*) ptr
) = len
; /* Store the length */
1095 *plparam
= (LPARAM
)ptr
;
1104 case WM_SYSDEADCHAR
:
1105 case EM_SETPASSWORDCHAR
:
1107 WCHAR wch
= LOWORD(*pwparam
);
1109 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
1110 *pwparam
= MAKEWPARAM( ch
, HIWORD(*pwparam
) );
1116 WCHAR wch
= LOWORD(*pwparam
);
1119 if (WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)ch
, 2, NULL
, NULL
) == 2)
1120 *pwparam
= MAKEWPARAM( (ch
[0] << 8) | ch
[1], HIWORD(*pwparam
) );
1122 *pwparam
= MAKEWPARAM( ch
[0], HIWORD(*pwparam
) );
1126 case WM_PAINTCLIPBOARD
:
1127 case WM_SIZECLIPBOARD
:
1128 FIXME_(msg
)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg
, hwnd
),msg
);
1130 default: /* No translation needed */
1136 /**********************************************************************
1137 * WINPROC_UnmapMsg32WTo32A
1139 * Unmap a message that was mapped from Unicode to Ansi.
1141 static LRESULT
WINPROC_UnmapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
, LRESULT result
)
1146 case WM_WININICHANGE
:
1147 case WM_DEVMODECHANGE
:
1152 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1157 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1158 if (HIWORD(cs
->szTitle
))
1159 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
1160 if (HIWORD(cs
->szClass
))
1161 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
1162 HeapFree( GetProcessHeap(), 0, cs
);
1168 case LB_INSERTSTRING
:
1170 case LB_FINDSTRINGEXACT
:
1171 case LB_SELECTSTRING
:
1172 if ( WINPROC_TestLBForStr( hwnd
))
1173 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1177 if ( WINPROC_TestLBForStr( hwnd
))
1179 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1181 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff ) - 1;
1182 HeapFree( GetProcessHeap(), 0, ptr
);
1188 case CB_INSERTSTRING
:
1190 case CB_FINDSTRINGEXACT
:
1191 case CB_SELECTSTRING
:
1192 if ( WINPROC_TestCBForStr( hwnd
))
1193 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1197 if ( result
< 0) /* CB_ERR and CB_ERRSPACE */
1199 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1200 HeapFree( GetProcessHeap(), 0, ptr
);
1202 else if ( WINPROC_TestCBForStr( hwnd
))
1204 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1205 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff ) - 1;
1206 HeapFree( GetProcessHeap(), 0, ptr
);
1210 /* Multiline edit */
1213 LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lparam */
1214 WORD len
= *(WORD
*)ptr
;
1217 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, result
, (LPWSTR
)*ptr
, len
);
1218 if (result
< len
) ((LPWSTR
)*ptr
)[result
] = 0;
1220 HeapFree( GetProcessHeap(), 0, ptr
);
1227 static UINT
convert_handle_16_to_32(HANDLE16 src
, unsigned int flags
)
1230 UINT sz
= GlobalSize16(src
);
1233 if (!(dst
= GlobalAlloc(flags
, sz
)))
1235 ptr16
= GlobalLock16(src
);
1236 ptr32
= GlobalLock(dst
);
1237 if (ptr16
!= NULL
&& ptr32
!= NULL
) memcpy(ptr32
, ptr16
, sz
);
1238 GlobalUnlock16(src
);
1244 /**********************************************************************
1245 * WINPROC_MapMsg16To32A
1247 * Map a message from 16- to 32-bit Ansi.
1248 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1250 INT
WINPROC_MapMsg16To32A( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1251 WPARAM
*pwparam32
, LPARAM
*plparam
)
1253 *pmsg32
= (UINT
)msg16
;
1254 *pwparam32
= (WPARAM
)wParam16
;
1261 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1262 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1266 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1267 *plparam
= (LPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1270 if ( HIWORD(*plparam
) > CTLCOLOR_STATIC
) return -1;
1271 *pmsg32
= WM_CTLCOLORMSGBOX
+ HIWORD(*plparam
);
1272 *pwparam32
= (WPARAM
)HDC_32(wParam16
);
1273 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1275 case WM_COMPAREITEM
:
1277 COMPAREITEMSTRUCT16
* cis16
= MapSL(*plparam
);
1278 COMPAREITEMSTRUCT
*cis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cis
));
1279 if (!cis
) return -1;
1280 cis
->CtlType
= cis16
->CtlType
;
1281 cis
->CtlID
= cis16
->CtlID
;
1282 cis
->hwndItem
= WIN_Handle32( cis16
->hwndItem
);
1283 cis
->itemID1
= cis16
->itemID1
;
1284 cis
->itemData1
= cis16
->itemData1
;
1285 cis
->itemID2
= cis16
->itemID2
;
1286 cis
->itemData2
= cis16
->itemData2
;
1287 cis
->dwLocaleId
= 0; /* FIXME */
1288 *plparam
= (LPARAM
)cis
;
1293 PCOPYDATASTRUCT16 pcds16
= MapSL(*plparam
);
1294 PCOPYDATASTRUCT pcds
= HeapAlloc ( GetProcessHeap(), 0, sizeof(*pcds
));
1295 pcds
->dwData
= pcds16
->dwData
;
1296 pcds
->cbData
= pcds16
->cbData
;
1297 pcds
->lpData
= MapSL( pcds16
->lpData
);
1298 *plparam
= (LPARAM
)pcds
;
1303 DELETEITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1304 DELETEITEMSTRUCT
*dis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1305 if (!dis
) return -1;
1306 dis
->CtlType
= dis16
->CtlType
;
1307 dis
->CtlID
= dis16
->CtlID
;
1308 dis
->hwndItem
= WIN_Handle32( dis16
->hwndItem
);
1309 dis
->itemData
= dis16
->itemData
;
1310 *plparam
= (LPARAM
)dis
;
1313 case WM_MEASUREITEM
:
1315 MEASUREITEMSTRUCT16
* mis16
= MapSL(*plparam
);
1316 MEASUREITEMSTRUCT
*mis
= HeapAlloc(GetProcessHeap(), 0,
1317 sizeof(*mis
) + sizeof(LPARAM
));
1318 if (!mis
) return -1;
1319 mis
->CtlType
= mis16
->CtlType
;
1320 mis
->CtlID
= mis16
->CtlID
;
1321 mis
->itemID
= mis16
->itemID
;
1322 mis
->itemWidth
= mis16
->itemWidth
;
1323 mis
->itemHeight
= mis16
->itemHeight
;
1324 mis
->itemData
= mis16
->itemData
;
1325 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1326 *plparam
= (LPARAM
)mis
;
1331 DRAWITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1332 DRAWITEMSTRUCT
*dis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1333 if (!dis
) return -1;
1334 dis
->CtlType
= dis16
->CtlType
;
1335 dis
->CtlID
= dis16
->CtlID
;
1336 dis
->itemID
= dis16
->itemID
;
1337 dis
->itemAction
= dis16
->itemAction
;
1338 dis
->itemState
= dis16
->itemState
;
1339 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND
)HMENU_32(dis16
->hwndItem
)
1340 : WIN_Handle32( dis16
->hwndItem
);
1341 dis
->hDC
= HDC_32(dis16
->hDC
);
1342 dis
->itemData
= dis16
->itemData
;
1343 dis
->rcItem
.left
= dis16
->rcItem
.left
;
1344 dis
->rcItem
.top
= dis16
->rcItem
.top
;
1345 dis
->rcItem
.right
= dis16
->rcItem
.right
;
1346 dis
->rcItem
.bottom
= dis16
->rcItem
.bottom
;
1347 *plparam
= (LPARAM
)dis
;
1350 case WM_GETMINMAXINFO
:
1352 MINMAXINFO
*mmi
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mmi
) + sizeof(LPARAM
));
1353 if (!mmi
) return -1;
1354 MINMAXINFO16to32( MapSL(*plparam
), mmi
);
1355 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1356 *plparam
= (LPARAM
)mmi
;
1361 case WM_WININICHANGE
:
1362 case WM_DEVMODECHANGE
:
1363 case WM_ASKCBFORMATNAME
:
1364 *plparam
= (LPARAM
)MapSL(*plparam
);
1368 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1369 MDICREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1371 MDICREATESTRUCT16to32A( cs16
, cs
);
1372 cs
->szTitle
= MapSL(cs16
->szTitle
);
1373 cs
->szClass
= MapSL(cs16
->szClass
);
1374 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1375 *plparam
= (LPARAM
)cs
;
1378 case WM_MDIGETACTIVE
:
1379 *plparam
= (LPARAM
)HeapAlloc( GetProcessHeap(), 0, sizeof(BOOL
) );
1380 *(BOOL
*)(*plparam
) = 0;
1383 if(wParam16
) *pmsg32
=WM_MDIREFRESHMENU
;
1384 *pwparam32
= (WPARAM
)HMENU_32(LOWORD(*plparam
));
1385 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1388 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1389 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1392 if((LOWORD(*plparam
) & MF_POPUP
) && (LOWORD(*plparam
) != 0xFFFF))
1394 HMENU hmenu
=HMENU_32(HIWORD(*plparam
));
1395 UINT Pos
=MENU_FindSubMenu( &hmenu
, HMENU_32(wParam16
));
1396 if(Pos
==0xFFFF) Pos
=0; /* NO_SELECTED_ITEM */
1397 *pwparam32
= MAKEWPARAM( Pos
, LOWORD(*plparam
) );
1399 else *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1400 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1402 case WM_MDIACTIVATE
:
1405 *pwparam32
= (WPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1406 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1408 else /* message sent to MDI client */
1409 *pwparam32
= wParam16
;
1413 NCCALCSIZE_PARAMS16
*nc16
;
1414 NCCALCSIZE_PARAMS
*nc
;
1416 nc
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
) + sizeof(LPARAM
) );
1418 nc16
= MapSL(*plparam
);
1419 nc
->rgrc
[0].left
= nc16
->rgrc
[0].left
;
1420 nc
->rgrc
[0].top
= nc16
->rgrc
[0].top
;
1421 nc
->rgrc
[0].right
= nc16
->rgrc
[0].right
;
1422 nc
->rgrc
[0].bottom
= nc16
->rgrc
[0].bottom
;
1425 nc
->lppos
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
->lppos
) );
1426 nc
->rgrc
[1].left
= nc16
->rgrc
[1].left
;
1427 nc
->rgrc
[1].top
= nc16
->rgrc
[1].top
;
1428 nc
->rgrc
[1].right
= nc16
->rgrc
[1].right
;
1429 nc
->rgrc
[1].bottom
= nc16
->rgrc
[1].bottom
;
1430 nc
->rgrc
[2].left
= nc16
->rgrc
[2].left
;
1431 nc
->rgrc
[2].top
= nc16
->rgrc
[2].top
;
1432 nc
->rgrc
[2].right
= nc16
->rgrc
[2].right
;
1433 nc
->rgrc
[2].bottom
= nc16
->rgrc
[2].bottom
;
1434 if (nc
->lppos
) WINDOWPOS16to32( MapSL(nc16
->lppos
), nc
->lppos
);
1436 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1437 *plparam
= (LPARAM
)nc
;
1443 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1444 CREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1446 CREATESTRUCT16to32A( cs16
, cs
);
1447 cs
->lpszName
= MapSL(cs16
->lpszName
);
1448 cs
->lpszClass
= MapSL(cs16
->lpszClass
);
1450 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1452 MDICREATESTRUCT16
*mdi_cs16
;
1453 MDICREATESTRUCTA
*mdi_cs
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs
));
1456 HeapFree(GetProcessHeap(), 0, cs
);
1459 mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs16
->lpCreateParams
);
1460 MDICREATESTRUCT16to32A(mdi_cs16
, mdi_cs
);
1461 mdi_cs
->szTitle
= MapSL(mdi_cs16
->szTitle
);
1462 mdi_cs
->szClass
= MapSL(mdi_cs16
->szClass
);
1464 cs
->lpCreateParams
= mdi_cs
;
1466 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1467 *plparam
= (LPARAM
)cs
;
1470 case WM_PARENTNOTIFY
:
1471 if ((wParam16
== WM_CREATE
) || (wParam16
== WM_DESTROY
))
1473 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1474 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1477 case WM_WINDOWPOSCHANGING
:
1478 case WM_WINDOWPOSCHANGED
:
1480 WINDOWPOS
*wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*wp
) + sizeof(LPARAM
) );
1482 WINDOWPOS16to32( MapSL(*plparam
), wp
);
1483 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1484 *plparam
= (LPARAM
)wp
;
1490 LPMSG16 msg16
= MapSL(*plparam
);
1491 LPMSG msg32
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1493 if (!msg32
) return -1;
1494 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1495 msg32
->lParam
= msg16
->lParam
;
1496 msg32
->time
= msg16
->time
;
1497 msg32
->pt
.x
= msg16
->pt
.x
;
1498 msg32
->pt
.y
= msg16
->pt
.y
;
1499 /* this is right, right? */
1500 if (WINPROC_MapMsg16To32A( msg32
->hwnd
, msg16
->message
,msg16
->wParam
,
1501 &msg32
->message
,&msg32
->wParam
,
1502 &msg32
->lParam
)<0) {
1503 HeapFree( GetProcessHeap(), 0, msg32
);
1506 *plparam
= (LPARAM
)msg32
;
1511 *plparam
= (LPARAM
)MapSL(*plparam
);
1513 case WM_ACTIVATEAPP
:
1514 /* We need this when SetActiveWindow sends a Sendmessage16() to
1515 * a 32bit window. Might be superflous with 32bit interprocess
1516 * message queues. */
1517 if (*plparam
) *plparam
= HTASK_32( *plparam
);
1521 MDINEXTMENU
*next
= HeapAlloc( GetProcessHeap(), 0, sizeof(*next
) );
1522 if (!next
) return -1;
1523 next
->hmenuIn
= (HMENU
)*plparam
;
1524 next
->hmenuNext
= 0;
1526 *plparam
= (LPARAM
)next
;
1529 case WM_PAINTCLIPBOARD
:
1530 case WM_SIZECLIPBOARD
:
1531 FIXME_(msg
)("message %04x needs translation\n",msg16
);
1533 case WM_DDE_INITIATE
:
1534 case WM_DDE_TERMINATE
:
1535 case WM_DDE_UNADVISE
:
1536 case WM_DDE_REQUEST
:
1537 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1547 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1548 lo16
= LOWORD(*plparam
);
1549 hi
= HIWORD(*plparam
);
1550 if (lo16
&& !(lo32
= convert_handle_16_to_32(lo16
, GMEM_DDESHARE
)))
1552 *plparam
= PackDDElParam(msg16
, lo32
, hi
);
1554 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1561 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1563 lo
= LOWORD(*plparam
);
1564 hi
= HIWORD(*plparam
);
1566 if (GlobalGetAtomNameA(hi
, buf
, 2) > 0) flag
|= 1;
1567 if (GlobalSize16(hi
) != 0) flag
|= 2;
1573 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
1578 break; /* atom, nothing to do */
1580 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi
);
1583 hi
= convert_handle_16_to_32(hi
, GMEM_DDESHARE
);
1586 *plparam
= PackDDElParam(WM_DDE_ACK
, lo
, hi
);
1588 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1589 case WM_DDE_EXECUTE
:
1590 *plparam
= convert_handle_16_to_32(*plparam
, GMEM_DDESHARE
);
1591 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1592 default: /* No translation needed */
1598 /**********************************************************************
1599 * WINPROC_UnmapMsg16To32A
1601 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1603 LRESULT
WINPROC_UnmapMsg16To32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1608 case WM_COMPAREITEM
:
1612 HeapFree( GetProcessHeap(), 0, (LPVOID
)lParam
);
1614 case WM_MEASUREITEM
:
1616 MEASUREITEMSTRUCT16
*mis16
;
1617 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)lParam
;
1618 lParam
= *(LPARAM
*)(mis
+ 1);
1619 mis16
= MapSL(lParam
);
1620 mis16
->itemWidth
= (UINT16
)mis
->itemWidth
;
1621 mis16
->itemHeight
= (UINT16
)mis
->itemHeight
;
1622 HeapFree( GetProcessHeap(), 0, mis
);
1625 case WM_GETMINMAXINFO
:
1627 MINMAXINFO
*mmi
= (MINMAXINFO
*)lParam
;
1628 lParam
= *(LPARAM
*)(mmi
+ 1);
1629 MINMAXINFO32to16( mmi
, MapSL(lParam
));
1630 HeapFree( GetProcessHeap(), 0, mmi
);
1635 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1636 lParam
= *(LPARAM
*)(cs
+ 1);
1637 MDICREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1638 HeapFree( GetProcessHeap(), 0, cs
);
1641 case WM_MDIGETACTIVE
:
1642 result
= MAKELONG( LOWORD(result
), (BOOL16
)(*(BOOL
*)lParam
) );
1643 HeapFree( GetProcessHeap(), 0, (BOOL
*)lParam
);
1647 NCCALCSIZE_PARAMS16
*nc16
;
1648 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lParam
;
1649 lParam
= *(LPARAM
*)(nc
+ 1);
1650 nc16
= MapSL(lParam
);
1651 nc16
->rgrc
[0].left
= nc
->rgrc
[0].left
;
1652 nc16
->rgrc
[0].top
= nc
->rgrc
[0].top
;
1653 nc16
->rgrc
[0].right
= nc
->rgrc
[0].right
;
1654 nc16
->rgrc
[0].bottom
= nc
->rgrc
[0].bottom
;
1657 nc16
->rgrc
[1].left
= nc
->rgrc
[1].left
;
1658 nc16
->rgrc
[1].top
= nc
->rgrc
[1].top
;
1659 nc16
->rgrc
[1].right
= nc
->rgrc
[1].right
;
1660 nc16
->rgrc
[1].bottom
= nc
->rgrc
[1].bottom
;
1661 nc16
->rgrc
[2].left
= nc
->rgrc
[2].left
;
1662 nc16
->rgrc
[2].top
= nc
->rgrc
[2].top
;
1663 nc16
->rgrc
[2].right
= nc
->rgrc
[2].right
;
1664 nc16
->rgrc
[2].bottom
= nc
->rgrc
[2].bottom
;
1667 WINDOWPOS32to16( nc
->lppos
, MapSL(nc16
->lppos
));
1668 HeapFree( GetProcessHeap(), 0, nc
->lppos
);
1671 HeapFree( GetProcessHeap(), 0, nc
);
1677 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
1678 lParam
= *(LPARAM
*)(cs
+ 1);
1679 CREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1681 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1682 HeapFree(GetProcessHeap(), 0, cs
->lpCreateParams
);
1684 HeapFree( GetProcessHeap(), 0, cs
);
1687 case WM_WINDOWPOSCHANGING
:
1688 case WM_WINDOWPOSCHANGED
:
1690 WINDOWPOS
*wp
= (WINDOWPOS
*)lParam
;
1691 lParam
= *(LPARAM
*)(wp
+ 1);
1692 WINDOWPOS32to16(wp
, MapSL(lParam
));
1693 HeapFree( GetProcessHeap(), 0, wp
);
1699 LPMSG msg32
= (LPMSG
)lParam
;
1701 WINPROC_UnmapMsg16To32A( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1703 HeapFree( GetProcessHeap(), 0, msg32
);
1708 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
1709 result
= MAKELONG( HMENU_16(next
->hmenuNext
), HWND_16(next
->hwndNext
) );
1710 HeapFree( GetProcessHeap(), 0, next
);
1718 /**********************************************************************
1719 * WINPROC_MapMsg16To32W
1721 * Map a message from 16- to 32-bit Unicode.
1722 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1724 INT
WINPROC_MapMsg16To32W( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1725 WPARAM
*pwparam32
, LPARAM
*plparam
)
1730 *pmsg32
=(UINT
)msg16
;
1731 *pwparam32
= (WPARAM
)wParam16
;
1736 case WM_WININICHANGE
:
1737 case WM_DEVMODECHANGE
:
1738 case WM_ASKCBFORMATNAME
:
1739 *plparam
= (LPARAM
)MapSL(*plparam
);
1740 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1741 case WM_GETTEXTLENGTH
:
1742 case CB_GETLBTEXTLEN
:
1744 return 1; /* need to map result */
1748 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1749 CREATESTRUCTW
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1751 CREATESTRUCT16to32A( cs16
, (CREATESTRUCTA
*)cs
);
1752 cs
->lpszName
= map_str_16_to_32W(cs16
->lpszName
);
1753 cs
->lpszClass
= map_str_16_to_32W(cs16
->lpszClass
);
1755 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1757 MDICREATESTRUCT16
*mdi_cs16
;
1758 MDICREATESTRUCTW
*mdi_cs
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs
));
1761 HeapFree(GetProcessHeap(), 0, cs
);
1764 mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs16
->lpCreateParams
);
1765 MDICREATESTRUCT16to32A(mdi_cs16
, (MDICREATESTRUCTA
*)mdi_cs
);
1766 mdi_cs
->szTitle
= map_str_16_to_32W(mdi_cs16
->szTitle
);
1767 mdi_cs
->szClass
= map_str_16_to_32W(mdi_cs16
->szClass
);
1769 cs
->lpCreateParams
= mdi_cs
;
1771 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1772 *plparam
= (LPARAM
)cs
;
1777 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1778 MDICREATESTRUCTW
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1780 MDICREATESTRUCT16to32A( cs16
, (MDICREATESTRUCTA
*)cs
);
1781 cs
->szTitle
= map_str_16_to_32W(cs16
->szTitle
);
1782 cs
->szClass
= map_str_16_to_32W(cs16
->szClass
);
1783 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1784 *plparam
= (LPARAM
)cs
;
1790 LPMSG16 msg16
= MapSL(*plparam
);
1791 LPMSG msg32
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1793 if (!msg32
) return -1;
1794 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1795 msg32
->lParam
= msg16
->lParam
;
1796 msg32
->time
= msg16
->time
;
1797 msg32
->pt
.x
= msg16
->pt
.x
;
1798 msg32
->pt
.y
= msg16
->pt
.y
;
1799 /* this is right, right? */
1800 if (WINPROC_MapMsg16To32W(hwnd
, msg16
->message
,msg16
->wParam
,
1801 &msg32
->message
,&msg32
->wParam
,
1802 &msg32
->lParam
)<0) {
1803 HeapFree( GetProcessHeap(), 0, msg32
);
1806 *plparam
= (LPARAM
)msg32
;
1813 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1814 *pwparam32
= MAKEWPARAM( wch
, HIWORD(*plparam
) );
1815 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1819 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1820 *pwparam32
= MAKEWPARAM( wch
, LOWORD(*plparam
) );
1821 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1826 case WM_SYSDEADCHAR
:
1828 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1832 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1834 default: /* No Unicode translation needed */
1835 return WINPROC_MapMsg16To32A( hwnd
, msg16
, wParam16
, pmsg32
,
1836 pwparam32
, plparam
);
1841 /**********************************************************************
1842 * WINPROC_UnmapMsg16To32W
1844 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1846 LRESULT
WINPROC_UnmapMsg16To32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1847 LRESULT result
, WNDPROC dispatch
)
1853 case WM_GETTEXTLENGTH
:
1854 case CB_GETLBTEXTLEN
:
1856 case WM_ASKCBFORMATNAME
:
1857 return WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
, dispatch
);
1861 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
1862 lParam
= *(LPARAM
*)(cs
+ 1);
1863 CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs
, MapSL(lParam
) );
1864 unmap_str_16_to_32W( cs
->lpszName
);
1865 unmap_str_16_to_32W( cs
->lpszClass
);
1867 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1869 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)cs
->lpCreateParams
;
1870 unmap_str_16_to_32W( mdi_cs
->szTitle
);
1871 unmap_str_16_to_32W( mdi_cs
->szClass
);
1872 HeapFree(GetProcessHeap(), 0, cs
->lpCreateParams
);
1874 HeapFree( GetProcessHeap(), 0, cs
);
1879 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
1880 lParam
= *(LPARAM
*)(cs
+ 1);
1881 MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs
, MapSL(lParam
) );
1882 unmap_str_16_to_32W( cs
->szTitle
);
1883 unmap_str_16_to_32W( cs
->szClass
);
1884 HeapFree( GetProcessHeap(), 0, cs
);
1890 LPMSG msg32
= (LPMSG
)lParam
;
1892 WINPROC_UnmapMsg16To32W( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1894 HeapFree( GetProcessHeap(), 0, msg32
);
1898 return WINPROC_UnmapMsg16To32A( hwnd
, msg
, wParam
, lParam
, result
);
1903 static HANDLE16
convert_handle_32_to_16(UINT src
, unsigned int flags
)
1906 UINT sz
= GlobalSize((HANDLE
)src
);
1909 if (!(dst
= GlobalAlloc16(flags
, sz
)))
1911 ptr32
= GlobalLock((HANDLE
)src
);
1912 ptr16
= GlobalLock16(dst
);
1913 if (ptr16
!= NULL
&& ptr32
!= NULL
) memcpy(ptr16
, ptr32
, sz
);
1914 GlobalUnlock((HANDLE
)src
);
1915 GlobalUnlock16(dst
);
1921 /**********************************************************************
1922 * WINPROC_MapMsg32ATo16
1924 * Map a message from 32-bit Ansi to 16-bit.
1925 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1927 INT
WINPROC_MapMsg32ATo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
1928 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
1931 *pmsg16
= (UINT16
)msg32
;
1932 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
1936 *pmsg16
= SBM_SETRANGE16
;
1937 *plparam
= MAKELPARAM(wParam32
, *plparam
);
1942 *pmsg16
= SBM_GETRANGE16
;
1950 *pmsg16
= (UINT16
)msg32
+ (BM_GETCHECK16
- BM_GETCHECK
);
1959 case EM_SCROLLCARET
:
1962 case EM_GETLINECOUNT
:
1974 case EM_LINEFROMCHAR
:
1975 case EM_SETTABSTOPS
:
1976 case EM_SETPASSWORDCHAR
:
1977 case EM_EMPTYUNDOBUFFER
:
1978 case EM_GETFIRSTVISIBLELINE
:
1979 case EM_SETREADONLY
:
1980 case EM_SETWORDBREAKPROC
:
1981 case EM_GETWORDBREAKPROC
:
1982 case EM_GETPASSWORDCHAR
:
1983 *pmsg16
= (UINT16
)msg32
+ (EM_GETSEL16
- EM_GETSEL
);
1988 case LB_DELETESTRING
:
1989 case LB_GETANCHORINDEX
:
1990 case LB_GETCARETINDEX
:
1993 case LB_GETHORIZONTALEXTENT
:
1994 case LB_GETITEMDATA
:
1995 case LB_GETITEMHEIGHT
:
1997 case LB_GETSELCOUNT
:
1999 case LB_GETTOPINDEX
:
2000 case LB_RESETCONTENT
:
2001 case LB_SELITEMRANGE
:
2002 case LB_SELITEMRANGEEX
:
2003 case LB_SETANCHORINDEX
:
2004 case LB_SETCARETINDEX
:
2005 case LB_SETCOLUMNWIDTH
:
2007 case LB_SETHORIZONTALEXTENT
:
2008 case LB_SETITEMDATA
:
2009 case LB_SETITEMHEIGHT
:
2011 case LB_SETTOPINDEX
:
2012 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2014 case CB_DELETESTRING
:
2016 case CB_GETLBTEXTLEN
:
2018 case CB_RESETCONTENT
:
2022 case CB_SHOWDROPDOWN
:
2023 case CB_SETITEMDATA
:
2024 case CB_SETITEMHEIGHT
:
2025 case CB_GETITEMHEIGHT
:
2026 case CB_SETEXTENDEDUI
:
2027 case CB_GETEXTENDEDUI
:
2028 case CB_GETDROPPEDSTATE
:
2029 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
2032 *pmsg16
= CB_GETEDITSEL16
;
2037 case LB_FINDSTRINGEXACT
:
2038 case LB_INSERTSTRING
:
2039 case LB_SELECTSTRING
:
2042 *plparam
= (LPARAM
)MapLS( (LPSTR
)*plparam
);
2043 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2048 case CB_FINDSTRINGEXACT
:
2049 case CB_INSERTSTRING
:
2050 case CB_SELECTSTRING
:
2052 *plparam
= (LPARAM
)MapLS( (LPSTR
)*plparam
);
2053 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
2056 case LB_GETITEMRECT
:
2058 RECT16
*rect
= HeapAlloc( GetProcessHeap(), 0, sizeof(RECT16
) + sizeof(LPARAM
) );
2059 if (!rect
) return -1;
2060 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
2061 *plparam
= MapLS( rect
);
2063 *pmsg16
= LB_GETITEMRECT16
;
2065 case LB_GETSELITEMS
:
2067 LPARAM
*items
; /* old LPARAM first, then *pwparam16 x INT16 entries */
2069 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
2070 if (!(items
= HeapAlloc( GetProcessHeap(), 0,
2071 *pwparam16
* sizeof(INT16
) + sizeof(LPARAM
)))) return -1;
2072 *items
++ = *plparam
; /* Store the previous lParam */
2073 *plparam
= MapLS( items
);
2075 *pmsg16
= LB_GETSELITEMS16
;
2077 case LB_SETTABSTOPS
:
2082 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
2083 if (!(stops
= HeapAlloc( GetProcessHeap(), 0,
2084 *pwparam16
* sizeof(INT16
) + sizeof(LPARAM
)))) return -1;
2085 for (i
= 0; i
< *pwparam16
; i
++) stops
[i
] = *((LPINT
)*plparam
+i
);
2086 *plparam
= MapLS( stops
);
2089 *pmsg16
= LB_SETTABSTOPS16
;
2092 case CB_GETDROPPEDCONTROLRECT
:
2094 RECT16
*rect
= HeapAlloc( GetProcessHeap(), 0, sizeof(RECT16
) + sizeof(LPARAM
) );
2095 if (!rect
) return -1;
2096 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
2097 *plparam
= (LPARAM
)MapLS(rect
);
2099 *pmsg16
= CB_GETDROPPEDCONTROLRECT16
;
2103 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
2104 *pmsg16
= LB_GETTEXT16
;
2108 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
2109 *pmsg16
= CB_GETLBTEXT16
;
2114 *plparam
= MAKELONG( (INT16
)(INT
)wParam32
, (INT16
)*plparam
);
2115 *pmsg16
= EM_SETSEL16
;
2122 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
2126 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HWND16
)*plparam
);
2130 PCOPYDATASTRUCT pcds32
= (PCOPYDATASTRUCT
) *plparam
;
2131 PCOPYDATASTRUCT16 pcds
= HeapAlloc( GetProcessHeap(), 0, sizeof( *pcds
));
2132 pcds
->dwData
= pcds32
->dwData
;
2133 pcds
->cbData
= pcds32
->cbData
;
2134 pcds
->lpData
= MapLS( pcds32
->lpData
);
2135 *plparam
= MapLS( pcds
);
2138 case WM_CTLCOLORMSGBOX
:
2139 case WM_CTLCOLOREDIT
:
2140 case WM_CTLCOLORLISTBOX
:
2141 case WM_CTLCOLORBTN
:
2142 case WM_CTLCOLORDLG
:
2143 case WM_CTLCOLORSCROLLBAR
:
2144 case WM_CTLCOLORSTATIC
:
2145 *pmsg16
= WM_CTLCOLOR
;
2146 *plparam
= MAKELPARAM( (HWND16
)*plparam
,
2147 (WORD
)msg32
- WM_CTLCOLORMSGBOX
);
2149 case WM_COMPAREITEM
:
2151 COMPAREITEMSTRUCT
*cis32
= (COMPAREITEMSTRUCT
*)*plparam
;
2152 COMPAREITEMSTRUCT16
*cis
= HeapAlloc( GetProcessHeap(), 0, sizeof(COMPAREITEMSTRUCT16
));
2153 if (!cis
) return -1;
2154 cis
->CtlType
= (UINT16
)cis32
->CtlType
;
2155 cis
->CtlID
= (UINT16
)cis32
->CtlID
;
2156 cis
->hwndItem
= HWND_16( cis32
->hwndItem
);
2157 cis
->itemID1
= (UINT16
)cis32
->itemID1
;
2158 cis
->itemData1
= cis32
->itemData1
;
2159 cis
->itemID2
= (UINT16
)cis32
->itemID2
;
2160 cis
->itemData2
= cis32
->itemData2
;
2161 *plparam
= MapLS( cis
);
2166 DELETEITEMSTRUCT
*dis32
= (DELETEITEMSTRUCT
*)*plparam
;
2167 DELETEITEMSTRUCT16
*dis
= HeapAlloc( GetProcessHeap(), 0, sizeof(DELETEITEMSTRUCT16
) );
2168 if (!dis
) return -1;
2169 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
2170 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
2171 dis
->itemID
= (UINT16
)dis32
->itemID
;
2172 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND16
)LOWORD(dis32
->hwndItem
)
2173 : HWND_16( dis32
->hwndItem
);
2174 dis
->itemData
= dis32
->itemData
;
2175 *plparam
= MapLS( dis
);
2180 DRAWITEMSTRUCT
*dis32
= (DRAWITEMSTRUCT
*)*plparam
;
2181 DRAWITEMSTRUCT16
*dis
= HeapAlloc( GetProcessHeap(), 0, sizeof(DRAWITEMSTRUCT16
) );
2182 if (!dis
) return -1;
2183 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
2184 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
2185 dis
->itemID
= (UINT16
)dis32
->itemID
;
2186 dis
->itemAction
= (UINT16
)dis32
->itemAction
;
2187 dis
->itemState
= (UINT16
)dis32
->itemState
;
2188 dis
->hwndItem
= HWND_16( dis32
->hwndItem
);
2189 dis
->hDC
= HDC_16(dis32
->hDC
);
2190 dis
->itemData
= dis32
->itemData
;
2191 dis
->rcItem
.left
= dis32
->rcItem
.left
;
2192 dis
->rcItem
.top
= dis32
->rcItem
.top
;
2193 dis
->rcItem
.right
= dis32
->rcItem
.right
;
2194 dis
->rcItem
.bottom
= dis32
->rcItem
.bottom
;
2195 *plparam
= MapLS( dis
);
2198 case WM_MEASUREITEM
:
2200 MEASUREITEMSTRUCT
*mis32
= (MEASUREITEMSTRUCT
*)*plparam
;
2201 MEASUREITEMSTRUCT16
*mis
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mis
)+sizeof(LPARAM
));
2202 if (!mis
) return -1;
2203 mis
->CtlType
= (UINT16
)mis32
->CtlType
;
2204 mis
->CtlID
= (UINT16
)mis32
->CtlID
;
2205 mis
->itemID
= (UINT16
)mis32
->itemID
;
2206 mis
->itemWidth
= (UINT16
)mis32
->itemWidth
;
2207 mis
->itemHeight
= (UINT16
)mis32
->itemHeight
;
2208 mis
->itemData
= mis32
->itemData
;
2209 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
2210 *plparam
= MapLS( mis
);
2213 case WM_GETMINMAXINFO
:
2215 MINMAXINFO16
*mmi
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mmi
) + sizeof(LPARAM
) );
2216 if (!mmi
) return -1;
2217 MINMAXINFO32to16( (MINMAXINFO
*)*plparam
, mmi
);
2218 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
2219 *plparam
= MapLS( mmi
);
2223 case WM_ASKCBFORMATNAME
:
2225 LPARAM
*str
; /* store LPARAM, then *pwparam16 char space */
2226 *pwparam16
= (WPARAM16
)min( wParam32
, 0xff80 ); /* Must be < 64K */
2227 if (!(str
= HeapAlloc( GetProcessHeap(), 0, *pwparam16
+ sizeof(LPARAM
)))) return -1;
2228 *str
++ = *plparam
; /* Store the previous lParam */
2229 *plparam
= MapLS( str
);
2234 MDICREATESTRUCT16
*cs
;
2235 MDICREATESTRUCTA
*cs32
= (MDICREATESTRUCTA
*)*plparam
;
2237 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16
) ))) return -1;
2238 MDICREATESTRUCT32Ato16( cs32
, cs
);
2239 cs
->szTitle
= MapLS( cs32
->szTitle
);
2240 cs
->szClass
= MapLS( cs32
->szClass
);
2241 *plparam
= MapLS( cs
);
2244 case WM_MDIGETACTIVE
:
2247 *plparam
= MAKELPARAM( (HMENU16
)LOWORD(wParam32
),
2248 (HMENU16
)LOWORD(*plparam
) );
2249 *pwparam16
= (*plparam
== 0);
2252 if(HIWORD(wParam32
) & MF_POPUP
)
2255 if (((UINT
)HIWORD(wParam32
) != 0xFFFF) || (*plparam
))
2257 if((hmenu
= GetSubMenu((HMENU
)*plparam
, *pwparam16
)))
2258 *pwparam16
=HMENU_16(hmenu
);
2263 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2265 case WM_MDIACTIVATE
:
2266 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2268 *pwparam16
= ((HWND
)*plparam
== hwnd
);
2269 *plparam
= MAKELPARAM( (HWND16
)LOWORD(*plparam
),
2270 (HWND16
)LOWORD(wParam32
) );
2274 *pwparam16
= HWND_16( (HWND
)wParam32
);
2280 NCCALCSIZE_PARAMS
*nc32
= (NCCALCSIZE_PARAMS
*)*plparam
;
2281 NCCALCSIZE_PARAMS16
*nc
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
) + sizeof(LPARAM
));
2284 nc
->rgrc
[0].left
= nc32
->rgrc
[0].left
;
2285 nc
->rgrc
[0].top
= nc32
->rgrc
[0].top
;
2286 nc
->rgrc
[0].right
= nc32
->rgrc
[0].right
;
2287 nc
->rgrc
[0].bottom
= nc32
->rgrc
[0].bottom
;
2291 nc
->rgrc
[1].left
= nc32
->rgrc
[1].left
;
2292 nc
->rgrc
[1].top
= nc32
->rgrc
[1].top
;
2293 nc
->rgrc
[1].right
= nc32
->rgrc
[1].right
;
2294 nc
->rgrc
[1].bottom
= nc32
->rgrc
[1].bottom
;
2295 nc
->rgrc
[2].left
= nc32
->rgrc
[2].left
;
2296 nc
->rgrc
[2].top
= nc32
->rgrc
[2].top
;
2297 nc
->rgrc
[2].right
= nc32
->rgrc
[2].right
;
2298 nc
->rgrc
[2].bottom
= nc32
->rgrc
[2].bottom
;
2299 if (!(wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(WINDOWPOS16
) )))
2301 HeapFree( GetProcessHeap(), 0, nc
);
2304 WINDOWPOS32to16( nc32
->lppos
, wp
);
2305 nc
->lppos
= MapLS( wp
);
2307 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
2308 *plparam
= MapLS( nc
);
2315 CREATESTRUCTA
*cs32
= (CREATESTRUCTA
*)*plparam
;
2317 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16
) ))) return -1;
2318 CREATESTRUCT32Ato16( cs32
, cs
);
2319 cs
->lpszName
= MapLS( cs32
->lpszName
);
2320 cs
->lpszClass
= MapLS( cs32
->lpszClass
);
2322 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2324 MDICREATESTRUCT16
*mdi_cs16
;
2325 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)cs32
->lpCreateParams
;
2326 mdi_cs16
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs16
));
2329 HeapFree(GetProcessHeap(), 0, cs
);
2332 MDICREATESTRUCT32Ato16(mdi_cs
, mdi_cs16
);
2333 mdi_cs16
->szTitle
= MapLS( mdi_cs
->szTitle
);
2334 mdi_cs16
->szClass
= MapLS( mdi_cs
->szClass
);
2335 cs
->lpCreateParams
= MapLS( mdi_cs16
);
2337 *plparam
= MapLS( cs
);
2340 case WM_PARENTNOTIFY
:
2341 if ((LOWORD(wParam32
)==WM_CREATE
) || (LOWORD(wParam32
)==WM_DESTROY
))
2342 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
));
2343 /* else nothing to do */
2346 *plparam
= MapLS( (NMHDR
*)*plparam
); /* NMHDR is already 32-bit */
2349 case WM_WININICHANGE
:
2350 case WM_DEVMODECHANGE
:
2351 *plparam
= MapLS( (LPSTR
)*plparam
);
2353 case WM_WINDOWPOSCHANGING
:
2354 case WM_WINDOWPOSCHANGED
:
2356 WINDOWPOS16
*wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*wp
) + sizeof(LPARAM
) );
2358 WINDOWPOS32to16( (WINDOWPOS
*)*plparam
, wp
);
2359 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
2360 *plparam
= MapLS( wp
);
2365 LPMSG msg32
= (LPMSG
) *plparam
;
2366 LPMSG16 msg16
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG16
) );
2368 if (!msg16
) return -1;
2369 msg16
->hwnd
= HWND_16( msg32
->hwnd
);
2370 msg16
->lParam
= msg32
->lParam
;
2371 msg16
->time
= msg32
->time
;
2372 msg16
->pt
.x
= msg32
->pt
.x
;
2373 msg16
->pt
.y
= msg32
->pt
.y
;
2374 /* this is right, right? */
2375 if (WINPROC_MapMsg32ATo16(msg32
->hwnd
,msg32
->message
,msg32
->wParam
,
2376 &msg16
->message
,&msg16
->wParam
, &msg16
->lParam
)<0)
2378 HeapFree( GetProcessHeap(), 0, msg16
);
2381 *plparam
= MapLS( msg16
);
2386 case WM_ACTIVATEAPP
:
2387 if (*plparam
) *plparam
= HTASK_16( (HANDLE
)*plparam
);
2391 MDINEXTMENU
*next
= (MDINEXTMENU
*)*plparam
;
2392 *plparam
= (LPARAM
)next
->hmenuIn
;
2396 if (IsIconic( hwnd
) && GetClassLongPtrW( hwnd
, GCLP_HICON
))
2398 *pmsg16
= WM_PAINTICON
;
2403 if (IsIconic( hwnd
) && GetClassLongPtrW( hwnd
, GCLP_HICON
))
2404 *pmsg16
= WM_ICONERASEBKGND
;
2406 case WM_PAINTCLIPBOARD
:
2407 case WM_SIZECLIPBOARD
:
2408 FIXME_(msg
)("message %04x needs translation\n", msg32
);
2410 /* following messages should not be sent to 16-bit apps */
2413 case WM_CAPTURECHANGED
:
2414 case WM_STYLECHANGING
:
2415 case WM_STYLECHANGED
:
2417 case WM_DDE_INITIATE
:
2418 case WM_DDE_TERMINATE
:
2419 case WM_DDE_UNADVISE
:
2420 case WM_DDE_REQUEST
:
2421 *pwparam16
= HWND_16((HWND
)wParam32
);
2430 *pwparam16
= HWND_16((HWND
)wParam32
);
2431 UnpackDDElParam(msg32
, *plparam
, &lo32
, &hi
);
2432 if (lo32
&& !(lo16
= convert_handle_32_to_16(lo32
, GMEM_DDESHARE
)))
2434 *plparam
= MAKELPARAM(lo16
, hi
);
2436 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2443 *pwparam16
= HWND_16((HWND
)wParam32
);
2445 UnpackDDElParam(msg32
, *plparam
, &lo
, &hi
);
2447 if (GlobalGetAtomNameA((ATOM
)hi
, buf
, sizeof(buf
)) > 0) flag
|= 1;
2448 if (GlobalSize((HANDLE
)hi
) != 0) flag
|= 2;
2454 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
2459 break; /* atom, nothing to do */
2461 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi
);
2464 hi
= convert_handle_32_to_16(hi
, GMEM_DDESHARE
);
2467 *plparam
= MAKELPARAM(lo
, hi
);
2469 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2470 case WM_DDE_EXECUTE
:
2471 *plparam
= convert_handle_32_to_16(*plparam
, GMEM_DDESHARE
);
2472 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2473 default: /* No translation needed */
2479 /**********************************************************************
2480 * WINPROC_UnmapMsg32ATo16
2482 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
2484 void WINPROC_UnmapMsg32ATo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2490 *(LPINT
)wParam
= LOWORD(p16
->lResult
);
2491 *(LPINT
)lParam
= HIWORD(p16
->lResult
);
2498 case LB_FINDSTRINGEXACT
:
2499 case LB_INSERTSTRING
:
2500 case LB_SELECTSTRING
:
2504 case CB_FINDSTRINGEXACT
:
2505 case CB_INSERTSTRING
:
2506 case CB_SELECTSTRING
:
2510 case WM_WININICHANGE
:
2511 case WM_DEVMODECHANGE
:
2512 UnMapLS( (SEGPTR
)p16
->lParam
);
2514 case LB_SETTABSTOPS
:
2515 case WM_COMPAREITEM
:
2519 void *ptr
= MapSL( p16
->lParam
);
2520 UnMapLS( p16
->lParam
);
2521 HeapFree( GetProcessHeap(), 0, ptr
);
2526 PCOPYDATASTRUCT16 pcds
= MapSL( p16
->lParam
);
2527 UnMapLS( p16
->lParam
);
2528 UnMapLS( pcds
->lpData
);
2529 HeapFree( GetProcessHeap(), 0, pcds
);
2532 case CB_GETDROPPEDCONTROLRECT
:
2533 case LB_GETITEMRECT
:
2536 RECT16
*rect
= MapSL(p16
->lParam
);
2537 UnMapLS( p16
->lParam
);
2538 p16
->lParam
= *(LPARAM
*)(rect
+ 1);
2539 r32
= (RECT
*)p16
->lParam
;
2540 r32
->left
= rect
->left
;
2541 r32
->top
= rect
->top
;
2542 r32
->right
= rect
->right
;
2543 r32
->bottom
= rect
->bottom
;
2544 HeapFree( GetProcessHeap(), 0, rect
);
2547 case LB_GETSELITEMS
:
2550 LPINT16 items
= MapSL(p16
->lParam
);
2551 UnMapLS( p16
->lParam
);
2552 p16
->lParam
= *((LPARAM
*)items
- 1);
2553 for (i
= 0; i
< p16
->wParam
; i
++) *((LPINT
)(p16
->lParam
) + i
) = items
[i
];
2554 HeapFree( GetProcessHeap(), 0, (LPARAM
*)items
- 1 );
2560 *((PUINT
)(wParam
)) = LOWORD(p16
->lResult
);
2562 *((PUINT
)(lParam
)) = HIWORD(p16
->lResult
); /* FIXME: substract 1? */
2565 case WM_MEASUREITEM
:
2567 MEASUREITEMSTRUCT16
*mis
= MapSL(p16
->lParam
);
2568 MEASUREITEMSTRUCT
*mis32
= *(MEASUREITEMSTRUCT
**)(mis
+ 1);
2569 mis32
->itemWidth
= mis
->itemWidth
;
2570 mis32
->itemHeight
= mis
->itemHeight
;
2571 UnMapLS( p16
->lParam
);
2572 HeapFree( GetProcessHeap(), 0, mis
);
2575 case WM_GETMINMAXINFO
:
2577 MINMAXINFO16
*mmi
= MapSL(p16
->lParam
);
2578 UnMapLS( p16
->lParam
);
2579 p16
->lParam
= *(LPARAM
*)(mmi
+ 1);
2580 MINMAXINFO16to32( mmi
, (MINMAXINFO
*)(p16
->lParam
) );
2581 HeapFree( GetProcessHeap(), 0, mmi
);
2585 case WM_ASKCBFORMATNAME
:
2587 LPSTR str
= MapSL(p16
->lParam
);
2588 UnMapLS( p16
->lParam
);
2589 p16
->lParam
= *((LPARAM
*)str
- 1);
2590 lstrcpynA( (LPSTR
)(p16
->lParam
), str
, p16
->wParam
);
2591 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
- 1 );
2596 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2597 UnMapLS( cs
->szTitle
);
2598 UnMapLS( cs
->szClass
);
2599 UnMapLS( p16
->lParam
);
2600 HeapFree( GetProcessHeap(), 0, cs
);
2603 case WM_MDIGETACTIVE
:
2604 if (lParam
) *(BOOL
*)lParam
= (BOOL16
)HIWORD(p16
->lResult
);
2605 p16
->lResult
= (LRESULT
)WIN_Handle32( LOWORD(p16
->lResult
) );
2609 NCCALCSIZE_PARAMS
*nc32
;
2610 NCCALCSIZE_PARAMS16
*nc
= MapSL(p16
->lParam
);
2611 UnMapLS( p16
->lParam
);
2612 p16
->lParam
= *(LPARAM
*)(nc
+ 1);
2613 nc32
= (NCCALCSIZE_PARAMS
*)(p16
->lParam
);
2614 nc32
->rgrc
[0].left
= nc
->rgrc
[0].left
;
2615 nc32
->rgrc
[0].top
= nc
->rgrc
[0].top
;
2616 nc32
->rgrc
[0].right
= nc
->rgrc
[0].right
;
2617 nc32
->rgrc
[0].bottom
= nc
->rgrc
[0].bottom
;
2620 WINDOWPOS16
*pos
= MapSL(nc
->lppos
);
2621 UnMapLS( nc
->lppos
);
2622 nc32
->rgrc
[1].left
= nc
->rgrc
[1].left
;
2623 nc32
->rgrc
[1].top
= nc
->rgrc
[1].top
;
2624 nc32
->rgrc
[1].right
= nc
->rgrc
[1].right
;
2625 nc32
->rgrc
[1].bottom
= nc
->rgrc
[1].bottom
;
2626 nc32
->rgrc
[2].left
= nc
->rgrc
[2].left
;
2627 nc32
->rgrc
[2].top
= nc
->rgrc
[2].top
;
2628 nc32
->rgrc
[2].right
= nc
->rgrc
[2].right
;
2629 nc32
->rgrc
[2].bottom
= nc
->rgrc
[2].bottom
;
2630 WINDOWPOS16to32( pos
, nc32
->lppos
);
2631 HeapFree( GetProcessHeap(), 0, pos
);
2633 HeapFree( GetProcessHeap(), 0, nc
);
2639 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2640 UnMapLS( p16
->lParam
);
2641 UnMapLS( cs
->lpszName
);
2642 UnMapLS( cs
->lpszClass
);
2643 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2645 MDICREATESTRUCT16
*mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs
->lpCreateParams
);
2646 UnMapLS( cs
->lpCreateParams
);
2647 UnMapLS( mdi_cs16
->szTitle
);
2648 UnMapLS( mdi_cs16
->szClass
);
2649 HeapFree(GetProcessHeap(), 0, mdi_cs16
);
2651 HeapFree( GetProcessHeap(), 0, cs
);
2654 case WM_WINDOWPOSCHANGING
:
2655 case WM_WINDOWPOSCHANGED
:
2657 WINDOWPOS16
*wp
= MapSL(p16
->lParam
);
2658 UnMapLS( p16
->lParam
);
2659 p16
->lParam
= *(LPARAM
*)(wp
+ 1);
2660 WINDOWPOS16to32( wp
, (WINDOWPOS
*)p16
->lParam
);
2661 HeapFree( GetProcessHeap(), 0, wp
);
2665 UnMapLS(p16
->lParam
);
2670 LPMSG16 msg16
= MapSL(p16
->lParam
);
2672 UnMapLS( p16
->lParam
);
2673 msgp16
.wParam
=msg16
->wParam
;
2674 msgp16
.lParam
=msg16
->lParam
;
2675 WINPROC_UnmapMsg32ATo16(((LPMSG
)lParam
)->hwnd
, ((LPMSG
)lParam
)->message
,
2676 ((LPMSG
)lParam
)->wParam
, ((LPMSG
)lParam
)->lParam
,
2678 HeapFree( GetProcessHeap(), 0, msg16
);
2683 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
2684 next
->hmenuNext
= HMENU_32( LOWORD(p16
->lResult
) );
2685 next
->hwndNext
= WIN_Handle32( HIWORD(p16
->lResult
) );
2693 /**********************************************************************
2694 * WINPROC_MapMsg32WTo16
2696 * Map a message from 32-bit Unicode to 16-bit.
2697 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
2699 INT
WINPROC_MapMsg32WTo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
2700 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
2706 *pmsg16
= LOWORD(msg32
);
2707 *pwparam16
= LOWORD(wParam32
);
2712 case LB_FINDSTRINGEXACT
:
2713 case LB_INSERTSTRING
:
2714 case LB_SELECTSTRING
:
2717 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2718 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2723 case CB_FINDSTRINGEXACT
:
2724 case CB_INSERTSTRING
:
2725 case CB_SELECTSTRING
:
2727 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2728 *pmsg16
= (UINT16
)msg32
+ (CB_ADDSTRING16
- CB_ADDSTRING
);
2735 CREATESTRUCTW
*cs32
= (CREATESTRUCTW
*)*plparam
;
2737 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16
) ))) return -1;
2738 CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs32
, cs
);
2739 cs
->lpszName
= map_str_32W_to_16( cs32
->lpszName
);
2740 cs
->lpszClass
= map_str_32W_to_16( cs32
->lpszClass
);
2742 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2744 MDICREATESTRUCT16
*mdi_cs16
;
2745 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)cs32
->lpCreateParams
;
2746 mdi_cs16
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs16
));
2749 HeapFree(GetProcessHeap(), 0, cs
);
2752 MDICREATESTRUCT32Ato16((MDICREATESTRUCTA
*)mdi_cs
, mdi_cs16
);
2753 mdi_cs16
->szTitle
= map_str_32W_to_16(mdi_cs
->szTitle
);
2754 mdi_cs16
->szClass
= map_str_32W_to_16(mdi_cs
->szClass
);
2755 cs
->lpCreateParams
= MapLS(mdi_cs16
);
2757 *plparam
= MapLS(cs
);
2762 MDICREATESTRUCT16
*cs
;
2763 MDICREATESTRUCTW
*cs32
= (MDICREATESTRUCTW
*)*plparam
;
2765 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16
) ))) return -1;
2766 MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs32
, cs
);
2767 cs
->szTitle
= map_str_32W_to_16( cs32
->szTitle
);
2768 cs
->szClass
= map_str_32W_to_16( cs32
->szClass
);
2769 *plparam
= MapLS(cs
);
2773 case WM_WININICHANGE
:
2774 case WM_DEVMODECHANGE
:
2775 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2778 if ( WINPROC_TestLBForStr( hwnd
))
2780 LPSTR str
= HeapAlloc( GetProcessHeap(), 0, 512 ); /* FIXME: fixed sized buffer */
2781 if (!str
) return -1;
2782 *pmsg16
= LB_GETTEXT16
;
2783 *plparam
= (LPARAM
)MapLS(str
);
2787 if ( WINPROC_TestCBForStr( hwnd
))
2789 LPSTR str
= HeapAlloc( GetProcessHeap(), 0, 512 ); /* FIXME: fixed sized buffer */
2790 if (!str
) return -1;
2791 *pmsg16
= CB_GETLBTEXT16
;
2792 *plparam
= (LPARAM
)MapLS(str
);
2797 wch
= LOWORD(wParam32
);
2798 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2800 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
2803 wch
= LOWORD(wParam32
);
2804 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2806 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2811 case WM_SYSDEADCHAR
:
2813 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2821 if (WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)ch
, 2, NULL
, NULL
) == 2)
2822 *pwparam16
= (ch
[0] << 8) | ch
[1];
2828 default: /* No Unicode translation needed (?) */
2829 return WINPROC_MapMsg32ATo16( hwnd
, msg32
, wParam32
, pmsg16
,
2830 pwparam16
, plparam
);
2835 /**********************************************************************
2836 * WINPROC_UnmapMsg32WTo16
2838 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2840 void WINPROC_UnmapMsg32WTo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2847 case LB_FINDSTRINGEXACT
:
2848 case LB_INSERTSTRING
:
2849 case LB_SELECTSTRING
:
2854 case CB_FINDSTRINGEXACT
:
2855 case CB_INSERTSTRING
:
2856 case CB_SELECTSTRING
:
2859 case WM_WININICHANGE
:
2860 case WM_DEVMODECHANGE
:
2861 unmap_str_32W_to_16( p16
->lParam
);
2866 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2867 UnMapLS( p16
->lParam
);
2868 unmap_str_32W_to_16( cs
->lpszName
);
2869 unmap_str_32W_to_16( cs
->lpszClass
);
2871 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2873 MDICREATESTRUCT16
*mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs
->lpCreateParams
);
2874 UnMapLS( cs
->lpCreateParams
);
2875 unmap_str_32W_to_16(mdi_cs16
->szTitle
);
2876 unmap_str_32W_to_16(mdi_cs16
->szClass
);
2877 HeapFree(GetProcessHeap(), 0, mdi_cs16
);
2879 HeapFree( GetProcessHeap(), 0, cs
);
2884 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2885 UnMapLS( p16
->lParam
);
2886 unmap_str_32W_to_16( cs
->szTitle
);
2887 unmap_str_32W_to_16( cs
->szClass
);
2888 HeapFree( GetProcessHeap(), 0, cs
);
2892 case WM_ASKCBFORMATNAME
:
2894 LPSTR str
= MapSL(p16
->lParam
);
2895 UnMapLS( p16
->lParam
);
2896 p16
->lParam
= *((LPARAM
*)str
- 1);
2897 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)p16
->lParam
, 0x7fffffff );
2898 p16
->lResult
= strlenW( (LPWSTR
)p16
->lParam
);
2899 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
- 1 );
2903 if ( WINPROC_TestLBForStr( hwnd
))
2905 LPSTR str
= MapSL(p16
->lParam
);
2906 UnMapLS( p16
->lParam
);
2907 p16
->lResult
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff ) - 1;
2908 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
);
2912 if ( WINPROC_TestCBForStr( hwnd
))
2914 LPSTR str
= MapSL(p16
->lParam
);
2915 UnMapLS( p16
->lParam
);
2916 p16
->lResult
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff ) - 1;
2917 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
);
2921 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, p16
);
2927 /**********************************************************************
2928 * WINPROC_CallProc32ATo32W
2930 * Call a window procedure, translating args from Ansi to Unicode.
2932 static LRESULT
WINPROC_CallProc32ATo32W( WNDPROC func
, HWND hwnd
, UINT msg
, WPARAM wParam
,
2933 LPARAM lParam
, BOOL dialog
)
2938 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2939 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2941 if( (unmap
= WINPROC_MapMsg32ATo32W( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
2942 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
2943 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2946 ret
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2951 LRESULT result
= GetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
);
2952 result
= WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
, NULL
);
2953 SetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
, result
);
2955 else ret
= WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, ret
, func
);
2961 static inline void *get_buffer( void *static_buffer
, size_t size
, size_t need
)
2963 if (size
>= need
) return static_buffer
;
2964 return HeapAlloc( GetProcessHeap(), 0, need
);
2967 static inline void free_buffer( void *static_buffer
, void *buffer
)
2969 if (buffer
!= static_buffer
) HeapFree( GetProcessHeap(), 0, buffer
);
2972 /**********************************************************************
2973 * WINPROC_CallProc32WTo32A
2975 * Call a window procedure, translating args from Unicode to Ansi.
2977 static LRESULT
WINPROC_CallProc32WTo32A( WNDPROC func
, HWND hwnd
, UINT msg
, WPARAM wParam
,
2978 LPARAM lParam
, BOOL dialog
)
2983 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2984 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2990 { /* csW->lpszName and csW->lpszClass are NOT supposed to be atoms
2993 char buffer
[1024], *cls
, *name
;
2994 CREATESTRUCTW
*csW
= (CREATESTRUCTW
*)lParam
;
2995 CREATESTRUCTA csA
= *(CREATESTRUCTA
*)csW
;
2996 MDICREATESTRUCTA mdi_cs
;
2997 DWORD name_lenA
, name_lenW
, class_lenA
, class_lenW
;
2999 class_lenW
= strlenW(csW
->lpszClass
) * sizeof(WCHAR
);
3000 RtlUnicodeToMultiByteSize(&class_lenA
, csW
->lpszClass
, class_lenW
);
3004 name_lenW
= strlenW(csW
->lpszName
) * sizeof(WCHAR
);
3005 RtlUnicodeToMultiByteSize(&name_lenA
, csW
->lpszName
, name_lenW
);
3008 name_lenW
= name_lenA
= 0;
3010 if (!(cls
= get_buffer( buffer
, sizeof(buffer
), class_lenA
+ name_lenA
+ 2 ))) break;
3012 RtlUnicodeToMultiByteN(cls
, class_lenA
, NULL
, csW
->lpszClass
, class_lenW
);
3013 cls
[class_lenA
] = 0;
3014 csA
.lpszClass
= cls
;
3018 name
= cls
+ class_lenA
+ 1;
3019 RtlUnicodeToMultiByteN(name
, name_lenA
, NULL
, csW
->lpszName
, name_lenW
);
3020 name
[name_lenA
] = 0;
3021 csA
.lpszName
= name
;
3024 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
3026 mdi_cs
= *(MDICREATESTRUCTA
*)csW
->lpCreateParams
;
3027 mdi_cs
.szTitle
= csA
.lpszName
;
3028 mdi_cs
.szClass
= csA
.lpszClass
;
3029 csA
.lpCreateParams
= &mdi_cs
;
3032 ret
= WINPROC_CallWndProc(func
, hwnd
, msg
, wParam
, (LPARAM
)&csA
);
3033 free_buffer( buffer
, cls
);
3038 case WM_ASKCBFORMATNAME
:
3040 char *ptr
, buffer
[512];
3041 DWORD len
= wParam
* 2;
3043 if (!(ptr
= get_buffer( buffer
, sizeof(buffer
), len
))) break;
3044 ret
= WINPROC_CallWndProc( func
, hwnd
, msg
, len
, (LPARAM
)ptr
);
3047 RtlMultiByteToUnicodeN( (LPWSTR
)lParam
, wParam
*sizeof(WCHAR
), &len
, ptr
, strlen(ptr
)+1 );
3048 ret
= len
/sizeof(WCHAR
) - 1; /* do not count terminating null */
3049 ((LPWSTR
)lParam
)[ret
] = 0;
3052 SetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
, ret
);
3056 free_buffer( buffer
, ptr
);
3061 if ((unmap
= WINPROC_MapMsg32WTo32A( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
3062 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
3063 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3066 ret
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3070 LRESULT result
= GetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
);
3071 result
= WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
, result
);
3072 SetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
, result
);
3074 else ret
= WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
, ret
);
3082 /**********************************************************************
3083 * WINPROC_CallProc16To32A
3085 static LRESULT
WINPROC_CallProc16To32A( WNDPROC func
, HWND16 hwnd
, UINT16 msg
,
3086 WPARAM16 wParam
, LPARAM lParam
, BOOL dialog
)
3091 HWND hwnd32
= WIN_Handle32( hwnd
);
3093 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3094 func
, hwnd32
, SPY_GetMsgName(msg
, hwnd32
), wParam
, lParam
);
3096 if (WINPROC_MapMsg16To32A( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
3098 ret
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
3101 LRESULT result
= GetWindowLongPtrW( hwnd32
, DWLP_MSGRESULT
);
3102 result
= WINPROC_UnmapMsg16To32A( hwnd32
, msg32
, wParam32
, lParam
, result
);
3103 SetWindowLongPtrW( hwnd32
, DWLP_MSGRESULT
, result
);
3105 else ret
= WINPROC_UnmapMsg16To32A( hwnd32
, msg32
, wParam32
, lParam
, ret
);
3111 /**********************************************************************
3112 * WINPROC_CallProc16To32W
3114 static LRESULT
WINPROC_CallProc16To32W( WNDPROC func
, HWND16 hwnd
, UINT16 msg
,
3115 WPARAM16 wParam
, LPARAM lParam
, BOOL dialog
)
3120 HWND hwnd32
= WIN_Handle32( hwnd
);
3122 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3123 func
, hwnd32
, SPY_GetMsgName(msg
, hwnd32
), wParam
, lParam
);
3125 if (WINPROC_MapMsg16To32W( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
3128 ret
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
3131 LRESULT result
= GetWindowLongPtrW( hwnd32
, DWLP_MSGRESULT
);
3132 result
= WINPROC_UnmapMsg16To32W( hwnd32
, msg32
, wParam32
, lParam
, result
, NULL
);
3133 SetWindowLongPtrW( hwnd32
, DWLP_MSGRESULT
, result
);
3135 else ret
= WINPROC_UnmapMsg16To32W( hwnd32
, msg32
, wParam32
, lParam
, ret
, func
);
3141 /**********************************************************************
3142 * __wine_call_wndproc (USER.1010)
3144 LRESULT WINAPI
__wine_call_wndproc( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
,
3147 if (proc
->procA
) return WINPROC_CallProc16To32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
, FALSE
);
3148 else return WINPROC_CallProc16To32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
, FALSE
);
3152 /**********************************************************************
3153 * WINPROC_CallProc32ATo16
3155 * Call a 16-bit window procedure, translating the 32-bit args.
3157 static LRESULT
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
, UINT msg
,
3158 WPARAM wParam
, LPARAM lParam
, BOOL dialog
)
3164 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3165 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3167 mp16
.lParam
= lParam
;
3168 if (WINPROC_MapMsg32ATo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
3170 ret
= WINPROC_CallWndProc16( func
, HWND_16(hwnd
), msg16
, mp16
.wParam
, mp16
.lParam
);
3173 mp16
.lResult
= GetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
);
3174 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3175 SetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
, mp16
.lResult
);
3181 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3188 /**********************************************************************
3189 * WINPROC_CallProc32WTo16
3191 * Call a 16-bit window procedure, translating the 32-bit args.
3193 static LRESULT
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
, UINT msg
,
3194 WPARAM wParam
, LPARAM lParam
, BOOL dialog
)
3200 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3201 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3203 mp16
.lParam
= lParam
;
3204 if (WINPROC_MapMsg32WTo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
3206 ret
= WINPROC_CallWndProc16( func
, HWND_16(hwnd
), msg16
, mp16
.wParam
, mp16
.lParam
);
3209 mp16
.lResult
= GetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
);
3210 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3211 SetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
, mp16
.lResult
);
3217 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3224 /**********************************************************************
3225 * CallWindowProc (USER.122)
3227 LRESULT WINAPI
CallWindowProc16( WNDPROC16 func
, HWND16 hwnd
, UINT16 msg
,
3228 WPARAM16 wParam
, LPARAM lParam
)
3232 if (!func
) return 0;
3234 if (!(proc
= handle16_to_proc( func
)))
3235 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
3237 if (proc
->procA
) return WINPROC_CallProc16To32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
, FALSE
);
3238 if (proc
->procW
) return WINPROC_CallProc16To32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
, FALSE
);
3239 return WINPROC_CallWndProc16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
);
3243 /**********************************************************************
3244 * CallWindowProcA (USER32.@)
3246 * The CallWindowProc() function invokes the windows procedure _func_,
3247 * with _hwnd_ as the target window, the message specified by _msg_, and
3248 * the message parameters _wParam_ and _lParam_.
3250 * Some kinds of argument conversion may be done, I'm not sure what.
3252 * CallWindowProc() may be used for windows subclassing. Use
3253 * SetWindowLong() to set a new windows procedure for windows of the
3254 * subclass, and handle subclassed messages in the new windows
3255 * procedure. The new windows procedure may then use CallWindowProc()
3256 * with _func_ set to the parent class's windows procedure to dispatch
3257 * the message to the superclass.
3261 * The return value is message dependent.
3267 LRESULT WINAPI
CallWindowProcA(
3268 WNDPROC func
, /* [in] window procedure */
3269 HWND hwnd
, /* [in] target window */
3270 UINT msg
, /* [in] message */
3271 WPARAM wParam
, /* [in] message dependent parameter */
3272 LPARAM lParam
/* [in] message dependent parameter */
3276 if (!func
) return 0;
3278 if (!(proc
= handle_to_proc( func
)))
3279 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3281 if (proc
->procA
) return WINPROC_CallWndProc( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3282 if (proc
->procW
) return WINPROC_CallProc32ATo32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
, FALSE
);
3283 return WINPROC_CallProc32ATo16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
, FALSE
);
3287 /**********************************************************************
3288 * CallWindowProcW (USER32.@)
3290 * See CallWindowProcA.
3292 LRESULT WINAPI
CallWindowProcW( WNDPROC func
, HWND hwnd
, UINT msg
,
3293 WPARAM wParam
, LPARAM lParam
)
3297 if (!func
) return 0;
3299 if (!(proc
= handle_to_proc( func
)))
3300 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3302 if (proc
->procW
) return WINPROC_CallWndProc( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3303 if (proc
->procA
) return WINPROC_CallProc32WTo32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
, FALSE
);
3304 return WINPROC_CallProc32WTo16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
, FALSE
);
3308 /**********************************************************************
3309 * WINPROC_CallDlgProc16
3311 INT_PTR
WINPROC_CallDlgProc16( DLGPROC16 func
, HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
)
3315 if (!func
) return 0;
3317 if (!(proc
= handle16_to_proc( (WNDPROC16
)func
)))
3318 return LOWORD( WINPROC_CallWndProc16( (WNDPROC16
)func
, hwnd
, msg
, wParam
, lParam
) );
3320 if (proc
->procA
) return WINPROC_CallProc16To32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
, TRUE
);
3321 if (proc
->procW
) return WINPROC_CallProc16To32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
, TRUE
);
3322 return LOWORD( WINPROC_CallWndProc16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
) );
3326 /**********************************************************************
3327 * WINPROC_CallDlgProcA
3329 INT_PTR
WINPROC_CallDlgProcA( DLGPROC func
, HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3333 if (!func
) return 0;
3335 if (!(proc
= handle_to_proc( (WNDPROC
)func
)))
3336 return WINPROC_CallWndProc( (WNDPROC
)func
, hwnd
, msg
, wParam
, lParam
);
3338 if (proc
->procA
) return WINPROC_CallWndProc( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3339 if (proc
->procW
) return WINPROC_CallProc32ATo32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
, TRUE
);
3340 return WINPROC_CallProc32ATo16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
, TRUE
);
3344 /**********************************************************************
3345 * WINPROC_CallDlgProcW
3347 INT_PTR
WINPROC_CallDlgProcW( DLGPROC func
, HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3351 if (!func
) return 0;
3353 if (!(proc
= handle_to_proc( (WNDPROC
)func
)))
3354 return WINPROC_CallWndProc( (WNDPROC
)func
, hwnd
, msg
, wParam
, lParam
);
3356 if (proc
->procW
) return WINPROC_CallWndProc( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3357 if (proc
->procA
) return WINPROC_CallProc32WTo32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
, TRUE
);
3358 return WINPROC_CallProc32WTo16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
, TRUE
);