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_ASKCBFORMATNAME
:
998 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, *pwparam
+ sizeof(LPARAM
) );
1000 *ptr
++ = *plparam
; /* Store previous lParam */
1001 *plparam
= (LPARAM
)ptr
;
1006 case WM_WININICHANGE
:
1007 case WM_DEVMODECHANGE
:
1014 LPCWSTR str
= (LPCWSTR
)*plparam
;
1015 int len
= WideCharToMultiByte(CP_ACP
, 0, str
, -1, NULL
, 0, 0, 0);
1016 *plparam
= (LPARAM
)HeapAlloc(GetProcessHeap(), 0, len
);
1017 if (!*plparam
) return -1;
1018 WideCharToMultiByte(CP_ACP
, 0, str
, -1, (LPSTR
)*plparam
, len
, 0, 0);
1025 MDICREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
1027 *cs
= *(MDICREATESTRUCTA
*)*plparam
;
1028 if (HIWORD(cs
->szTitle
))
1030 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szTitle
, -1, NULL
, 0, 0, 0);
1031 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1032 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szTitle
, -1, buf
, len
, 0, 0);
1035 if (HIWORD(cs
->szClass
))
1037 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szClass
, -1, NULL
, 0, 0, 0);
1038 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1039 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)cs
->szClass
, -1, buf
, len
, 0, 0);
1042 *plparam
= (LPARAM
)cs
;
1048 case LB_INSERTSTRING
:
1050 case LB_FINDSTRINGEXACT
:
1051 case LB_SELECTSTRING
:
1052 if(!*plparam
) return 0;
1053 if ( WINPROC_TestLBForStr( hwnd
))
1055 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, NULL
, 0, 0, 0);
1056 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1057 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, buf
, len
, 0, 0);
1058 *plparam
= (LPARAM
)buf
;
1060 return (*plparam
? 1 : -1);
1062 case LB_GETTEXT
: /* FIXME: fixed sized buffer */
1063 { if ( WINPROC_TestLBForStr( hwnd
))
1064 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 + sizeof(LPARAM
) );
1065 if (!ptr
) return -1;
1066 *ptr
++ = *plparam
; /* Store previous lParam */
1067 *plparam
= (LPARAM
)ptr
;
1074 case CB_INSERTSTRING
:
1076 case CB_FINDSTRINGEXACT
:
1077 case CB_SELECTSTRING
:
1078 if(!*plparam
) return 0;
1079 if ( WINPROC_TestCBForStr( hwnd
))
1081 int len
= WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, NULL
, 0, 0, 0);
1082 LPSTR buf
= HeapAlloc(GetProcessHeap(), 0, len
);
1083 if (buf
) WideCharToMultiByte(CP_ACP
, 0, (LPCWSTR
)*plparam
, -1, buf
, len
, 0, 0);
1084 *plparam
= (LPARAM
)buf
;
1086 return (*plparam
? 1 : -1);
1088 case CB_GETLBTEXT
: /* FIXME: fixed sized buffer */
1089 { if ( WINPROC_TestCBForStr( hwnd
))
1090 { LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, 512 + sizeof(LPARAM
) );
1091 if (!ptr
) return -1;
1092 *ptr
++ = *plparam
; /* Store previous lParam */
1093 *plparam
= (LPARAM
)ptr
;
1098 /* Multiline edit */
1100 { WORD len
= (WORD
)*plparam
;
1101 LPARAM
*ptr
= HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(CHAR
) );
1102 if (!ptr
) return -1;
1103 *ptr
++ = *plparam
; /* Store previous lParam */
1104 *((WORD
*) ptr
) = len
; /* Store the length */
1105 *plparam
= (LPARAM
)ptr
;
1114 case WM_SYSDEADCHAR
:
1115 case EM_SETPASSWORDCHAR
:
1117 WCHAR wch
= LOWORD(*pwparam
);
1119 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
1120 *pwparam
= MAKEWPARAM( ch
, HIWORD(*pwparam
) );
1126 WCHAR wch
= LOWORD(*pwparam
);
1129 if (WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)ch
, 2, NULL
, NULL
) == 2)
1130 *pwparam
= MAKEWPARAM( (ch
[0] << 8) | ch
[1], HIWORD(*pwparam
) );
1132 *pwparam
= MAKEWPARAM( ch
[0], HIWORD(*pwparam
) );
1136 case WM_PAINTCLIPBOARD
:
1137 case WM_SIZECLIPBOARD
:
1138 FIXME_(msg
)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg
, hwnd
),msg
);
1140 default: /* No translation needed */
1146 /**********************************************************************
1147 * WINPROC_UnmapMsg32WTo32A
1149 * Unmap a message that was mapped from Unicode to Ansi.
1151 static LRESULT
WINPROC_UnmapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
, LRESULT result
)
1156 case WM_ASKCBFORMATNAME
:
1158 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1159 if (!wParam
) result
= 0;
1160 else if (!(result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1,
1161 (LPWSTR
)*ptr
, wParam
)))
1163 ((LPWSTR
)*ptr
)[wParam
-1] = 0;
1164 result
= wParam
- 1;
1166 else result
--; /* do not count terminating null */
1167 HeapFree( GetProcessHeap(), 0, ptr
);
1172 case WM_WININICHANGE
:
1173 case WM_DEVMODECHANGE
:
1178 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1183 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1184 if (HIWORD(cs
->szTitle
))
1185 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
1186 if (HIWORD(cs
->szClass
))
1187 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
1188 HeapFree( GetProcessHeap(), 0, cs
);
1194 case LB_INSERTSTRING
:
1196 case LB_FINDSTRINGEXACT
:
1197 case LB_SELECTSTRING
:
1198 if ( WINPROC_TestLBForStr( hwnd
))
1199 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1203 if ( WINPROC_TestLBForStr( hwnd
))
1205 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1207 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff ) - 1;
1208 HeapFree( GetProcessHeap(), 0, ptr
);
1214 case CB_INSERTSTRING
:
1216 case CB_FINDSTRINGEXACT
:
1217 case CB_SELECTSTRING
:
1218 if ( WINPROC_TestCBForStr( hwnd
))
1219 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1223 if ( result
< 0) /* CB_ERR and CB_ERRSPACE */
1225 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1226 HeapFree( GetProcessHeap(), 0, ptr
);
1228 else if ( WINPROC_TestCBForStr( hwnd
))
1230 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1231 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff ) - 1;
1232 HeapFree( GetProcessHeap(), 0, ptr
);
1236 /* Multiline edit */
1239 LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lparam */
1240 WORD len
= *(WORD
*)ptr
;
1243 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, result
, (LPWSTR
)*ptr
, len
);
1244 if (result
< len
) ((LPWSTR
)*ptr
)[result
] = 0;
1246 HeapFree( GetProcessHeap(), 0, ptr
);
1253 static UINT
convert_handle_16_to_32(HANDLE16 src
, unsigned int flags
)
1256 UINT sz
= GlobalSize16(src
);
1259 if (!(dst
= GlobalAlloc(flags
, sz
)))
1261 ptr16
= GlobalLock16(src
);
1262 ptr32
= GlobalLock(dst
);
1263 if (ptr16
!= NULL
&& ptr32
!= NULL
) memcpy(ptr32
, ptr16
, sz
);
1264 GlobalUnlock16(src
);
1270 /**********************************************************************
1271 * WINPROC_MapMsg16To32A
1273 * Map a message from 16- to 32-bit Ansi.
1274 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1276 INT
WINPROC_MapMsg16To32A( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1277 WPARAM
*pwparam32
, LPARAM
*plparam
)
1279 *pmsg32
= (UINT
)msg16
;
1280 *pwparam32
= (WPARAM
)wParam16
;
1287 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1288 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1292 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1293 *plparam
= (LPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1296 if ( HIWORD(*plparam
) > CTLCOLOR_STATIC
) return -1;
1297 *pmsg32
= WM_CTLCOLORMSGBOX
+ HIWORD(*plparam
);
1298 *pwparam32
= (WPARAM
)HDC_32(wParam16
);
1299 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1301 case WM_COMPAREITEM
:
1303 COMPAREITEMSTRUCT16
* cis16
= MapSL(*plparam
);
1304 COMPAREITEMSTRUCT
*cis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cis
));
1305 if (!cis
) return -1;
1306 cis
->CtlType
= cis16
->CtlType
;
1307 cis
->CtlID
= cis16
->CtlID
;
1308 cis
->hwndItem
= WIN_Handle32( cis16
->hwndItem
);
1309 cis
->itemID1
= cis16
->itemID1
;
1310 cis
->itemData1
= cis16
->itemData1
;
1311 cis
->itemID2
= cis16
->itemID2
;
1312 cis
->itemData2
= cis16
->itemData2
;
1313 cis
->dwLocaleId
= 0; /* FIXME */
1314 *plparam
= (LPARAM
)cis
;
1319 PCOPYDATASTRUCT16 pcds16
= MapSL(*plparam
);
1320 PCOPYDATASTRUCT pcds
= HeapAlloc ( GetProcessHeap(), 0, sizeof(*pcds
));
1321 pcds
->dwData
= pcds16
->dwData
;
1322 pcds
->cbData
= pcds16
->cbData
;
1323 pcds
->lpData
= MapSL( pcds16
->lpData
);
1324 *plparam
= (LPARAM
)pcds
;
1329 DELETEITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1330 DELETEITEMSTRUCT
*dis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1331 if (!dis
) return -1;
1332 dis
->CtlType
= dis16
->CtlType
;
1333 dis
->CtlID
= dis16
->CtlID
;
1334 dis
->hwndItem
= WIN_Handle32( dis16
->hwndItem
);
1335 dis
->itemData
= dis16
->itemData
;
1336 *plparam
= (LPARAM
)dis
;
1339 case WM_MEASUREITEM
:
1341 MEASUREITEMSTRUCT16
* mis16
= MapSL(*plparam
);
1342 MEASUREITEMSTRUCT
*mis
= HeapAlloc(GetProcessHeap(), 0,
1343 sizeof(*mis
) + sizeof(LPARAM
));
1344 if (!mis
) return -1;
1345 mis
->CtlType
= mis16
->CtlType
;
1346 mis
->CtlID
= mis16
->CtlID
;
1347 mis
->itemID
= mis16
->itemID
;
1348 mis
->itemWidth
= mis16
->itemWidth
;
1349 mis
->itemHeight
= mis16
->itemHeight
;
1350 mis
->itemData
= mis16
->itemData
;
1351 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1352 *plparam
= (LPARAM
)mis
;
1357 DRAWITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1358 DRAWITEMSTRUCT
*dis
= HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1359 if (!dis
) return -1;
1360 dis
->CtlType
= dis16
->CtlType
;
1361 dis
->CtlID
= dis16
->CtlID
;
1362 dis
->itemID
= dis16
->itemID
;
1363 dis
->itemAction
= dis16
->itemAction
;
1364 dis
->itemState
= dis16
->itemState
;
1365 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND
)HMENU_32(dis16
->hwndItem
)
1366 : WIN_Handle32( dis16
->hwndItem
);
1367 dis
->hDC
= HDC_32(dis16
->hDC
);
1368 dis
->itemData
= dis16
->itemData
;
1369 dis
->rcItem
.left
= dis16
->rcItem
.left
;
1370 dis
->rcItem
.top
= dis16
->rcItem
.top
;
1371 dis
->rcItem
.right
= dis16
->rcItem
.right
;
1372 dis
->rcItem
.bottom
= dis16
->rcItem
.bottom
;
1373 *plparam
= (LPARAM
)dis
;
1376 case WM_GETMINMAXINFO
:
1378 MINMAXINFO
*mmi
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mmi
) + sizeof(LPARAM
));
1379 if (!mmi
) return -1;
1380 MINMAXINFO16to32( MapSL(*plparam
), mmi
);
1381 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1382 *plparam
= (LPARAM
)mmi
;
1387 case WM_WININICHANGE
:
1388 case WM_DEVMODECHANGE
:
1389 case WM_ASKCBFORMATNAME
:
1390 *plparam
= (LPARAM
)MapSL(*plparam
);
1394 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1395 MDICREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1397 MDICREATESTRUCT16to32A( cs16
, cs
);
1398 cs
->szTitle
= MapSL(cs16
->szTitle
);
1399 cs
->szClass
= MapSL(cs16
->szClass
);
1400 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1401 *plparam
= (LPARAM
)cs
;
1404 case WM_MDIGETACTIVE
:
1405 *plparam
= (LPARAM
)HeapAlloc( GetProcessHeap(), 0, sizeof(BOOL
) );
1406 *(BOOL
*)(*plparam
) = 0;
1409 if(wParam16
) *pmsg32
=WM_MDIREFRESHMENU
;
1410 *pwparam32
= (WPARAM
)HMENU_32(LOWORD(*plparam
));
1411 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1414 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1415 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1418 if((LOWORD(*plparam
) & MF_POPUP
) && (LOWORD(*plparam
) != 0xFFFF))
1420 HMENU hmenu
=HMENU_32(HIWORD(*plparam
));
1421 UINT Pos
=MENU_FindSubMenu( &hmenu
, HMENU_32(wParam16
));
1422 if(Pos
==0xFFFF) Pos
=0; /* NO_SELECTED_ITEM */
1423 *pwparam32
= MAKEWPARAM( Pos
, LOWORD(*plparam
) );
1425 else *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1426 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1428 case WM_MDIACTIVATE
:
1431 *pwparam32
= (WPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1432 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1434 else /* message sent to MDI client */
1435 *pwparam32
= wParam16
;
1439 NCCALCSIZE_PARAMS16
*nc16
;
1440 NCCALCSIZE_PARAMS
*nc
;
1442 nc
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
) + sizeof(LPARAM
) );
1444 nc16
= MapSL(*plparam
);
1445 nc
->rgrc
[0].left
= nc16
->rgrc
[0].left
;
1446 nc
->rgrc
[0].top
= nc16
->rgrc
[0].top
;
1447 nc
->rgrc
[0].right
= nc16
->rgrc
[0].right
;
1448 nc
->rgrc
[0].bottom
= nc16
->rgrc
[0].bottom
;
1451 nc
->lppos
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
->lppos
) );
1452 nc
->rgrc
[1].left
= nc16
->rgrc
[1].left
;
1453 nc
->rgrc
[1].top
= nc16
->rgrc
[1].top
;
1454 nc
->rgrc
[1].right
= nc16
->rgrc
[1].right
;
1455 nc
->rgrc
[1].bottom
= nc16
->rgrc
[1].bottom
;
1456 nc
->rgrc
[2].left
= nc16
->rgrc
[2].left
;
1457 nc
->rgrc
[2].top
= nc16
->rgrc
[2].top
;
1458 nc
->rgrc
[2].right
= nc16
->rgrc
[2].right
;
1459 nc
->rgrc
[2].bottom
= nc16
->rgrc
[2].bottom
;
1460 if (nc
->lppos
) WINDOWPOS16to32( MapSL(nc16
->lppos
), nc
->lppos
);
1462 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1463 *plparam
= (LPARAM
)nc
;
1469 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1470 CREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1472 CREATESTRUCT16to32A( cs16
, cs
);
1473 cs
->lpszName
= MapSL(cs16
->lpszName
);
1474 cs
->lpszClass
= MapSL(cs16
->lpszClass
);
1476 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1478 MDICREATESTRUCT16
*mdi_cs16
;
1479 MDICREATESTRUCTA
*mdi_cs
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs
));
1482 HeapFree(GetProcessHeap(), 0, cs
);
1485 mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs16
->lpCreateParams
);
1486 MDICREATESTRUCT16to32A(mdi_cs16
, mdi_cs
);
1487 mdi_cs
->szTitle
= MapSL(mdi_cs16
->szTitle
);
1488 mdi_cs
->szClass
= MapSL(mdi_cs16
->szClass
);
1490 cs
->lpCreateParams
= mdi_cs
;
1492 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1493 *plparam
= (LPARAM
)cs
;
1496 case WM_PARENTNOTIFY
:
1497 if ((wParam16
== WM_CREATE
) || (wParam16
== WM_DESTROY
))
1499 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1500 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1503 case WM_WINDOWPOSCHANGING
:
1504 case WM_WINDOWPOSCHANGED
:
1506 WINDOWPOS
*wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*wp
) + sizeof(LPARAM
) );
1508 WINDOWPOS16to32( MapSL(*plparam
), wp
);
1509 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1510 *plparam
= (LPARAM
)wp
;
1516 LPMSG16 msg16
= MapSL(*plparam
);
1517 LPMSG msg32
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1519 if (!msg32
) return -1;
1520 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1521 msg32
->lParam
= msg16
->lParam
;
1522 msg32
->time
= msg16
->time
;
1523 msg32
->pt
.x
= msg16
->pt
.x
;
1524 msg32
->pt
.y
= msg16
->pt
.y
;
1525 /* this is right, right? */
1526 if (WINPROC_MapMsg16To32A( msg32
->hwnd
, msg16
->message
,msg16
->wParam
,
1527 &msg32
->message
,&msg32
->wParam
,
1528 &msg32
->lParam
)<0) {
1529 HeapFree( GetProcessHeap(), 0, msg32
);
1532 *plparam
= (LPARAM
)msg32
;
1537 *plparam
= (LPARAM
)MapSL(*plparam
);
1539 case WM_ACTIVATEAPP
:
1540 /* We need this when SetActiveWindow sends a Sendmessage16() to
1541 * a 32bit window. Might be superflous with 32bit interprocess
1542 * message queues. */
1543 if (*plparam
) *plparam
= HTASK_32( *plparam
);
1547 MDINEXTMENU
*next
= HeapAlloc( GetProcessHeap(), 0, sizeof(*next
) );
1548 if (!next
) return -1;
1549 next
->hmenuIn
= (HMENU
)*plparam
;
1550 next
->hmenuNext
= 0;
1552 *plparam
= (LPARAM
)next
;
1555 case WM_PAINTCLIPBOARD
:
1556 case WM_SIZECLIPBOARD
:
1557 FIXME_(msg
)("message %04x needs translation\n",msg16
);
1559 case WM_DDE_INITIATE
:
1560 case WM_DDE_TERMINATE
:
1561 case WM_DDE_UNADVISE
:
1562 case WM_DDE_REQUEST
:
1563 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1573 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1574 lo16
= LOWORD(*plparam
);
1575 hi
= HIWORD(*plparam
);
1576 if (lo16
&& !(lo32
= convert_handle_16_to_32(lo16
, GMEM_DDESHARE
)))
1578 *plparam
= PackDDElParam(msg16
, lo32
, hi
);
1580 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1587 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1589 lo
= LOWORD(*plparam
);
1590 hi
= HIWORD(*plparam
);
1592 if (GlobalGetAtomNameA(hi
, buf
, 2) > 0) flag
|= 1;
1593 if (GlobalSize16(hi
) != 0) flag
|= 2;
1599 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
1604 break; /* atom, nothing to do */
1606 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi
);
1609 hi
= convert_handle_16_to_32(hi
, GMEM_DDESHARE
);
1612 *plparam
= PackDDElParam(WM_DDE_ACK
, lo
, hi
);
1614 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1615 case WM_DDE_EXECUTE
:
1616 *plparam
= convert_handle_16_to_32(*plparam
, GMEM_DDESHARE
);
1617 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1618 default: /* No translation needed */
1624 /**********************************************************************
1625 * WINPROC_UnmapMsg16To32A
1627 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1629 LRESULT
WINPROC_UnmapMsg16To32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1634 case WM_COMPAREITEM
:
1638 HeapFree( GetProcessHeap(), 0, (LPVOID
)lParam
);
1640 case WM_MEASUREITEM
:
1642 MEASUREITEMSTRUCT16
*mis16
;
1643 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)lParam
;
1644 lParam
= *(LPARAM
*)(mis
+ 1);
1645 mis16
= MapSL(lParam
);
1646 mis16
->itemWidth
= (UINT16
)mis
->itemWidth
;
1647 mis16
->itemHeight
= (UINT16
)mis
->itemHeight
;
1648 HeapFree( GetProcessHeap(), 0, mis
);
1651 case WM_GETMINMAXINFO
:
1653 MINMAXINFO
*mmi
= (MINMAXINFO
*)lParam
;
1654 lParam
= *(LPARAM
*)(mmi
+ 1);
1655 MINMAXINFO32to16( mmi
, MapSL(lParam
));
1656 HeapFree( GetProcessHeap(), 0, mmi
);
1661 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1662 lParam
= *(LPARAM
*)(cs
+ 1);
1663 MDICREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1664 HeapFree( GetProcessHeap(), 0, cs
);
1667 case WM_MDIGETACTIVE
:
1668 result
= MAKELONG( LOWORD(result
), (BOOL16
)(*(BOOL
*)lParam
) );
1669 HeapFree( GetProcessHeap(), 0, (BOOL
*)lParam
);
1673 NCCALCSIZE_PARAMS16
*nc16
;
1674 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lParam
;
1675 lParam
= *(LPARAM
*)(nc
+ 1);
1676 nc16
= MapSL(lParam
);
1677 nc16
->rgrc
[0].left
= nc
->rgrc
[0].left
;
1678 nc16
->rgrc
[0].top
= nc
->rgrc
[0].top
;
1679 nc16
->rgrc
[0].right
= nc
->rgrc
[0].right
;
1680 nc16
->rgrc
[0].bottom
= nc
->rgrc
[0].bottom
;
1683 nc16
->rgrc
[1].left
= nc
->rgrc
[1].left
;
1684 nc16
->rgrc
[1].top
= nc
->rgrc
[1].top
;
1685 nc16
->rgrc
[1].right
= nc
->rgrc
[1].right
;
1686 nc16
->rgrc
[1].bottom
= nc
->rgrc
[1].bottom
;
1687 nc16
->rgrc
[2].left
= nc
->rgrc
[2].left
;
1688 nc16
->rgrc
[2].top
= nc
->rgrc
[2].top
;
1689 nc16
->rgrc
[2].right
= nc
->rgrc
[2].right
;
1690 nc16
->rgrc
[2].bottom
= nc
->rgrc
[2].bottom
;
1693 WINDOWPOS32to16( nc
->lppos
, MapSL(nc16
->lppos
));
1694 HeapFree( GetProcessHeap(), 0, nc
->lppos
);
1697 HeapFree( GetProcessHeap(), 0, nc
);
1703 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
1704 lParam
= *(LPARAM
*)(cs
+ 1);
1705 CREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1707 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1708 HeapFree(GetProcessHeap(), 0, cs
->lpCreateParams
);
1710 HeapFree( GetProcessHeap(), 0, cs
);
1713 case WM_WINDOWPOSCHANGING
:
1714 case WM_WINDOWPOSCHANGED
:
1716 WINDOWPOS
*wp
= (WINDOWPOS
*)lParam
;
1717 lParam
= *(LPARAM
*)(wp
+ 1);
1718 WINDOWPOS32to16(wp
, MapSL(lParam
));
1719 HeapFree( GetProcessHeap(), 0, wp
);
1725 LPMSG msg32
= (LPMSG
)lParam
;
1727 WINPROC_UnmapMsg16To32A( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1729 HeapFree( GetProcessHeap(), 0, msg32
);
1734 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
1735 result
= MAKELONG( HMENU_16(next
->hmenuNext
), HWND_16(next
->hwndNext
) );
1736 HeapFree( GetProcessHeap(), 0, next
);
1744 /**********************************************************************
1745 * WINPROC_MapMsg16To32W
1747 * Map a message from 16- to 32-bit Unicode.
1748 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1750 INT
WINPROC_MapMsg16To32W( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1751 WPARAM
*pwparam32
, LPARAM
*plparam
)
1756 *pmsg32
=(UINT
)msg16
;
1757 *pwparam32
= (WPARAM
)wParam16
;
1762 case WM_WININICHANGE
:
1763 case WM_DEVMODECHANGE
:
1764 case WM_ASKCBFORMATNAME
:
1765 *plparam
= (LPARAM
)MapSL(*plparam
);
1766 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1767 case WM_GETTEXTLENGTH
:
1768 case CB_GETLBTEXTLEN
:
1770 return 1; /* need to map result */
1774 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1775 CREATESTRUCTW
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1777 CREATESTRUCT16to32A( cs16
, (CREATESTRUCTA
*)cs
);
1778 cs
->lpszName
= map_str_16_to_32W(cs16
->lpszName
);
1779 cs
->lpszClass
= map_str_16_to_32W(cs16
->lpszClass
);
1781 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1783 MDICREATESTRUCT16
*mdi_cs16
;
1784 MDICREATESTRUCTW
*mdi_cs
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs
));
1787 HeapFree(GetProcessHeap(), 0, cs
);
1790 mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs16
->lpCreateParams
);
1791 MDICREATESTRUCT16to32A(mdi_cs16
, (MDICREATESTRUCTA
*)mdi_cs
);
1792 mdi_cs
->szTitle
= map_str_16_to_32W(mdi_cs16
->szTitle
);
1793 mdi_cs
->szClass
= map_str_16_to_32W(mdi_cs16
->szClass
);
1795 cs
->lpCreateParams
= mdi_cs
;
1797 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1798 *plparam
= (LPARAM
)cs
;
1803 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1804 MDICREATESTRUCTW
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1806 MDICREATESTRUCT16to32A( cs16
, (MDICREATESTRUCTA
*)cs
);
1807 cs
->szTitle
= map_str_16_to_32W(cs16
->szTitle
);
1808 cs
->szClass
= map_str_16_to_32W(cs16
->szClass
);
1809 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1810 *plparam
= (LPARAM
)cs
;
1816 LPMSG16 msg16
= MapSL(*plparam
);
1817 LPMSG msg32
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1819 if (!msg32
) return -1;
1820 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1821 msg32
->lParam
= msg16
->lParam
;
1822 msg32
->time
= msg16
->time
;
1823 msg32
->pt
.x
= msg16
->pt
.x
;
1824 msg32
->pt
.y
= msg16
->pt
.y
;
1825 /* this is right, right? */
1826 if (WINPROC_MapMsg16To32W(hwnd
, msg16
->message
,msg16
->wParam
,
1827 &msg32
->message
,&msg32
->wParam
,
1828 &msg32
->lParam
)<0) {
1829 HeapFree( GetProcessHeap(), 0, msg32
);
1832 *plparam
= (LPARAM
)msg32
;
1839 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1840 *pwparam32
= MAKEWPARAM( wch
, HIWORD(*plparam
) );
1841 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1845 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1846 *pwparam32
= MAKEWPARAM( wch
, LOWORD(*plparam
) );
1847 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1852 case WM_SYSDEADCHAR
:
1854 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1858 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1860 default: /* No Unicode translation needed */
1861 return WINPROC_MapMsg16To32A( hwnd
, msg16
, wParam16
, pmsg32
,
1862 pwparam32
, plparam
);
1867 /**********************************************************************
1868 * WINPROC_UnmapMsg16To32W
1870 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1872 LRESULT
WINPROC_UnmapMsg16To32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1873 LRESULT result
, WNDPROC dispatch
)
1879 case WM_GETTEXTLENGTH
:
1880 case CB_GETLBTEXTLEN
:
1882 case WM_ASKCBFORMATNAME
:
1883 return WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
, dispatch
);
1887 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
1888 lParam
= *(LPARAM
*)(cs
+ 1);
1889 CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs
, MapSL(lParam
) );
1890 unmap_str_16_to_32W( cs
->lpszName
);
1891 unmap_str_16_to_32W( cs
->lpszClass
);
1893 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1895 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)cs
->lpCreateParams
;
1896 unmap_str_16_to_32W( mdi_cs
->szTitle
);
1897 unmap_str_16_to_32W( mdi_cs
->szClass
);
1898 HeapFree(GetProcessHeap(), 0, cs
->lpCreateParams
);
1900 HeapFree( GetProcessHeap(), 0, cs
);
1905 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
1906 lParam
= *(LPARAM
*)(cs
+ 1);
1907 MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs
, MapSL(lParam
) );
1908 unmap_str_16_to_32W( cs
->szTitle
);
1909 unmap_str_16_to_32W( cs
->szClass
);
1910 HeapFree( GetProcessHeap(), 0, cs
);
1916 LPMSG msg32
= (LPMSG
)lParam
;
1918 WINPROC_UnmapMsg16To32W( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1920 HeapFree( GetProcessHeap(), 0, msg32
);
1924 return WINPROC_UnmapMsg16To32A( hwnd
, msg
, wParam
, lParam
, result
);
1929 static HANDLE16
convert_handle_32_to_16(UINT src
, unsigned int flags
)
1932 UINT sz
= GlobalSize((HANDLE
)src
);
1935 if (!(dst
= GlobalAlloc16(flags
, sz
)))
1937 ptr32
= GlobalLock((HANDLE
)src
);
1938 ptr16
= GlobalLock16(dst
);
1939 if (ptr16
!= NULL
&& ptr32
!= NULL
) memcpy(ptr16
, ptr32
, sz
);
1940 GlobalUnlock((HANDLE
)src
);
1941 GlobalUnlock16(dst
);
1947 /**********************************************************************
1948 * WINPROC_MapMsg32ATo16
1950 * Map a message from 32-bit Ansi to 16-bit.
1951 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1953 INT
WINPROC_MapMsg32ATo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
1954 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
1957 *pmsg16
= (UINT16
)msg32
;
1958 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
1962 *pmsg16
= SBM_SETRANGE16
;
1963 *plparam
= MAKELPARAM(wParam32
, *plparam
);
1968 *pmsg16
= SBM_GETRANGE16
;
1976 *pmsg16
= (UINT16
)msg32
+ (BM_GETCHECK16
- BM_GETCHECK
);
1985 case EM_SCROLLCARET
:
1988 case EM_GETLINECOUNT
:
2000 case EM_LINEFROMCHAR
:
2001 case EM_SETTABSTOPS
:
2002 case EM_SETPASSWORDCHAR
:
2003 case EM_EMPTYUNDOBUFFER
:
2004 case EM_GETFIRSTVISIBLELINE
:
2005 case EM_SETREADONLY
:
2006 case EM_SETWORDBREAKPROC
:
2007 case EM_GETWORDBREAKPROC
:
2008 case EM_GETPASSWORDCHAR
:
2009 *pmsg16
= (UINT16
)msg32
+ (EM_GETSEL16
- EM_GETSEL
);
2014 case LB_DELETESTRING
:
2015 case LB_GETANCHORINDEX
:
2016 case LB_GETCARETINDEX
:
2019 case LB_GETHORIZONTALEXTENT
:
2020 case LB_GETITEMDATA
:
2021 case LB_GETITEMHEIGHT
:
2023 case LB_GETSELCOUNT
:
2025 case LB_GETTOPINDEX
:
2026 case LB_RESETCONTENT
:
2027 case LB_SELITEMRANGE
:
2028 case LB_SELITEMRANGEEX
:
2029 case LB_SETANCHORINDEX
:
2030 case LB_SETCARETINDEX
:
2031 case LB_SETCOLUMNWIDTH
:
2033 case LB_SETHORIZONTALEXTENT
:
2034 case LB_SETITEMDATA
:
2035 case LB_SETITEMHEIGHT
:
2037 case LB_SETTOPINDEX
:
2038 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2040 case CB_DELETESTRING
:
2042 case CB_GETLBTEXTLEN
:
2044 case CB_RESETCONTENT
:
2048 case CB_SHOWDROPDOWN
:
2049 case CB_SETITEMDATA
:
2050 case CB_SETITEMHEIGHT
:
2051 case CB_GETITEMHEIGHT
:
2052 case CB_SETEXTENDEDUI
:
2053 case CB_GETEXTENDEDUI
:
2054 case CB_GETDROPPEDSTATE
:
2055 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
2058 *pmsg16
= CB_GETEDITSEL16
;
2063 case LB_FINDSTRINGEXACT
:
2064 case LB_INSERTSTRING
:
2065 case LB_SELECTSTRING
:
2068 *plparam
= (LPARAM
)MapLS( (LPSTR
)*plparam
);
2069 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2074 case CB_FINDSTRINGEXACT
:
2075 case CB_INSERTSTRING
:
2076 case CB_SELECTSTRING
:
2078 *plparam
= (LPARAM
)MapLS( (LPSTR
)*plparam
);
2079 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
2082 case LB_GETITEMRECT
:
2084 RECT16
*rect
= HeapAlloc( GetProcessHeap(), 0, sizeof(RECT16
) + sizeof(LPARAM
) );
2085 if (!rect
) return -1;
2086 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
2087 *plparam
= MapLS( rect
);
2089 *pmsg16
= LB_GETITEMRECT16
;
2091 case LB_GETSELITEMS
:
2093 LPARAM
*items
; /* old LPARAM first, then *pwparam16 x INT16 entries */
2095 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
2096 if (!(items
= HeapAlloc( GetProcessHeap(), 0,
2097 *pwparam16
* sizeof(INT16
) + sizeof(LPARAM
)))) return -1;
2098 *items
++ = *plparam
; /* Store the previous lParam */
2099 *plparam
= MapLS( items
);
2101 *pmsg16
= LB_GETSELITEMS16
;
2103 case LB_SETTABSTOPS
:
2108 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
2109 if (!(stops
= HeapAlloc( GetProcessHeap(), 0,
2110 *pwparam16
* sizeof(INT16
) + sizeof(LPARAM
)))) return -1;
2111 for (i
= 0; i
< *pwparam16
; i
++) stops
[i
] = *((LPINT
)*plparam
+i
);
2112 *plparam
= MapLS( stops
);
2115 *pmsg16
= LB_SETTABSTOPS16
;
2118 case CB_GETDROPPEDCONTROLRECT
:
2120 RECT16
*rect
= HeapAlloc( GetProcessHeap(), 0, sizeof(RECT16
) + sizeof(LPARAM
) );
2121 if (!rect
) return -1;
2122 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
2123 *plparam
= (LPARAM
)MapLS(rect
);
2125 *pmsg16
= CB_GETDROPPEDCONTROLRECT16
;
2129 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
2130 *pmsg16
= LB_GETTEXT16
;
2134 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
2135 *pmsg16
= CB_GETLBTEXT16
;
2140 *plparam
= MAKELONG( (INT16
)(INT
)wParam32
, (INT16
)*plparam
);
2141 *pmsg16
= EM_SETSEL16
;
2148 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
2152 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HWND16
)*plparam
);
2156 PCOPYDATASTRUCT pcds32
= (PCOPYDATASTRUCT
) *plparam
;
2157 PCOPYDATASTRUCT16 pcds
= HeapAlloc( GetProcessHeap(), 0, sizeof( *pcds
));
2158 pcds
->dwData
= pcds32
->dwData
;
2159 pcds
->cbData
= pcds32
->cbData
;
2160 pcds
->lpData
= MapLS( pcds32
->lpData
);
2161 *plparam
= MapLS( pcds
);
2164 case WM_CTLCOLORMSGBOX
:
2165 case WM_CTLCOLOREDIT
:
2166 case WM_CTLCOLORLISTBOX
:
2167 case WM_CTLCOLORBTN
:
2168 case WM_CTLCOLORDLG
:
2169 case WM_CTLCOLORSCROLLBAR
:
2170 case WM_CTLCOLORSTATIC
:
2171 *pmsg16
= WM_CTLCOLOR
;
2172 *plparam
= MAKELPARAM( (HWND16
)*plparam
,
2173 (WORD
)msg32
- WM_CTLCOLORMSGBOX
);
2175 case WM_COMPAREITEM
:
2177 COMPAREITEMSTRUCT
*cis32
= (COMPAREITEMSTRUCT
*)*plparam
;
2178 COMPAREITEMSTRUCT16
*cis
= HeapAlloc( GetProcessHeap(), 0, sizeof(COMPAREITEMSTRUCT16
));
2179 if (!cis
) return -1;
2180 cis
->CtlType
= (UINT16
)cis32
->CtlType
;
2181 cis
->CtlID
= (UINT16
)cis32
->CtlID
;
2182 cis
->hwndItem
= HWND_16( cis32
->hwndItem
);
2183 cis
->itemID1
= (UINT16
)cis32
->itemID1
;
2184 cis
->itemData1
= cis32
->itemData1
;
2185 cis
->itemID2
= (UINT16
)cis32
->itemID2
;
2186 cis
->itemData2
= cis32
->itemData2
;
2187 *plparam
= MapLS( cis
);
2192 DELETEITEMSTRUCT
*dis32
= (DELETEITEMSTRUCT
*)*plparam
;
2193 DELETEITEMSTRUCT16
*dis
= HeapAlloc( GetProcessHeap(), 0, sizeof(DELETEITEMSTRUCT16
) );
2194 if (!dis
) return -1;
2195 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
2196 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
2197 dis
->itemID
= (UINT16
)dis32
->itemID
;
2198 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND16
)LOWORD(dis32
->hwndItem
)
2199 : HWND_16( dis32
->hwndItem
);
2200 dis
->itemData
= dis32
->itemData
;
2201 *plparam
= MapLS( dis
);
2206 DRAWITEMSTRUCT
*dis32
= (DRAWITEMSTRUCT
*)*plparam
;
2207 DRAWITEMSTRUCT16
*dis
= HeapAlloc( GetProcessHeap(), 0, sizeof(DRAWITEMSTRUCT16
) );
2208 if (!dis
) return -1;
2209 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
2210 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
2211 dis
->itemID
= (UINT16
)dis32
->itemID
;
2212 dis
->itemAction
= (UINT16
)dis32
->itemAction
;
2213 dis
->itemState
= (UINT16
)dis32
->itemState
;
2214 dis
->hwndItem
= HWND_16( dis32
->hwndItem
);
2215 dis
->hDC
= HDC_16(dis32
->hDC
);
2216 dis
->itemData
= dis32
->itemData
;
2217 dis
->rcItem
.left
= dis32
->rcItem
.left
;
2218 dis
->rcItem
.top
= dis32
->rcItem
.top
;
2219 dis
->rcItem
.right
= dis32
->rcItem
.right
;
2220 dis
->rcItem
.bottom
= dis32
->rcItem
.bottom
;
2221 *plparam
= MapLS( dis
);
2224 case WM_MEASUREITEM
:
2226 MEASUREITEMSTRUCT
*mis32
= (MEASUREITEMSTRUCT
*)*plparam
;
2227 MEASUREITEMSTRUCT16
*mis
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mis
)+sizeof(LPARAM
));
2228 if (!mis
) return -1;
2229 mis
->CtlType
= (UINT16
)mis32
->CtlType
;
2230 mis
->CtlID
= (UINT16
)mis32
->CtlID
;
2231 mis
->itemID
= (UINT16
)mis32
->itemID
;
2232 mis
->itemWidth
= (UINT16
)mis32
->itemWidth
;
2233 mis
->itemHeight
= (UINT16
)mis32
->itemHeight
;
2234 mis
->itemData
= mis32
->itemData
;
2235 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
2236 *plparam
= MapLS( mis
);
2239 case WM_GETMINMAXINFO
:
2241 MINMAXINFO16
*mmi
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mmi
) + sizeof(LPARAM
) );
2242 if (!mmi
) return -1;
2243 MINMAXINFO32to16( (MINMAXINFO
*)*plparam
, mmi
);
2244 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
2245 *plparam
= MapLS( mmi
);
2249 case WM_ASKCBFORMATNAME
:
2251 LPARAM
*str
; /* store LPARAM, then *pwparam16 char space */
2252 *pwparam16
= (WPARAM16
)min( wParam32
, 0xff80 ); /* Must be < 64K */
2253 if (!(str
= HeapAlloc( GetProcessHeap(), 0, *pwparam16
+ sizeof(LPARAM
)))) return -1;
2254 *str
++ = *plparam
; /* Store the previous lParam */
2255 *plparam
= MapLS( str
);
2260 MDICREATESTRUCT16
*cs
;
2261 MDICREATESTRUCTA
*cs32
= (MDICREATESTRUCTA
*)*plparam
;
2263 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16
) ))) return -1;
2264 MDICREATESTRUCT32Ato16( cs32
, cs
);
2265 cs
->szTitle
= MapLS( cs32
->szTitle
);
2266 cs
->szClass
= MapLS( cs32
->szClass
);
2267 *plparam
= MapLS( cs
);
2270 case WM_MDIGETACTIVE
:
2273 *plparam
= MAKELPARAM( (HMENU16
)LOWORD(wParam32
),
2274 (HMENU16
)LOWORD(*plparam
) );
2275 *pwparam16
= (*plparam
== 0);
2278 if(HIWORD(wParam32
) & MF_POPUP
)
2281 if (((UINT
)HIWORD(wParam32
) != 0xFFFF) || (*plparam
))
2283 if((hmenu
= GetSubMenu((HMENU
)*plparam
, *pwparam16
)))
2284 *pwparam16
=HMENU_16(hmenu
);
2289 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2291 case WM_MDIACTIVATE
:
2292 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2294 *pwparam16
= ((HWND
)*plparam
== hwnd
);
2295 *plparam
= MAKELPARAM( (HWND16
)LOWORD(*plparam
),
2296 (HWND16
)LOWORD(wParam32
) );
2300 *pwparam16
= HWND_16( (HWND
)wParam32
);
2306 NCCALCSIZE_PARAMS
*nc32
= (NCCALCSIZE_PARAMS
*)*plparam
;
2307 NCCALCSIZE_PARAMS16
*nc
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
) + sizeof(LPARAM
));
2310 nc
->rgrc
[0].left
= nc32
->rgrc
[0].left
;
2311 nc
->rgrc
[0].top
= nc32
->rgrc
[0].top
;
2312 nc
->rgrc
[0].right
= nc32
->rgrc
[0].right
;
2313 nc
->rgrc
[0].bottom
= nc32
->rgrc
[0].bottom
;
2317 nc
->rgrc
[1].left
= nc32
->rgrc
[1].left
;
2318 nc
->rgrc
[1].top
= nc32
->rgrc
[1].top
;
2319 nc
->rgrc
[1].right
= nc32
->rgrc
[1].right
;
2320 nc
->rgrc
[1].bottom
= nc32
->rgrc
[1].bottom
;
2321 nc
->rgrc
[2].left
= nc32
->rgrc
[2].left
;
2322 nc
->rgrc
[2].top
= nc32
->rgrc
[2].top
;
2323 nc
->rgrc
[2].right
= nc32
->rgrc
[2].right
;
2324 nc
->rgrc
[2].bottom
= nc32
->rgrc
[2].bottom
;
2325 if (!(wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(WINDOWPOS16
) )))
2327 HeapFree( GetProcessHeap(), 0, nc
);
2330 WINDOWPOS32to16( nc32
->lppos
, wp
);
2331 nc
->lppos
= MapLS( wp
);
2333 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
2334 *plparam
= MapLS( nc
);
2341 CREATESTRUCTA
*cs32
= (CREATESTRUCTA
*)*plparam
;
2343 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16
) ))) return -1;
2344 CREATESTRUCT32Ato16( cs32
, cs
);
2345 cs
->lpszName
= MapLS( cs32
->lpszName
);
2346 cs
->lpszClass
= MapLS( cs32
->lpszClass
);
2348 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2350 MDICREATESTRUCT16
*mdi_cs16
;
2351 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)cs32
->lpCreateParams
;
2352 mdi_cs16
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs16
));
2355 HeapFree(GetProcessHeap(), 0, cs
);
2358 MDICREATESTRUCT32Ato16(mdi_cs
, mdi_cs16
);
2359 mdi_cs16
->szTitle
= MapLS( mdi_cs
->szTitle
);
2360 mdi_cs16
->szClass
= MapLS( mdi_cs
->szClass
);
2361 cs
->lpCreateParams
= MapLS( mdi_cs16
);
2363 *plparam
= MapLS( cs
);
2366 case WM_PARENTNOTIFY
:
2367 if ((LOWORD(wParam32
)==WM_CREATE
) || (LOWORD(wParam32
)==WM_DESTROY
))
2368 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
));
2369 /* else nothing to do */
2372 *plparam
= MapLS( (NMHDR
*)*plparam
); /* NMHDR is already 32-bit */
2375 case WM_WININICHANGE
:
2376 case WM_DEVMODECHANGE
:
2377 *plparam
= MapLS( (LPSTR
)*plparam
);
2379 case WM_WINDOWPOSCHANGING
:
2380 case WM_WINDOWPOSCHANGED
:
2382 WINDOWPOS16
*wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*wp
) + sizeof(LPARAM
) );
2384 WINDOWPOS32to16( (WINDOWPOS
*)*plparam
, wp
);
2385 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
2386 *plparam
= MapLS( wp
);
2391 LPMSG msg32
= (LPMSG
) *plparam
;
2392 LPMSG16 msg16
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG16
) );
2394 if (!msg16
) return -1;
2395 msg16
->hwnd
= HWND_16( msg32
->hwnd
);
2396 msg16
->lParam
= msg32
->lParam
;
2397 msg16
->time
= msg32
->time
;
2398 msg16
->pt
.x
= msg32
->pt
.x
;
2399 msg16
->pt
.y
= msg32
->pt
.y
;
2400 /* this is right, right? */
2401 if (WINPROC_MapMsg32ATo16(msg32
->hwnd
,msg32
->message
,msg32
->wParam
,
2402 &msg16
->message
,&msg16
->wParam
, &msg16
->lParam
)<0)
2404 HeapFree( GetProcessHeap(), 0, msg16
);
2407 *plparam
= MapLS( msg16
);
2412 case WM_ACTIVATEAPP
:
2413 if (*plparam
) *plparam
= HTASK_16( (HANDLE
)*plparam
);
2417 MDINEXTMENU
*next
= (MDINEXTMENU
*)*plparam
;
2418 *plparam
= (LPARAM
)next
->hmenuIn
;
2422 if (IsIconic( hwnd
) && GetClassLongPtrW( hwnd
, GCLP_HICON
))
2424 *pmsg16
= WM_PAINTICON
;
2429 if (IsIconic( hwnd
) && GetClassLongPtrW( hwnd
, GCLP_HICON
))
2430 *pmsg16
= WM_ICONERASEBKGND
;
2432 case WM_PAINTCLIPBOARD
:
2433 case WM_SIZECLIPBOARD
:
2434 FIXME_(msg
)("message %04x needs translation\n", msg32
);
2436 /* following messages should not be sent to 16-bit apps */
2439 case WM_CAPTURECHANGED
:
2440 case WM_STYLECHANGING
:
2441 case WM_STYLECHANGED
:
2443 case WM_DDE_INITIATE
:
2444 case WM_DDE_TERMINATE
:
2445 case WM_DDE_UNADVISE
:
2446 case WM_DDE_REQUEST
:
2447 *pwparam16
= HWND_16((HWND
)wParam32
);
2456 *pwparam16
= HWND_16((HWND
)wParam32
);
2457 UnpackDDElParam(msg32
, *plparam
, &lo32
, &hi
);
2458 if (lo32
&& !(lo16
= convert_handle_32_to_16(lo32
, GMEM_DDESHARE
)))
2460 *plparam
= MAKELPARAM(lo16
, hi
);
2462 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2469 *pwparam16
= HWND_16((HWND
)wParam32
);
2471 UnpackDDElParam(msg32
, *plparam
, &lo
, &hi
);
2473 if (GlobalGetAtomNameA((ATOM
)hi
, buf
, sizeof(buf
)) > 0) flag
|= 1;
2474 if (GlobalSize((HANDLE
)hi
) != 0) flag
|= 2;
2480 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
2485 break; /* atom, nothing to do */
2487 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi
);
2490 hi
= convert_handle_32_to_16(hi
, GMEM_DDESHARE
);
2493 *plparam
= MAKELPARAM(lo
, hi
);
2495 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2496 case WM_DDE_EXECUTE
:
2497 *plparam
= convert_handle_32_to_16(*plparam
, GMEM_DDESHARE
);
2498 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2499 default: /* No translation needed */
2505 /**********************************************************************
2506 * WINPROC_UnmapMsg32ATo16
2508 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
2510 void WINPROC_UnmapMsg32ATo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2516 *(LPINT
)wParam
= LOWORD(p16
->lResult
);
2517 *(LPINT
)lParam
= HIWORD(p16
->lResult
);
2524 case LB_FINDSTRINGEXACT
:
2525 case LB_INSERTSTRING
:
2526 case LB_SELECTSTRING
:
2530 case CB_FINDSTRINGEXACT
:
2531 case CB_INSERTSTRING
:
2532 case CB_SELECTSTRING
:
2536 case WM_WININICHANGE
:
2537 case WM_DEVMODECHANGE
:
2538 UnMapLS( (SEGPTR
)p16
->lParam
);
2540 case LB_SETTABSTOPS
:
2541 case WM_COMPAREITEM
:
2545 void *ptr
= MapSL( p16
->lParam
);
2546 UnMapLS( p16
->lParam
);
2547 HeapFree( GetProcessHeap(), 0, ptr
);
2552 PCOPYDATASTRUCT16 pcds
= MapSL( p16
->lParam
);
2553 UnMapLS( p16
->lParam
);
2554 UnMapLS( pcds
->lpData
);
2555 HeapFree( GetProcessHeap(), 0, pcds
);
2558 case CB_GETDROPPEDCONTROLRECT
:
2559 case LB_GETITEMRECT
:
2562 RECT16
*rect
= MapSL(p16
->lParam
);
2563 UnMapLS( p16
->lParam
);
2564 p16
->lParam
= *(LPARAM
*)(rect
+ 1);
2565 r32
= (RECT
*)p16
->lParam
;
2566 r32
->left
= rect
->left
;
2567 r32
->top
= rect
->top
;
2568 r32
->right
= rect
->right
;
2569 r32
->bottom
= rect
->bottom
;
2570 HeapFree( GetProcessHeap(), 0, rect
);
2573 case LB_GETSELITEMS
:
2576 LPINT16 items
= MapSL(p16
->lParam
);
2577 UnMapLS( p16
->lParam
);
2578 p16
->lParam
= *((LPARAM
*)items
- 1);
2579 for (i
= 0; i
< p16
->wParam
; i
++) *((LPINT
)(p16
->lParam
) + i
) = items
[i
];
2580 HeapFree( GetProcessHeap(), 0, (LPARAM
*)items
- 1 );
2586 *((PUINT
)(wParam
)) = LOWORD(p16
->lResult
);
2588 *((PUINT
)(lParam
)) = HIWORD(p16
->lResult
); /* FIXME: substract 1? */
2591 case WM_MEASUREITEM
:
2593 MEASUREITEMSTRUCT16
*mis
= MapSL(p16
->lParam
);
2594 MEASUREITEMSTRUCT
*mis32
= *(MEASUREITEMSTRUCT
**)(mis
+ 1);
2595 mis32
->itemWidth
= mis
->itemWidth
;
2596 mis32
->itemHeight
= mis
->itemHeight
;
2597 UnMapLS( p16
->lParam
);
2598 HeapFree( GetProcessHeap(), 0, mis
);
2601 case WM_GETMINMAXINFO
:
2603 MINMAXINFO16
*mmi
= MapSL(p16
->lParam
);
2604 UnMapLS( p16
->lParam
);
2605 p16
->lParam
= *(LPARAM
*)(mmi
+ 1);
2606 MINMAXINFO16to32( mmi
, (MINMAXINFO
*)(p16
->lParam
) );
2607 HeapFree( GetProcessHeap(), 0, mmi
);
2611 case WM_ASKCBFORMATNAME
:
2613 LPSTR str
= MapSL(p16
->lParam
);
2614 UnMapLS( p16
->lParam
);
2615 p16
->lParam
= *((LPARAM
*)str
- 1);
2616 lstrcpynA( (LPSTR
)(p16
->lParam
), str
, p16
->wParam
);
2617 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
- 1 );
2622 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2623 UnMapLS( cs
->szTitle
);
2624 UnMapLS( cs
->szClass
);
2625 UnMapLS( p16
->lParam
);
2626 HeapFree( GetProcessHeap(), 0, cs
);
2629 case WM_MDIGETACTIVE
:
2630 if (lParam
) *(BOOL
*)lParam
= (BOOL16
)HIWORD(p16
->lResult
);
2631 p16
->lResult
= (LRESULT
)WIN_Handle32( LOWORD(p16
->lResult
) );
2635 NCCALCSIZE_PARAMS
*nc32
;
2636 NCCALCSIZE_PARAMS16
*nc
= MapSL(p16
->lParam
);
2637 UnMapLS( p16
->lParam
);
2638 p16
->lParam
= *(LPARAM
*)(nc
+ 1);
2639 nc32
= (NCCALCSIZE_PARAMS
*)(p16
->lParam
);
2640 nc32
->rgrc
[0].left
= nc
->rgrc
[0].left
;
2641 nc32
->rgrc
[0].top
= nc
->rgrc
[0].top
;
2642 nc32
->rgrc
[0].right
= nc
->rgrc
[0].right
;
2643 nc32
->rgrc
[0].bottom
= nc
->rgrc
[0].bottom
;
2646 WINDOWPOS16
*pos
= MapSL(nc
->lppos
);
2647 UnMapLS( nc
->lppos
);
2648 nc32
->rgrc
[1].left
= nc
->rgrc
[1].left
;
2649 nc32
->rgrc
[1].top
= nc
->rgrc
[1].top
;
2650 nc32
->rgrc
[1].right
= nc
->rgrc
[1].right
;
2651 nc32
->rgrc
[1].bottom
= nc
->rgrc
[1].bottom
;
2652 nc32
->rgrc
[2].left
= nc
->rgrc
[2].left
;
2653 nc32
->rgrc
[2].top
= nc
->rgrc
[2].top
;
2654 nc32
->rgrc
[2].right
= nc
->rgrc
[2].right
;
2655 nc32
->rgrc
[2].bottom
= nc
->rgrc
[2].bottom
;
2656 WINDOWPOS16to32( pos
, nc32
->lppos
);
2657 HeapFree( GetProcessHeap(), 0, pos
);
2659 HeapFree( GetProcessHeap(), 0, nc
);
2665 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2666 UnMapLS( p16
->lParam
);
2667 UnMapLS( cs
->lpszName
);
2668 UnMapLS( cs
->lpszClass
);
2669 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2671 MDICREATESTRUCT16
*mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs
->lpCreateParams
);
2672 UnMapLS( cs
->lpCreateParams
);
2673 UnMapLS( mdi_cs16
->szTitle
);
2674 UnMapLS( mdi_cs16
->szClass
);
2675 HeapFree(GetProcessHeap(), 0, mdi_cs16
);
2677 HeapFree( GetProcessHeap(), 0, cs
);
2680 case WM_WINDOWPOSCHANGING
:
2681 case WM_WINDOWPOSCHANGED
:
2683 WINDOWPOS16
*wp
= MapSL(p16
->lParam
);
2684 UnMapLS( p16
->lParam
);
2685 p16
->lParam
= *(LPARAM
*)(wp
+ 1);
2686 WINDOWPOS16to32( wp
, (WINDOWPOS
*)p16
->lParam
);
2687 HeapFree( GetProcessHeap(), 0, wp
);
2691 UnMapLS(p16
->lParam
);
2696 LPMSG16 msg16
= MapSL(p16
->lParam
);
2698 UnMapLS( p16
->lParam
);
2699 msgp16
.wParam
=msg16
->wParam
;
2700 msgp16
.lParam
=msg16
->lParam
;
2701 WINPROC_UnmapMsg32ATo16(((LPMSG
)lParam
)->hwnd
, ((LPMSG
)lParam
)->message
,
2702 ((LPMSG
)lParam
)->wParam
, ((LPMSG
)lParam
)->lParam
,
2704 HeapFree( GetProcessHeap(), 0, msg16
);
2709 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
2710 next
->hmenuNext
= HMENU_32( LOWORD(p16
->lResult
) );
2711 next
->hwndNext
= WIN_Handle32( HIWORD(p16
->lResult
) );
2719 /**********************************************************************
2720 * WINPROC_MapMsg32WTo16
2722 * Map a message from 32-bit Unicode to 16-bit.
2723 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
2725 INT
WINPROC_MapMsg32WTo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
2726 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
2732 *pmsg16
= LOWORD(msg32
);
2733 *pwparam16
= LOWORD(wParam32
);
2738 case LB_FINDSTRINGEXACT
:
2739 case LB_INSERTSTRING
:
2740 case LB_SELECTSTRING
:
2743 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2744 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2749 case CB_FINDSTRINGEXACT
:
2750 case CB_INSERTSTRING
:
2751 case CB_SELECTSTRING
:
2753 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2754 *pmsg16
= (UINT16
)msg32
+ (CB_ADDSTRING16
- CB_ADDSTRING
);
2761 CREATESTRUCTW
*cs32
= (CREATESTRUCTW
*)*plparam
;
2763 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16
) ))) return -1;
2764 CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs32
, cs
);
2765 cs
->lpszName
= map_str_32W_to_16( cs32
->lpszName
);
2766 cs
->lpszClass
= map_str_32W_to_16( cs32
->lpszClass
);
2768 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2770 MDICREATESTRUCT16
*mdi_cs16
;
2771 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)cs32
->lpCreateParams
;
2772 mdi_cs16
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs16
));
2775 HeapFree(GetProcessHeap(), 0, cs
);
2778 MDICREATESTRUCT32Ato16((MDICREATESTRUCTA
*)mdi_cs
, mdi_cs16
);
2779 mdi_cs16
->szTitle
= map_str_32W_to_16(mdi_cs
->szTitle
);
2780 mdi_cs16
->szClass
= map_str_32W_to_16(mdi_cs
->szClass
);
2781 cs
->lpCreateParams
= MapLS(mdi_cs16
);
2783 *plparam
= MapLS(cs
);
2788 MDICREATESTRUCT16
*cs
;
2789 MDICREATESTRUCTW
*cs32
= (MDICREATESTRUCTW
*)*plparam
;
2791 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16
) ))) return -1;
2792 MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs32
, cs
);
2793 cs
->szTitle
= map_str_32W_to_16( cs32
->szTitle
);
2794 cs
->szClass
= map_str_32W_to_16( cs32
->szClass
);
2795 *plparam
= MapLS(cs
);
2799 case WM_WININICHANGE
:
2800 case WM_DEVMODECHANGE
:
2801 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2804 if ( WINPROC_TestLBForStr( hwnd
))
2806 LPSTR str
= HeapAlloc( GetProcessHeap(), 0, 512 ); /* FIXME: fixed sized buffer */
2807 if (!str
) return -1;
2808 *pmsg16
= LB_GETTEXT16
;
2809 *plparam
= (LPARAM
)MapLS(str
);
2813 if ( WINPROC_TestCBForStr( hwnd
))
2815 LPSTR str
= HeapAlloc( GetProcessHeap(), 0, 512 ); /* FIXME: fixed sized buffer */
2816 if (!str
) return -1;
2817 *pmsg16
= CB_GETLBTEXT16
;
2818 *plparam
= (LPARAM
)MapLS(str
);
2823 wch
= LOWORD(wParam32
);
2824 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2826 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
2829 wch
= LOWORD(wParam32
);
2830 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2832 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2837 case WM_SYSDEADCHAR
:
2839 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)&ch
, 1, NULL
, NULL
);
2847 if (WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, (LPSTR
)ch
, 2, NULL
, NULL
) == 2)
2848 *pwparam16
= (ch
[0] << 8) | ch
[1];
2854 default: /* No Unicode translation needed (?) */
2855 return WINPROC_MapMsg32ATo16( hwnd
, msg32
, wParam32
, pmsg16
,
2856 pwparam16
, plparam
);
2861 /**********************************************************************
2862 * WINPROC_UnmapMsg32WTo16
2864 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2866 void WINPROC_UnmapMsg32WTo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2873 case LB_FINDSTRINGEXACT
:
2874 case LB_INSERTSTRING
:
2875 case LB_SELECTSTRING
:
2880 case CB_FINDSTRINGEXACT
:
2881 case CB_INSERTSTRING
:
2882 case CB_SELECTSTRING
:
2885 case WM_WININICHANGE
:
2886 case WM_DEVMODECHANGE
:
2887 unmap_str_32W_to_16( p16
->lParam
);
2892 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2893 UnMapLS( p16
->lParam
);
2894 unmap_str_32W_to_16( cs
->lpszName
);
2895 unmap_str_32W_to_16( cs
->lpszClass
);
2897 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2899 MDICREATESTRUCT16
*mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs
->lpCreateParams
);
2900 UnMapLS( cs
->lpCreateParams
);
2901 unmap_str_32W_to_16(mdi_cs16
->szTitle
);
2902 unmap_str_32W_to_16(mdi_cs16
->szClass
);
2903 HeapFree(GetProcessHeap(), 0, mdi_cs16
);
2905 HeapFree( GetProcessHeap(), 0, cs
);
2910 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2911 UnMapLS( p16
->lParam
);
2912 unmap_str_32W_to_16( cs
->szTitle
);
2913 unmap_str_32W_to_16( cs
->szClass
);
2914 HeapFree( GetProcessHeap(), 0, cs
);
2918 case WM_ASKCBFORMATNAME
:
2920 LPSTR str
= MapSL(p16
->lParam
);
2921 UnMapLS( p16
->lParam
);
2922 p16
->lParam
= *((LPARAM
*)str
- 1);
2923 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)p16
->lParam
, 0x7fffffff );
2924 p16
->lResult
= strlenW( (LPWSTR
)p16
->lParam
);
2925 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
- 1 );
2929 if ( WINPROC_TestLBForStr( hwnd
))
2931 LPSTR str
= MapSL(p16
->lParam
);
2932 UnMapLS( p16
->lParam
);
2933 p16
->lResult
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff ) - 1;
2934 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
);
2938 if ( WINPROC_TestCBForStr( hwnd
))
2940 LPSTR str
= MapSL(p16
->lParam
);
2941 UnMapLS( p16
->lParam
);
2942 p16
->lResult
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff ) - 1;
2943 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
);
2947 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, p16
);
2953 /**********************************************************************
2954 * WINPROC_CallProc32ATo32W
2956 * Call a window procedure, translating args from Ansi to Unicode.
2958 static LRESULT
WINPROC_CallProc32ATo32W( WNDPROC func
, HWND hwnd
,
2959 UINT msg
, WPARAM wParam
,
2965 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2966 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2968 if( (unmap
= WINPROC_MapMsg32ATo32W( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
2969 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
2970 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2973 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2974 if (unmap
) result
= WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
, func
);
2979 /**********************************************************************
2980 * WINPROC_CallProc32WTo32A_fast
2983 static BOOL
WINPROC_CallProc32WTo32A_fast( WNDPROC func
, HWND hwnd
,
2984 UINT msg
, WPARAM wParam
,
2985 LPARAM lParam
, LRESULT
*result
)
2991 { /* csW->lpszName and csW->lpszClass are NOT supposed to be atoms
2995 char *cls
= buffer
, *name
;
2996 CREATESTRUCTW
*csW
= (CREATESTRUCTW
*)lParam
;
2997 CREATESTRUCTA csA
= *(CREATESTRUCTA
*)csW
;
2998 MDICREATESTRUCTA mdi_cs
;
2999 DWORD name_lenA
, name_lenW
, class_lenA
, class_lenW
;
3001 class_lenW
= strlenW(csW
->lpszClass
) * sizeof(WCHAR
);
3002 RtlUnicodeToMultiByteSize(&class_lenA
, csW
->lpszClass
, class_lenW
);
3006 name_lenW
= strlenW(csW
->lpszName
) * sizeof(WCHAR
);
3007 RtlUnicodeToMultiByteSize(&name_lenA
, csW
->lpszName
, name_lenW
);
3010 name_lenW
= name_lenA
= 0;
3012 if (class_lenA
+ name_lenA
+ 2 > sizeof(buffer
))
3014 cls
= HeapAlloc(GetProcessHeap(), 0, class_lenA
+ name_lenA
+ 2);
3015 if (!cls
) return FALSE
;
3018 RtlUnicodeToMultiByteN(cls
, class_lenA
, NULL
, csW
->lpszClass
, class_lenW
);
3019 cls
[class_lenA
] = 0;
3020 csA
.lpszClass
= cls
;
3024 name
= cls
+ class_lenA
+ 1;
3025 RtlUnicodeToMultiByteN(name
, name_lenA
, NULL
, csW
->lpszName
, name_lenW
);
3026 name
[name_lenA
] = 0;
3027 csA
.lpszName
= name
;
3030 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
3032 mdi_cs
= *(MDICREATESTRUCTA
*)csW
->lpCreateParams
;
3033 mdi_cs
.szTitle
= csA
.lpszName
;
3034 mdi_cs
.szClass
= csA
.lpszClass
;
3035 csA
.lpCreateParams
= &mdi_cs
;
3038 lParam
= (LPARAM
)&csA
;
3039 *result
= WINPROC_CallWndProc(func
, hwnd
, msg
, wParam
, lParam
);
3041 if (cls
!= buffer
) HeapFree(GetProcessHeap(), 0, cls
);
3050 /**********************************************************************
3051 * WINPROC_CallProc32WTo32A
3053 * Call a window procedure, translating args from Unicode to Ansi.
3055 static LRESULT
WINPROC_CallProc32WTo32A( WNDPROC func
, HWND hwnd
,
3056 UINT msg
, WPARAM wParam
,
3062 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3063 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3065 if (WINPROC_CallProc32WTo32A_fast( func
, hwnd
, msg
, wParam
, lParam
, &result
))
3068 if ((unmap
= WINPROC_MapMsg32WTo32A( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
3069 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
3070 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3073 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3074 if( unmap
) result
= WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
, result
);
3079 /**********************************************************************
3080 * WINPROC_CallProc16To32A
3082 static LRESULT
WINPROC_CallProc16To32A( WNDPROC func
, HWND16 hwnd
, UINT16 msg
,
3083 WPARAM16 wParam
, LPARAM lParam
)
3088 HWND hwnd32
= WIN_Handle32( hwnd
);
3090 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3091 func
, hwnd32
, SPY_GetMsgName(msg
, hwnd32
), wParam
, lParam
);
3093 if (WINPROC_MapMsg16To32A( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
3095 result
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
3096 return WINPROC_UnmapMsg16To32A( hwnd32
, msg32
, wParam32
, lParam
, result
);
3100 /**********************************************************************
3101 * WINPROC_CallProc16To32W
3103 static LRESULT
WINPROC_CallProc16To32W( WNDPROC func
, HWND16 hwnd
, UINT16 msg
,
3104 WPARAM16 wParam
, LPARAM lParam
)
3109 HWND hwnd32
= WIN_Handle32( hwnd
);
3111 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3112 func
, hwnd32
, SPY_GetMsgName(msg
, hwnd32
), wParam
, lParam
);
3114 if (WINPROC_MapMsg16To32W( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
3116 result
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
3117 return WINPROC_UnmapMsg16To32W( hwnd32
, msg32
, wParam32
, lParam
, result
,
3122 /**********************************************************************
3123 * __wine_call_wndproc (USER.1010)
3125 LRESULT WINAPI
__wine_call_wndproc( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
,
3128 if (proc
->procA
) return WINPROC_CallProc16To32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3129 else return WINPROC_CallProc16To32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3133 /**********************************************************************
3134 * WINPROC_CallProc32ATo16
3136 * Call a 16-bit window procedure, translating the 32-bit args.
3138 static LRESULT
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
3139 UINT msg
, WPARAM wParam
, LPARAM lParam
)
3144 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3145 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3147 mp16
.lParam
= lParam
;
3148 if (WINPROC_MapMsg32ATo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
3150 mp16
.lResult
= WINPROC_CallWndProc16( func
, HWND_16(hwnd
), msg16
,
3151 mp16
.wParam
, mp16
.lParam
);
3152 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3153 return mp16
.lResult
;
3157 /**********************************************************************
3158 * WINPROC_CallProc32WTo16
3160 * Call a 16-bit window procedure, translating the 32-bit args.
3162 static LRESULT
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
3163 UINT msg
, WPARAM wParam
, LPARAM lParam
)
3168 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3169 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3171 mp16
.lParam
= lParam
;
3172 if (WINPROC_MapMsg32WTo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
,
3173 &mp16
.lParam
) == -1)
3175 mp16
.lResult
= WINPROC_CallWndProc16( func
, HWND_16(hwnd
), msg16
,
3176 mp16
.wParam
, mp16
.lParam
);
3177 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3178 return mp16
.lResult
;
3182 /**********************************************************************
3183 * CallWindowProc (USER.122)
3185 LRESULT WINAPI
CallWindowProc16( WNDPROC16 func
, HWND16 hwnd
, UINT16 msg
,
3186 WPARAM16 wParam
, LPARAM lParam
)
3190 if (!func
) return 0;
3192 if (!(proc
= handle16_to_proc( func
)))
3193 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
3195 if (proc
->procA
) return WINPROC_CallProc16To32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3196 if (proc
->procW
) return WINPROC_CallProc16To32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3197 return WINPROC_CallWndProc16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
);
3201 /**********************************************************************
3202 * CallWindowProcA (USER32.@)
3204 * The CallWindowProc() function invokes the windows procedure _func_,
3205 * with _hwnd_ as the target window, the message specified by _msg_, and
3206 * the message parameters _wParam_ and _lParam_.
3208 * Some kinds of argument conversion may be done, I'm not sure what.
3210 * CallWindowProc() may be used for windows subclassing. Use
3211 * SetWindowLong() to set a new windows procedure for windows of the
3212 * subclass, and handle subclassed messages in the new windows
3213 * procedure. The new windows procedure may then use CallWindowProc()
3214 * with _func_ set to the parent class's windows procedure to dispatch
3215 * the message to the superclass.
3219 * The return value is message dependent.
3225 LRESULT WINAPI
CallWindowProcA(
3226 WNDPROC func
, /* [in] window procedure */
3227 HWND hwnd
, /* [in] target window */
3228 UINT msg
, /* [in] message */
3229 WPARAM wParam
, /* [in] message dependent parameter */
3230 LPARAM lParam
/* [in] message dependent parameter */
3234 if (!func
) return 0;
3236 if (!(proc
= handle_to_proc( func
)))
3237 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3239 if (proc
->procA
) return WINPROC_CallWndProc( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3240 if (proc
->procW
) return WINPROC_CallProc32ATo32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3241 return WINPROC_CallProc32ATo16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
);
3245 /**********************************************************************
3246 * CallWindowProcW (USER32.@)
3248 * See CallWindowProcA.
3250 LRESULT WINAPI
CallWindowProcW( WNDPROC func
, HWND hwnd
, UINT msg
,
3251 WPARAM wParam
, LPARAM lParam
)
3255 if (!func
) return 0;
3257 if (!(proc
= handle_to_proc( func
)))
3258 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3260 if (proc
->procW
) return WINPROC_CallWndProc( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3261 if (proc
->procA
) return WINPROC_CallProc32WTo32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3262 return WINPROC_CallProc32WTo16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
);
3266 /**********************************************************************
3267 * WINPROC_CallDlgProc16
3269 INT_PTR
WINPROC_CallDlgProc16( DLGPROC16 func
, HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
)
3273 if (!func
) return 0;
3275 if (!(proc
= handle16_to_proc( (WNDPROC16
)func
)))
3276 return LOWORD( WINPROC_CallWndProc16( (WNDPROC16
)func
, hwnd
, msg
, wParam
, lParam
) );
3278 if (proc
->procA
) return WINPROC_CallProc16To32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3279 if (proc
->procW
) return WINPROC_CallProc16To32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3280 return LOWORD( WINPROC_CallWndProc16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
) );
3284 /**********************************************************************
3285 * WINPROC_CallDlgProcA
3287 INT_PTR
WINPROC_CallDlgProcA( DLGPROC func
, HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3291 if (!func
) return 0;
3293 if (!(proc
= handle_to_proc( (WNDPROC
)func
)))
3294 return WINPROC_CallWndProc( (WNDPROC
)func
, hwnd
, msg
, wParam
, lParam
);
3296 if (proc
->procA
) return WINPROC_CallWndProc( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3297 if (proc
->procW
) return WINPROC_CallProc32ATo32W( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3298 return LOWORD( WINPROC_CallProc32ATo16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
) );
3302 /**********************************************************************
3303 * WINPROC_CallDlgProcW
3305 INT_PTR
WINPROC_CallDlgProcW( DLGPROC func
, HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3309 if (!func
) return 0;
3311 if (!(proc
= handle_to_proc( (WNDPROC
)func
)))
3312 return WINPROC_CallWndProc( (WNDPROC
)func
, hwnd
, msg
, wParam
, lParam
);
3314 if (proc
->procW
) return WINPROC_CallWndProc( proc
->procW
, hwnd
, msg
, wParam
, lParam
);
3315 if (proc
->procA
) return WINPROC_CallProc32WTo32A( proc
->procA
, hwnd
, msg
, wParam
, lParam
);
3316 return LOWORD( WINPROC_CallProc32WTo16( proc
->proc16
, hwnd
, msg
, wParam
, lParam
));