2 * Window procedure callbacks
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1996 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
32 #include "wine/winbase16.h"
33 #include "wine/winuser16.h"
34 #include "stackframe.h"
40 #include "user_private.h"
44 #include "wine/unicode.h"
45 #include "wine/debug.h"
47 WINE_DECLARE_DEBUG_CHANNEL(msg
);
48 WINE_DECLARE_DEBUG_CHANNEL(relay
);
49 WINE_DEFAULT_DEBUG_CHANNEL(win
);
55 /* Window procedure 16-to-32-bit thunk */
58 BYTE popl_eax
; /* popl %eax (return address) */
59 BYTE pushl_func
; /* pushl $proc */
61 BYTE pushl_eax
; /* pushl %eax */
62 BYTE ljmp
; /* ljmp relay*/
63 DWORD relay_offset
; /* __wine_call_wndproc_32A/W */
65 } WINPROC_THUNK_FROM16
;
67 /* Window procedure 32-to-16-bit thunk */
70 BYTE popl_eax
; /* popl %eax (return address) */
71 BYTE pushl_func
; /* pushl $proc */
73 BYTE pushl_eax
; /* pushl %eax */
74 BYTE jmp
; /* jmp relay (relative jump)*/
75 void (*relay
)(); /* WINPROC_CallProc32ATo16() */
76 } WINPROC_THUNK_FROM32
;
78 /* Simple jmp to call 32-bit procedure directly */
81 BYTE jmp
; /* jmp proc (relative jump) */
92 } WINPROC_THUNK_FROM16
;
97 } WINPROC_THUNK_FROM32
;
104 #endif /* __i386__ */
108 WINPROC_THUNK_FROM16 t_from16
;
109 WINPROC_THUNK_FROM32 t_from32
;
112 typedef struct tagWINDOWPROC
114 WINPROC_THUNK thunk
; /* Thunk */
115 WINPROC_JUMP jmp
; /* Jump */
116 BYTE type
; /* Function type */
119 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
120 UINT msg
, WPARAM wParam
,
122 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
123 UINT msg
, WPARAM wParam
,
126 #define MAX_WINPROCS (0x10000 / sizeof(WINDOWPROC))
128 static WINDOWPROC winproc_array
[MAX_WINPROCS
];
129 static UINT winproc_used
;
131 static CRITICAL_SECTION winproc_cs
;
132 static CRITICAL_SECTION_DEBUG critsect_debug
=
135 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
136 0, 0, { 0, (DWORD
)(__FILE__
": winproc_cs") }
138 static CRITICAL_SECTION winproc_cs
= { &critsect_debug
, -1, 0, 0, 0, 0 };
140 static BOOL
is_valid_winproc( WINDOWPROC
*proc
)
142 /* check alignment */
143 if (((BYTE
*)proc
- (BYTE
*)winproc_array
) % sizeof(*proc
)) return FALSE
;
144 /* check array limits */
145 if (proc
< winproc_array
|| proc
>= winproc_array
+ winproc_used
) return FALSE
;
146 return (proc
->type
!= WIN_PROC_INVALID
);
149 /* find an existing winproc for a given function and type */
150 /* FIXME: probably should do something more clever than a linear search */
151 static inline WINDOWPROC
*find_winproc( WNDPROC func
, WINDOWPROCTYPE type
)
155 if (type
== WIN_PROC_16
)
157 for (i
= 0; i
< winproc_used
; i
++)
159 if (winproc_array
[i
].type
== type
&&
160 winproc_array
[i
].thunk
.t_from32
.proc
== (WNDPROC16
)func
)
161 return &winproc_array
[i
];
166 for (i
= 0; i
< winproc_used
; i
++)
168 if (winproc_array
[i
].type
== type
&&
169 winproc_array
[i
].thunk
.t_from16
.proc
== func
)
170 return &winproc_array
[i
];
176 /* initialize a new winproc */
177 static inline void set_winproc( WINDOWPROC
*proc
, WNDPROC func
, WINDOWPROCTYPE type
)
180 static FARPROC16 relay_32A
, relay_32W
;
185 proc
->thunk
.t_from32
.popl_eax
= 0x58; /* popl %eax */
186 proc
->thunk
.t_from32
.pushl_func
= 0x68; /* pushl $proc */
187 proc
->thunk
.t_from32
.proc
= (WNDPROC16
)func
;
188 proc
->thunk
.t_from32
.pushl_eax
= 0x50; /* pushl %eax */
189 proc
->thunk
.t_from32
.jmp
= 0xe9; /* jmp relay*/
190 proc
->thunk
.t_from32
.relay
= /* relative jump */
191 (void(*)())((DWORD
)WINPROC_CallProc32ATo16
-
192 (DWORD
)(&proc
->thunk
.t_from32
.relay
+ 1));
195 if (!relay_32A
) relay_32A
= GetProcAddress16( GetModuleHandle16("user"),
196 "__wine_call_wndproc_32A" );
197 proc
->thunk
.t_from16
.popl_eax
= 0x58; /* popl %eax */
198 proc
->thunk
.t_from16
.pushl_func
= 0x68; /* pushl $proc */
199 proc
->thunk
.t_from16
.proc
= func
;
200 proc
->thunk
.t_from16
.pushl_eax
= 0x50; /* pushl %eax */
201 proc
->thunk
.t_from16
.ljmp
= 0xea; /* ljmp relay*/
202 proc
->thunk
.t_from16
.relay_offset
= OFFSETOF(relay_32A
);
203 proc
->thunk
.t_from16
.relay_sel
= SELECTOROF(relay_32A
);
204 proc
->jmp
.jmp
= 0xe9;
205 /* Fixup relative jump */
206 proc
->jmp
.proc
= (WNDPROC
)((DWORD
)func
- (DWORD
)(&proc
->jmp
.proc
+ 1));
209 if (!relay_32W
) relay_32W
= GetProcAddress16( GetModuleHandle16("user"),
210 "__wine_call_wndproc_32W" );
211 proc
->thunk
.t_from16
.popl_eax
= 0x58; /* popl %eax */
212 proc
->thunk
.t_from16
.pushl_func
= 0x68; /* pushl $proc */
213 proc
->thunk
.t_from16
.proc
= func
;
214 proc
->thunk
.t_from16
.pushl_eax
= 0x50; /* pushl %eax */
215 proc
->thunk
.t_from16
.ljmp
= 0xea; /* ljmp relay*/
216 proc
->thunk
.t_from16
.relay_offset
= OFFSETOF(relay_32W
);
217 proc
->thunk
.t_from16
.relay_sel
= SELECTOROF(relay_32W
);
218 proc
->jmp
.jmp
= 0xe9;
219 /* Fixup relative jump */
220 proc
->jmp
.proc
= (WNDPROC
)((char *)func
- (char *)(&proc
->jmp
.proc
+ 1));
223 /* Should not happen */
230 proc
->thunk
.t_from32
.proc
= (WNDPROC16
)func
;
234 proc
->thunk
.t_from16
.proc
= func
;
237 /* Should not happen */
240 #endif /* __i386__ */
245 static WORD
get_winproc_selector(void)
247 static LONG winproc_selector
;
250 if (!(ret
= winproc_selector
))
253 WORD sel
= wine_ldt_alloc_entries(1);
254 wine_ldt_set_base( &entry
, winproc_array
);
255 wine_ldt_set_limit( &entry
, sizeof(winproc_array
) - 1 );
256 wine_ldt_set_flags( &entry
, WINE_LDT_FLAGS_CODE
| WINE_LDT_FLAGS_32BIT
);
257 wine_ldt_set_entry( sel
, &entry
);
258 if (!(ret
= InterlockedCompareExchange( &winproc_selector
, sel
, 0 ))) ret
= sel
;
259 else wine_ldt_free_entries( sel
, 1 ); /* somebody beat us to it */
266 /* Some window procedures modify register they shouldn't, or are not
267 * properly declared stdcall; so we need a small assembly wrapper to
269 extern LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
270 WPARAM wParam
, LPARAM lParam
);
271 __ASM_GLOBAL_FUNC( WINPROC_wrapper
,
281 "movl 8(%ebp),%eax\n\t"
283 "leal -12(%ebp),%esp\n\t"
290 static inline LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
291 WPARAM wParam
, LPARAM lParam
)
293 return proc( hwnd
, msg
, wParam
, lParam
);
295 #endif /* __i386__ */
298 static void MINMAXINFO32to16( const MINMAXINFO
*from
, MINMAXINFO16
*to
)
300 to
->ptReserved
.x
= from
->ptReserved
.x
;
301 to
->ptReserved
.y
= from
->ptReserved
.y
;
302 to
->ptMaxSize
.x
= from
->ptMaxSize
.x
;
303 to
->ptMaxSize
.y
= from
->ptMaxSize
.y
;
304 to
->ptMaxPosition
.x
= from
->ptMaxPosition
.x
;
305 to
->ptMaxPosition
.y
= from
->ptMaxPosition
.y
;
306 to
->ptMinTrackSize
.x
= from
->ptMinTrackSize
.x
;
307 to
->ptMinTrackSize
.y
= from
->ptMinTrackSize
.y
;
308 to
->ptMaxTrackSize
.x
= from
->ptMaxTrackSize
.x
;
309 to
->ptMaxTrackSize
.y
= from
->ptMaxTrackSize
.y
;
312 static void MINMAXINFO16to32( const MINMAXINFO16
*from
, MINMAXINFO
*to
)
314 to
->ptReserved
.x
= from
->ptReserved
.x
;
315 to
->ptReserved
.y
= from
->ptReserved
.y
;
316 to
->ptMaxSize
.x
= from
->ptMaxSize
.x
;
317 to
->ptMaxSize
.y
= from
->ptMaxSize
.y
;
318 to
->ptMaxPosition
.x
= from
->ptMaxPosition
.x
;
319 to
->ptMaxPosition
.y
= from
->ptMaxPosition
.y
;
320 to
->ptMinTrackSize
.x
= from
->ptMinTrackSize
.x
;
321 to
->ptMinTrackSize
.y
= from
->ptMinTrackSize
.y
;
322 to
->ptMaxTrackSize
.x
= from
->ptMaxTrackSize
.x
;
323 to
->ptMaxTrackSize
.y
= from
->ptMaxTrackSize
.y
;
326 static void WINDOWPOS32to16( const WINDOWPOS
* from
, WINDOWPOS16
* to
)
328 to
->hwnd
= HWND_16(from
->hwnd
);
329 to
->hwndInsertAfter
= HWND_16(from
->hwndInsertAfter
);
334 to
->flags
= from
->flags
;
337 static void WINDOWPOS16to32( const WINDOWPOS16
* from
, WINDOWPOS
* to
)
339 to
->hwnd
= WIN_Handle32(from
->hwnd
);
340 to
->hwndInsertAfter
= (from
->hwndInsertAfter
== (HWND16
)-1) ?
341 HWND_TOPMOST
: WIN_Handle32(from
->hwndInsertAfter
);
346 to
->flags
= from
->flags
;
349 /* The strings are not copied */
350 static void CREATESTRUCT32Ato16( const CREATESTRUCTA
* from
, CREATESTRUCT16
* to
)
352 to
->lpCreateParams
= (SEGPTR
)from
->lpCreateParams
;
353 to
->hInstance
= HINSTANCE_16(from
->hInstance
);
354 to
->hMenu
= HMENU_16(from
->hMenu
);
355 to
->hwndParent
= HWND_16(from
->hwndParent
);
360 to
->style
= from
->style
;
361 to
->dwExStyle
= from
->dwExStyle
;
364 static void CREATESTRUCT16to32A( const CREATESTRUCT16
* from
, CREATESTRUCTA
*to
)
367 to
->lpCreateParams
= (LPVOID
)from
->lpCreateParams
;
368 to
->hInstance
= HINSTANCE_32(from
->hInstance
);
369 to
->hMenu
= HMENU_32(from
->hMenu
);
370 to
->hwndParent
= WIN_Handle32(from
->hwndParent
);
375 to
->style
= from
->style
;
376 to
->dwExStyle
= from
->dwExStyle
;
379 /* The strings are not copied */
380 static void MDICREATESTRUCT32Ato16( const MDICREATESTRUCTA
* from
, MDICREATESTRUCT16
* to
)
382 to
->hOwner
= HINSTANCE_16(from
->hOwner
);
387 to
->style
= from
->style
;
388 to
->lParam
= from
->lParam
;
391 static void MDICREATESTRUCT16to32A( const MDICREATESTRUCT16
* from
, MDICREATESTRUCTA
*to
)
393 to
->hOwner
= HINSTANCE_32(from
->hOwner
);
398 to
->style
= from
->style
;
399 to
->lParam
= from
->lParam
;
402 /**********************************************************************
403 * WINPROC_CallWndProc32
405 * Call a 32-bit WndProc.
407 static LRESULT
WINPROC_CallWndProc( WNDPROC proc
, HWND hwnd
, UINT msg
,
408 WPARAM wParam
, LPARAM lParam
)
413 hwnd
= WIN_GetFullHandle( hwnd
);
415 DPRINTF( "%04lx:Call window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
416 GetCurrentThreadId(), proc
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
417 /* To avoid any deadlocks, all the locks on the windows structures
418 must be suspended before the control is passed to the application */
419 iWndsLocks
= WIN_SuspendWndsLock();
420 retvalue
= WINPROC_wrapper( proc
, hwnd
, msg
, wParam
, lParam
);
421 WIN_RestoreWndsLock(iWndsLocks
);
424 DPRINTF( "%04lx:Ret window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx) retval=%08lx\n",
425 GetCurrentThreadId(), proc
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
, retvalue
);
429 /***********************************************************************
430 * WINPROC_CallWndProc16
432 * Call a 16-bit window procedure
434 static LRESULT WINAPI
WINPROC_CallWndProc16( WNDPROC16 proc
, HWND16 hwnd
,
435 UINT16 msg
, WPARAM16 wParam
,
442 TEB
*teb
= NtCurrentTeb();
445 /* Window procedures want ax = hInstance, ds = es = ss */
447 memset(&context
, 0, sizeof(context
));
448 context
.SegDs
= context
.SegEs
= SELECTOROF(teb
->cur_stack
);
449 context
.SegFs
= wine_get_fs();
450 context
.SegGs
= wine_get_gs();
451 if (!(context
.Eax
= GetWindowWord( HWND_32(hwnd
), GWLP_HINSTANCE
))) context
.Eax
= context
.SegDs
;
452 context
.SegCs
= SELECTOROF(proc
);
453 context
.Eip
= OFFSETOF(proc
);
454 context
.Ebp
= OFFSETOF(teb
->cur_stack
)
455 + (WORD
)&((STACK16FRAME
*)0)->bp
;
459 /* Some programs (eg. the "Undocumented Windows" examples, JWP) only
460 work if structures passed in lParam are placed in the stack/data
461 segment. Programmers easily make the mistake of converting lParam
462 to a near rather than a far pointer, since Windows apparently
463 allows this. We copy the structures to the 16 bit stack; this is
464 ugly but makes these programs work. */
469 offset
= sizeof(CREATESTRUCT16
); break;
471 offset
= sizeof(DRAWITEMSTRUCT16
); break;
473 offset
= sizeof(COMPAREITEMSTRUCT16
); break;
477 void *s
= MapSL(lParam
);
478 lParam
= stack16_push( offset
);
479 memcpy( MapSL(lParam
), s
, offset
);
483 iWndsLocks
= WIN_SuspendWndsLock();
488 args
[1] = HIWORD(lParam
);
489 args
[0] = LOWORD(lParam
);
490 WOWCallback16Ex( 0, WCB16_REGS
, sizeof(args
), args
, (DWORD
*)&context
);
491 ret
= MAKELONG( LOWORD(context
.Eax
), LOWORD(context
.Edx
) );
493 if (offset
) stack16_pop( offset
);
495 WIN_RestoreWndsLock(iWndsLocks
);
501 /**********************************************************************
504 * Return a pointer to the win proc.
506 static WINDOWPROC
*WINPROC_GetPtr( WNDPROC handle
)
511 /* ptr cannot be < 64K */
512 if (!HIWORD(handle
)) return NULL
;
514 /* Check for a linear pointer */
516 ptr
= (BYTE
*)handle
;
517 /* First check if it is the jmp address */
518 proc
= (WINDOWPROC
*)(ptr
- FIELD_OFFSET(WINDOWPROC
,jmp
));
519 if (is_valid_winproc(proc
)) return proc
;
521 /* Now it must be the thunk address */
522 proc
= (WINDOWPROC
*)(ptr
- FIELD_OFFSET(WINDOWPROC
,thunk
));
523 if (is_valid_winproc(proc
)) return proc
;
525 /* Check for a segmented pointer */
527 if (HIWORD(handle
) == get_winproc_selector())
529 ptr
= (BYTE
*)winproc_array
+ LOWORD(handle
);
530 /* It must be the thunk address */
531 proc
= (WINDOWPROC
*)(ptr
- FIELD_OFFSET(WINDOWPROC
,thunk
));
532 if (is_valid_winproc(proc
)) return proc
;
538 /**********************************************************************
541 * Get a window procedure pointer that can be passed to the Windows program.
543 WNDPROC16
WINPROC_GetProc( WNDPROC proc
, WINDOWPROCTYPE type
)
545 WINDOWPROC
*ptr
= (WINDOWPROC
*)proc
;
547 if (!proc
) return NULL
;
548 if (type
== WIN_PROC_16
) /* We want a 16:16 address */
550 if (ptr
->type
== WIN_PROC_16
)
551 return ptr
->thunk
.t_from32
.proc
;
553 return (WNDPROC16
)MAKESEGPTR( get_winproc_selector(),
554 (char *)&ptr
->thunk
- (char *)winproc_array
);
556 else /* We want a 32-bit address */
558 if (ptr
->type
== WIN_PROC_16
)
559 return (WNDPROC16
)&ptr
->thunk
;
560 else if (type
!= ptr
->type
)
561 /* Have to return the jmp address if types don't match */
562 return (WNDPROC16
)&ptr
->jmp
;
564 /* Some Win16 programs want to get back the proc they set */
565 return (WNDPROC16
)ptr
->thunk
.t_from16
.proc
;
570 /**********************************************************************
573 * Allocate a window procedure for a window or class.
575 * Note that allocated winprocs are never freed; the idea is that even if an app creates a
576 * lot of windows, it will usually only have a limited number of window procedures, so the
577 * array won't grow too large, and this way we avoid the need to track allocations per window.
579 WNDPROC
WINPROC_AllocProc( WNDPROC func
, WINDOWPROCTYPE type
)
583 if (!func
) return NULL
;
585 EnterCriticalSection( &winproc_cs
);
587 /* check if the function is already a win proc */
588 if (!(proc
= WINPROC_GetPtr( func
)))
590 /* then check if we already have a winproc for that function */
591 if (!(proc
= find_winproc( func
, type
)))
593 if (winproc_used
>= MAX_WINPROCS
)
594 FIXME( "too many winprocs, cannot allocate one for %p/%d\n", func
, type
);
597 proc
= &winproc_array
[winproc_used
++];
598 set_winproc( proc
, func
, type
);
599 TRACE( "allocated %p for %p/%d (%d/%d used)\n",
600 proc
, func
, type
, winproc_used
, MAX_WINPROCS
);
603 else TRACE( "reusing %p for %p/%d\n", proc
, func
, type
);
606 LeaveCriticalSection( &winproc_cs
);
607 return (WNDPROC
)proc
;
611 /**********************************************************************
612 * WINPROC_GetProcType
614 * Return the window procedure type.
616 WINDOWPROCTYPE
WINPROC_GetProcType( WNDPROC proc
)
618 if (!proc
) return WIN_PROC_INVALID
;
619 return ((WINDOWPROC
*)proc
)->type
;
621 /**********************************************************************
622 * WINPROC_TestCBForStr
624 * Return TRUE if the lparam is a string
626 inline static BOOL
WINPROC_TestCBForStr( HWND hwnd
)
628 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
629 return (!(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) || (style
& CBS_HASSTRINGS
));
631 /**********************************************************************
632 * WINPROC_TestLBForStr
634 * Return TRUE if the lparam is a string
636 inline static BOOL
WINPROC_TestLBForStr( HWND hwnd
)
638 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
639 return (!(style
& (LBS_OWNERDRAWFIXED
| LBS_OWNERDRAWVARIABLE
)) || (style
& LBS_HASSTRINGS
));
642 /**********************************************************************
643 * WINPROC_MapMsg32ATo32W
645 * Map a message from Ansi to Unicode.
646 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
649 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
650 * the first four bytes are the handle of the icon
651 * when the WM_SETTEXT message has been used to set the icon
653 INT
WINPROC_MapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
658 case WM_ASKCBFORMATNAME
:
660 LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0,
661 *pwparam
* sizeof(WCHAR
) + sizeof(LPARAM
) );
663 *ptr
++ = *plparam
; /* Store previous lParam */
664 *plparam
= (LPARAM
)ptr
;
667 /* lparam is string (0-terminated) */
669 case WM_WININICHANGE
:
670 case WM_DEVMODECHANGE
:
676 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*plparam
, -1, NULL
, 0);
677 WCHAR
*buf
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
678 len
= MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*plparam
, -1, buf
, len
);
679 *plparam
= (LPARAM
)buf
;
680 return (*plparam
? 1 : -1);
682 case WM_GETTEXTLENGTH
:
683 case CB_GETLBTEXTLEN
:
685 return 1; /* need to map result */
689 UNICODE_STRING usBuffer
;
691 { CREATESTRUCTW cs
; /* new structure */
692 LPCWSTR lpszName
; /* allocated Name */
693 LPCWSTR lpszClass
; /* allocated Class */
696 struct s
*xs
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct s
));
698 xs
->cs
= *(CREATESTRUCTW
*)*plparam
;
699 if (HIWORD(xs
->cs
.lpszName
))
701 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)xs
->cs
.lpszName
);
702 xs
->lpszName
= xs
->cs
.lpszName
= usBuffer
.Buffer
;
704 if (HIWORD(xs
->cs
.lpszClass
))
706 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)xs
->cs
.lpszClass
);
707 xs
->lpszClass
= xs
->cs
.lpszClass
= usBuffer
.Buffer
;
710 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
712 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)HeapAlloc(GetProcessHeap(), 0,
714 *mdi_cs
= *(MDICREATESTRUCTW
*)xs
->cs
.lpCreateParams
;
715 if (HIWORD(mdi_cs
->szTitle
))
717 RtlCreateUnicodeStringFromAsciiz(&usBuffer
, (LPCSTR
)mdi_cs
->szTitle
);
718 mdi_cs
->szTitle
= usBuffer
.Buffer
;
720 if (HIWORD(mdi_cs
->szClass
))
722 RtlCreateUnicodeStringFromAsciiz(&usBuffer
, (LPCSTR
)mdi_cs
->szClass
);
723 mdi_cs
->szClass
= usBuffer
.Buffer
;
725 xs
->cs
.lpCreateParams
= mdi_cs
;
728 *plparam
= (LPARAM
)xs
;
733 MDICREATESTRUCTW
*cs
=
734 (MDICREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
736 *cs
= *(MDICREATESTRUCTW
*)*plparam
;
737 if (HIWORD(cs
->szClass
))
739 UNICODE_STRING usBuffer
;
740 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)cs
->szClass
);
741 cs
->szClass
= usBuffer
.Buffer
;
743 if (HIWORD(cs
->szTitle
))
745 UNICODE_STRING usBuffer
;
746 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)cs
->szTitle
);
747 cs
->szTitle
= usBuffer
.Buffer
;
749 *plparam
= (LPARAM
)cs
;
755 case LB_INSERTSTRING
:
757 case LB_FINDSTRINGEXACT
:
758 case LB_SELECTSTRING
:
759 if(!*plparam
) return 0;
760 if ( WINPROC_TestLBForStr( hwnd
))
762 UNICODE_STRING usBuffer
;
763 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)*plparam
);
764 *plparam
= (LPARAM
)usBuffer
.Buffer
;
766 return (*plparam
? 1 : -1);
768 case LB_GETTEXT
: /* FIXME: fixed sized buffer */
769 { if ( WINPROC_TestLBForStr( hwnd
))
770 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR
) + sizeof(LPARAM
) );
772 *ptr
++ = *plparam
; /* Store previous lParam */
773 *plparam
= (LPARAM
)ptr
;
780 case CB_INSERTSTRING
:
781 case CB_FINDSTRINGEXACT
:
783 case CB_SELECTSTRING
:
784 if(!*plparam
) return 0;
785 if ( WINPROC_TestCBForStr( hwnd
))
787 UNICODE_STRING usBuffer
;
788 RtlCreateUnicodeStringFromAsciiz(&usBuffer
,(LPCSTR
)*plparam
);
789 *plparam
= (LPARAM
)usBuffer
.Buffer
;
791 return (*plparam
? 1 : -1);
793 case CB_GETLBTEXT
: /* FIXME: fixed sized buffer */
794 { if ( WINPROC_TestCBForStr( hwnd
))
795 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR
) + sizeof(LPARAM
) );
797 *ptr
++ = *plparam
; /* Store previous lParam */
798 *plparam
= (LPARAM
)ptr
;
805 { WORD len
= (WORD
)*plparam
;
806 LPARAM
*ptr
= (LPARAM
*) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(WCHAR
) );
808 *ptr
++ = *plparam
; /* Store previous lParam */
809 *((WORD
*) ptr
) = len
; /* Store the length */
810 *plparam
= (LPARAM
)ptr
;
820 case EM_SETPASSWORDCHAR
:
822 BYTE ch
= LOWORD(*pwparam
);
824 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wch
, 1);
825 *pwparam
= MAKEWPARAM( wch
, HIWORD(*pwparam
) );
833 ch
[0] = (*pwparam
>> 8);
834 ch
[1] = *pwparam
& 0xff;
836 MultiByteToWideChar(CP_ACP
, 0, ch
, 2, &wch
, 1);
838 MultiByteToWideChar(CP_ACP
, 0, &ch
[1], 1, &wch
, 1);
839 *pwparam
= MAKEWPARAM( wch
, HIWORD(*pwparam
) );
843 case WM_PAINTCLIPBOARD
:
844 case WM_SIZECLIPBOARD
:
845 FIXME_(msg
)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg
, hwnd
), msg
);
847 default: /* No translation needed */
853 /**********************************************************************
854 * WINPROC_UnmapMsg32ATo32W
856 * Unmap a message that was mapped from Ansi to Unicode.
858 LRESULT
WINPROC_UnmapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
864 case WM_ASKCBFORMATNAME
:
866 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
867 if (!wParam
) result
= 0;
868 else if (!(result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
869 (LPSTR
)*ptr
, wParam
, NULL
, NULL
)))
871 ((LPSTR
)*ptr
)[wParam
-1] = 0;
874 else result
--; /* do not count terminating null */
875 HeapFree( GetProcessHeap(), 0, ptr
);
878 case WM_GETTEXTLENGTH
:
879 case CB_GETLBTEXTLEN
:
881 /* there may be one DBCS char for each Unicode char */
887 { CREATESTRUCTW cs
; /* new structure */
888 LPWSTR lpszName
; /* allocated Name */
889 LPWSTR lpszClass
; /* allocated Class */
891 struct s
*xs
= (struct s
*)lParam
;
892 HeapFree( GetProcessHeap(), 0, xs
->lpszName
);
893 HeapFree( GetProcessHeap(), 0, xs
->lpszClass
);
895 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
897 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)xs
->cs
.lpCreateParams
;
898 if (HIWORD(mdi_cs
->szTitle
))
899 HeapFree(GetProcessHeap(), 0, (LPVOID
)mdi_cs
->szTitle
);
900 if (HIWORD(mdi_cs
->szClass
))
901 HeapFree(GetProcessHeap(), 0, (LPVOID
)mdi_cs
->szClass
);
902 HeapFree(GetProcessHeap(), 0, mdi_cs
);
904 HeapFree( GetProcessHeap(), 0, xs
);
910 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
911 if (HIWORD(cs
->szTitle
))
912 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
913 if (HIWORD(cs
->szClass
))
914 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
915 HeapFree( GetProcessHeap(), 0, cs
);
920 case WM_WININICHANGE
:
921 case WM_DEVMODECHANGE
:
926 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
931 case LB_INSERTSTRING
:
933 case LB_FINDSTRINGEXACT
:
934 case LB_SELECTSTRING
:
935 if ( WINPROC_TestLBForStr( hwnd
))
936 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
940 if ( WINPROC_TestLBForStr( hwnd
))
942 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
943 result
= WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
944 (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
) - 1;
945 HeapFree( GetProcessHeap(), 0, ptr
);
951 case CB_INSERTSTRING
:
953 case CB_FINDSTRINGEXACT
:
954 case CB_SELECTSTRING
:
955 if ( WINPROC_TestCBForStr( hwnd
))
956 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
960 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
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0,
999 *pwparam
+ sizeof(LPARAM
) );
1000 if (!ptr
) return -1;
1001 *ptr
++ = *plparam
; /* Store previous lParam */
1002 *plparam
= (LPARAM
)ptr
;
1007 case WM_WININICHANGE
:
1008 case WM_DEVMODECHANGE
:
1013 if(!*plparam
) return 0;
1014 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
1015 return (*plparam
? 1 : -1);
1019 MDICREATESTRUCTA
*cs
=
1020 (MDICREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
1022 *cs
= *(MDICREATESTRUCTA
*)*plparam
;
1023 if (HIWORD(cs
->szTitle
))
1024 cs
->szTitle
= HEAP_strdupWtoA( GetProcessHeap(), 0,
1025 (LPCWSTR
)cs
->szTitle
);
1026 if (HIWORD(cs
->szClass
))
1027 cs
->szClass
= HEAP_strdupWtoA( GetProcessHeap(), 0,
1028 (LPCWSTR
)cs
->szClass
);
1029 *plparam
= (LPARAM
)cs
;
1035 case LB_INSERTSTRING
:
1037 case LB_FINDSTRINGEXACT
:
1038 case LB_SELECTSTRING
:
1039 if(!*plparam
) return 0;
1040 if ( WINPROC_TestLBForStr( hwnd
))
1041 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
1042 return (*plparam
? 1 : -1);
1044 case LB_GETTEXT
: /* FIXME: fixed sized buffer */
1045 { if ( WINPROC_TestLBForStr( hwnd
))
1046 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM
) );
1047 if (!ptr
) return -1;
1048 *ptr
++ = *plparam
; /* Store previous lParam */
1049 *plparam
= (LPARAM
)ptr
;
1056 case CB_INSERTSTRING
:
1058 case CB_FINDSTRINGEXACT
:
1059 case CB_SELECTSTRING
:
1060 if(!*plparam
) return 0;
1061 if ( WINPROC_TestCBForStr( hwnd
))
1062 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
1063 return (*plparam
? 1 : -1);
1065 case CB_GETLBTEXT
: /* FIXME: fixed sized buffer */
1066 { if ( WINPROC_TestCBForStr( hwnd
))
1067 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM
) );
1068 if (!ptr
) return -1;
1069 *ptr
++ = *plparam
; /* Store previous lParam */
1070 *plparam
= (LPARAM
)ptr
;
1075 /* Multiline edit */
1077 { WORD len
= (WORD
)*plparam
;
1078 LPARAM
*ptr
= (LPARAM
*) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(CHAR
) );
1079 if (!ptr
) return -1;
1080 *ptr
++ = *plparam
; /* Store previous lParam */
1081 *((WORD
*) ptr
) = len
; /* Store the length */
1082 *plparam
= (LPARAM
)ptr
;
1091 case WM_SYSDEADCHAR
:
1092 case EM_SETPASSWORDCHAR
:
1094 WCHAR wch
= LOWORD(*pwparam
);
1096 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
1097 *pwparam
= MAKEWPARAM( ch
, HIWORD(*pwparam
) );
1103 WCHAR wch
= LOWORD(*pwparam
);
1106 if (WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, ch
, 2, NULL
, NULL
) == 2)
1107 *pwparam
= MAKEWPARAM( (ch
[0] << 8) | ch
[1], HIWORD(*pwparam
) );
1109 *pwparam
= MAKEWPARAM( ch
[0], HIWORD(*pwparam
) );
1113 case WM_PAINTCLIPBOARD
:
1114 case WM_SIZECLIPBOARD
:
1115 FIXME_(msg
)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg
, hwnd
),msg
);
1117 default: /* No translation needed */
1123 /**********************************************************************
1124 * WINPROC_UnmapMsg32WTo32A
1126 * Unmap a message that was mapped from Unicode to Ansi.
1128 static LRESULT
WINPROC_UnmapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
, LRESULT result
)
1133 case WM_ASKCBFORMATNAME
:
1135 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1136 if (!wParam
) result
= 0;
1137 else if (!(result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1,
1138 (LPWSTR
)*ptr
, wParam
)))
1140 ((LPWSTR
)*ptr
)[wParam
-1] = 0;
1141 result
= wParam
- 1;
1143 else result
--; /* do not count terminating null */
1144 HeapFree( GetProcessHeap(), 0, ptr
);
1149 case WM_WININICHANGE
:
1150 case WM_DEVMODECHANGE
:
1155 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1160 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1161 if (HIWORD(cs
->szTitle
))
1162 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
1163 if (HIWORD(cs
->szClass
))
1164 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
1165 HeapFree( GetProcessHeap(), 0, cs
);
1171 case LB_INSERTSTRING
:
1173 case LB_FINDSTRINGEXACT
:
1174 case LB_SELECTSTRING
:
1175 if ( WINPROC_TestLBForStr( hwnd
))
1176 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1180 if ( WINPROC_TestLBForStr( hwnd
))
1182 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1183 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff ) - 1;
1184 HeapFree( GetProcessHeap(), 0, ptr
);
1190 case CB_INSERTSTRING
:
1192 case CB_FINDSTRINGEXACT
:
1193 case CB_SELECTSTRING
:
1194 if ( WINPROC_TestCBForStr( hwnd
))
1195 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1199 if ( WINPROC_TestCBForStr( hwnd
))
1201 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1202 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff ) - 1;
1203 HeapFree( GetProcessHeap(), 0, ptr
);
1207 /* Multiline edit */
1210 LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lparam */
1211 WORD len
= *(WORD
*)ptr
;
1214 result
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, result
, (LPWSTR
)*ptr
, len
);
1215 if (result
< len
) ((LPWSTR
)*ptr
)[result
] = 0;
1217 HeapFree( GetProcessHeap(), 0, ptr
);
1224 static UINT
convert_handle_16_to_32(HANDLE16 src
, unsigned int flags
)
1227 UINT sz
= GlobalSize16(src
);
1230 if (!(dst
= GlobalAlloc(flags
, sz
)))
1232 ptr16
= GlobalLock16(src
);
1233 ptr32
= GlobalLock(dst
);
1234 if (ptr16
!= NULL
&& ptr32
!= NULL
) memcpy(ptr32
, ptr16
, sz
);
1235 GlobalUnlock16(src
);
1241 /**********************************************************************
1242 * WINPROC_MapMsg16To32A
1244 * Map a message from 16- to 32-bit Ansi.
1245 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1247 INT
WINPROC_MapMsg16To32A( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1248 WPARAM
*pwparam32
, LPARAM
*plparam
)
1250 *pmsg32
= (UINT
)msg16
;
1251 *pwparam32
= (WPARAM
)wParam16
;
1258 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1259 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1263 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1264 *plparam
= (LPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1267 if ( HIWORD(*plparam
) > CTLCOLOR_STATIC
) return -1;
1268 *pmsg32
= WM_CTLCOLORMSGBOX
+ HIWORD(*plparam
);
1269 *pwparam32
= (WPARAM
)HDC_32(wParam16
);
1270 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1272 case WM_COMPAREITEM
:
1274 COMPAREITEMSTRUCT16
* cis16
= MapSL(*plparam
);
1275 COMPAREITEMSTRUCT
*cis
= (COMPAREITEMSTRUCT
*)
1276 HeapAlloc(GetProcessHeap(), 0, sizeof(*cis
));
1277 if (!cis
) return -1;
1278 cis
->CtlType
= cis16
->CtlType
;
1279 cis
->CtlID
= cis16
->CtlID
;
1280 cis
->hwndItem
= WIN_Handle32( cis16
->hwndItem
);
1281 cis
->itemID1
= cis16
->itemID1
;
1282 cis
->itemData1
= cis16
->itemData1
;
1283 cis
->itemID2
= cis16
->itemID2
;
1284 cis
->itemData2
= cis16
->itemData2
;
1285 cis
->dwLocaleId
= 0; /* FIXME */
1286 *plparam
= (LPARAM
)cis
;
1291 DELETEITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1292 DELETEITEMSTRUCT
*dis
= (DELETEITEMSTRUCT
*)
1293 HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1294 if (!dis
) return -1;
1295 dis
->CtlType
= dis16
->CtlType
;
1296 dis
->CtlID
= dis16
->CtlID
;
1297 dis
->hwndItem
= WIN_Handle32( dis16
->hwndItem
);
1298 dis
->itemData
= dis16
->itemData
;
1299 *plparam
= (LPARAM
)dis
;
1302 case WM_MEASUREITEM
:
1304 MEASUREITEMSTRUCT16
* mis16
= MapSL(*plparam
);
1305 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)
1306 HeapAlloc(GetProcessHeap(), 0,
1307 sizeof(*mis
) + sizeof(LPARAM
));
1308 if (!mis
) return -1;
1309 mis
->CtlType
= mis16
->CtlType
;
1310 mis
->CtlID
= mis16
->CtlID
;
1311 mis
->itemID
= mis16
->itemID
;
1312 mis
->itemWidth
= mis16
->itemWidth
;
1313 mis
->itemHeight
= mis16
->itemHeight
;
1314 mis
->itemData
= mis16
->itemData
;
1315 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1316 *plparam
= (LPARAM
)mis
;
1321 DRAWITEMSTRUCT16
* dis16
= MapSL(*plparam
);
1322 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)HeapAlloc(GetProcessHeap(), 0,
1324 if (!dis
) return -1;
1325 dis
->CtlType
= dis16
->CtlType
;
1326 dis
->CtlID
= dis16
->CtlID
;
1327 dis
->itemID
= dis16
->itemID
;
1328 dis
->itemAction
= dis16
->itemAction
;
1329 dis
->itemState
= dis16
->itemState
;
1330 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND
)HMENU_32(dis16
->hwndItem
)
1331 : WIN_Handle32( dis16
->hwndItem
);
1332 dis
->hDC
= HDC_32(dis16
->hDC
);
1333 dis
->itemData
= dis16
->itemData
;
1334 dis
->rcItem
.left
= dis16
->rcItem
.left
;
1335 dis
->rcItem
.top
= dis16
->rcItem
.top
;
1336 dis
->rcItem
.right
= dis16
->rcItem
.right
;
1337 dis
->rcItem
.bottom
= dis16
->rcItem
.bottom
;
1338 *plparam
= (LPARAM
)dis
;
1341 case WM_GETMINMAXINFO
:
1343 MINMAXINFO
*mmi
= (MINMAXINFO
*)HeapAlloc( GetProcessHeap(), 0,
1344 sizeof(*mmi
) + sizeof(LPARAM
));
1345 if (!mmi
) return -1;
1346 MINMAXINFO16to32( MapSL(*plparam
), mmi
);
1347 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1348 *plparam
= (LPARAM
)mmi
;
1353 case WM_WININICHANGE
:
1354 case WM_DEVMODECHANGE
:
1355 case WM_ASKCBFORMATNAME
:
1356 *plparam
= (LPARAM
)MapSL(*plparam
);
1360 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1361 MDICREATESTRUCTA
*cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) + sizeof(LPARAM
) );
1363 MDICREATESTRUCT16to32A( cs16
, cs
);
1364 cs
->szTitle
= MapSL(cs16
->szTitle
);
1365 cs
->szClass
= MapSL(cs16
->szClass
);
1366 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1367 *plparam
= (LPARAM
)cs
;
1370 case WM_MDIGETACTIVE
:
1371 *plparam
= (LPARAM
)HeapAlloc( GetProcessHeap(), 0, sizeof(BOOL
) );
1372 *(BOOL
*)(*plparam
) = 0;
1375 if(wParam16
) *pmsg32
=WM_MDIREFRESHMENU
;
1376 *pwparam32
= (WPARAM
)HMENU_32(LOWORD(*plparam
));
1377 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1380 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1381 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1384 if((LOWORD(*plparam
) & MF_POPUP
) && (LOWORD(*plparam
) != 0xFFFF))
1386 HMENU hmenu
=HMENU_32(HIWORD(*plparam
));
1387 UINT Pos
=MENU_FindSubMenu( &hmenu
, HMENU_32(wParam16
));
1388 if(Pos
==0xFFFF) Pos
=0; /* NO_SELECTED_ITEM */
1389 *pwparam32
= MAKEWPARAM( Pos
, LOWORD(*plparam
) );
1391 else *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1392 *plparam
= (LPARAM
)HMENU_32(HIWORD(*plparam
));
1394 case WM_MDIACTIVATE
:
1397 *pwparam32
= (WPARAM
)WIN_Handle32( HIWORD(*plparam
) );
1398 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1400 else /* message sent to MDI client */
1401 *pwparam32
= wParam16
;
1405 NCCALCSIZE_PARAMS16
*nc16
;
1406 NCCALCSIZE_PARAMS
*nc
;
1408 nc
= (NCCALCSIZE_PARAMS
*)HeapAlloc( GetProcessHeap(), 0,
1409 sizeof(*nc
) + sizeof(LPARAM
) );
1411 nc16
= MapSL(*plparam
);
1412 nc
->rgrc
[0].left
= nc16
->rgrc
[0].left
;
1413 nc
->rgrc
[0].top
= nc16
->rgrc
[0].top
;
1414 nc
->rgrc
[0].right
= nc16
->rgrc
[0].right
;
1415 nc
->rgrc
[0].bottom
= nc16
->rgrc
[0].bottom
;
1418 nc
->lppos
= (WINDOWPOS
*)HeapAlloc( GetProcessHeap(), 0,
1419 sizeof(*nc
->lppos
) );
1420 nc
->rgrc
[1].left
= nc16
->rgrc
[1].left
;
1421 nc
->rgrc
[1].top
= nc16
->rgrc
[1].top
;
1422 nc
->rgrc
[1].right
= nc16
->rgrc
[1].right
;
1423 nc
->rgrc
[1].bottom
= nc16
->rgrc
[1].bottom
;
1424 nc
->rgrc
[2].left
= nc16
->rgrc
[2].left
;
1425 nc
->rgrc
[2].top
= nc16
->rgrc
[2].top
;
1426 nc
->rgrc
[2].right
= nc16
->rgrc
[2].right
;
1427 nc
->rgrc
[2].bottom
= nc16
->rgrc
[2].bottom
;
1428 if (nc
->lppos
) WINDOWPOS16to32( MapSL(nc16
->lppos
), nc
->lppos
);
1430 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1431 *plparam
= (LPARAM
)nc
;
1437 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1438 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0,
1439 sizeof(*cs
) + sizeof(LPARAM
) );
1441 CREATESTRUCT16to32A( cs16
, cs
);
1442 cs
->lpszName
= MapSL(cs16
->lpszName
);
1443 cs
->lpszClass
= MapSL(cs16
->lpszClass
);
1445 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1447 MDICREATESTRUCT16
*mdi_cs16
;
1448 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)HeapAlloc(GetProcessHeap(), 0,
1452 HeapFree(GetProcessHeap(), 0, cs
);
1455 mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs16
->lpCreateParams
);
1456 MDICREATESTRUCT16to32A(mdi_cs16
, mdi_cs
);
1457 mdi_cs
->szTitle
= MapSL(mdi_cs16
->szTitle
);
1458 mdi_cs
->szClass
= MapSL(mdi_cs16
->szClass
);
1460 cs
->lpCreateParams
= mdi_cs
;
1462 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1463 *plparam
= (LPARAM
)cs
;
1466 case WM_PARENTNOTIFY
:
1467 if ((wParam16
== WM_CREATE
) || (wParam16
== WM_DESTROY
))
1469 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1470 *plparam
= (LPARAM
)WIN_Handle32( LOWORD(*plparam
) );
1473 case WM_WINDOWPOSCHANGING
:
1474 case WM_WINDOWPOSCHANGED
:
1476 WINDOWPOS
*wp
= (WINDOWPOS
*)HeapAlloc( GetProcessHeap(), 0,
1477 sizeof(*wp
) + sizeof(LPARAM
) );
1479 WINDOWPOS16to32( MapSL(*plparam
), wp
);
1480 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1481 *plparam
= (LPARAM
)wp
;
1487 LPMSG16 msg16
= MapSL(*plparam
);
1488 LPMSG msg32
= (LPMSG
)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1490 if (!msg32
) return -1;
1491 msg32
->hwnd
= WIN_Handle32( msg16
->hwnd
);
1492 msg32
->lParam
= msg16
->lParam
;
1493 msg32
->time
= msg16
->time
;
1494 msg32
->pt
.x
= msg16
->pt
.x
;
1495 msg32
->pt
.y
= msg16
->pt
.y
;
1496 /* this is right, right? */
1497 if (WINPROC_MapMsg16To32A( msg32
->hwnd
, msg16
->message
,msg16
->wParam
,
1498 &msg32
->message
,&msg32
->wParam
,
1499 &msg32
->lParam
)<0) {
1500 HeapFree( GetProcessHeap(), 0, msg32
);
1503 *plparam
= (LPARAM
)msg32
;
1508 *plparam
= (LPARAM
)MapSL(*plparam
);
1510 case WM_ACTIVATEAPP
:
1511 /* We need this when SetActiveWindow sends a Sendmessage16() to
1512 * a 32bit window. Might be superflous with 32bit interprocess
1513 * message queues. */
1514 if (*plparam
) *plparam
= HTASK_32( *plparam
);
1518 MDINEXTMENU
*next
= HeapAlloc( GetProcessHeap(), 0, sizeof(*next
) );
1519 if (!next
) return -1;
1520 next
->hmenuIn
= (HMENU
)*plparam
;
1521 next
->hmenuNext
= 0;
1523 *plparam
= (LPARAM
)next
;
1526 case WM_PAINTCLIPBOARD
:
1527 case WM_SIZECLIPBOARD
:
1528 FIXME_(msg
)("message %04x needs translation\n",msg16
);
1530 case WM_DDE_INITIATE
:
1531 case WM_DDE_TERMINATE
:
1532 case WM_DDE_UNADVISE
:
1533 case WM_DDE_REQUEST
:
1534 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1544 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1545 lo16
= LOWORD(*plparam
);
1546 hi
= HIWORD(*plparam
);
1547 if (lo16
&& !(lo32
= convert_handle_16_to_32(lo16
, GMEM_DDESHARE
)))
1549 *plparam
= PackDDElParam(msg16
, lo32
, hi
);
1551 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1558 *pwparam32
= (WPARAM
)WIN_Handle32(wParam16
);
1560 lo
= LOWORD(*plparam
);
1561 hi
= HIWORD(*plparam
);
1563 if (GlobalGetAtomNameA(hi
, buf
, 2) > 0) flag
|= 1;
1564 if (GlobalSize16(hi
) != 0) flag
|= 2;
1570 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
1575 break; /* atom, nothing to do */
1577 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi
);
1580 hi
= convert_handle_16_to_32(hi
, GMEM_DDESHARE
);
1583 *plparam
= PackDDElParam(WM_DDE_ACK
, lo
, hi
);
1585 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1586 case WM_DDE_EXECUTE
:
1587 *plparam
= convert_handle_16_to_32(*plparam
, GMEM_DDESHARE
);
1588 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
1589 default: /* No translation needed */
1595 /**********************************************************************
1596 * WINPROC_UnmapMsg16To32A
1598 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1600 LRESULT
WINPROC_UnmapMsg16To32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1605 case WM_COMPAREITEM
:
1608 HeapFree( GetProcessHeap(), 0, (LPVOID
)lParam
);
1610 case WM_MEASUREITEM
:
1612 MEASUREITEMSTRUCT16
*mis16
;
1613 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)lParam
;
1614 lParam
= *(LPARAM
*)(mis
+ 1);
1615 mis16
= MapSL(lParam
);
1616 mis16
->itemWidth
= (UINT16
)mis
->itemWidth
;
1617 mis16
->itemHeight
= (UINT16
)mis
->itemHeight
;
1618 HeapFree( GetProcessHeap(), 0, mis
);
1621 case WM_GETMINMAXINFO
:
1623 MINMAXINFO
*mmi
= (MINMAXINFO
*)lParam
;
1624 lParam
= *(LPARAM
*)(mmi
+ 1);
1625 MINMAXINFO32to16( mmi
, MapSL(lParam
));
1626 HeapFree( GetProcessHeap(), 0, mmi
);
1631 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1632 lParam
= *(LPARAM
*)(cs
+ 1);
1633 MDICREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1634 HeapFree( GetProcessHeap(), 0, cs
);
1637 case WM_MDIGETACTIVE
:
1638 result
= MAKELONG( LOWORD(result
), (BOOL16
)(*(BOOL
*)lParam
) );
1639 HeapFree( GetProcessHeap(), 0, (BOOL
*)lParam
);
1643 NCCALCSIZE_PARAMS16
*nc16
;
1644 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lParam
;
1645 lParam
= *(LPARAM
*)(nc
+ 1);
1646 nc16
= MapSL(lParam
);
1647 nc16
->rgrc
[0].left
= nc
->rgrc
[0].left
;
1648 nc16
->rgrc
[0].top
= nc
->rgrc
[0].top
;
1649 nc16
->rgrc
[0].right
= nc
->rgrc
[0].right
;
1650 nc16
->rgrc
[0].bottom
= nc
->rgrc
[0].bottom
;
1653 nc16
->rgrc
[1].left
= nc
->rgrc
[1].left
;
1654 nc16
->rgrc
[1].top
= nc
->rgrc
[1].top
;
1655 nc16
->rgrc
[1].right
= nc
->rgrc
[1].right
;
1656 nc16
->rgrc
[1].bottom
= nc
->rgrc
[1].bottom
;
1657 nc16
->rgrc
[2].left
= nc
->rgrc
[2].left
;
1658 nc16
->rgrc
[2].top
= nc
->rgrc
[2].top
;
1659 nc16
->rgrc
[2].right
= nc
->rgrc
[2].right
;
1660 nc16
->rgrc
[2].bottom
= nc
->rgrc
[2].bottom
;
1663 WINDOWPOS32to16( nc
->lppos
, MapSL(nc16
->lppos
));
1664 HeapFree( GetProcessHeap(), 0, nc
->lppos
);
1667 HeapFree( GetProcessHeap(), 0, nc
);
1673 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
1674 lParam
= *(LPARAM
*)(cs
+ 1);
1675 CREATESTRUCT32Ato16( cs
, MapSL(lParam
) );
1677 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1678 HeapFree(GetProcessHeap(), 0, cs
->lpCreateParams
);
1680 HeapFree( GetProcessHeap(), 0, cs
);
1683 case WM_WINDOWPOSCHANGING
:
1684 case WM_WINDOWPOSCHANGED
:
1686 WINDOWPOS
*wp
= (WINDOWPOS
*)lParam
;
1687 lParam
= *(LPARAM
*)(wp
+ 1);
1688 WINDOWPOS32to16(wp
, MapSL(lParam
));
1689 HeapFree( GetProcessHeap(), 0, wp
);
1695 LPMSG msg32
= (LPMSG
)lParam
;
1697 WINPROC_UnmapMsg16To32A( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1699 HeapFree( GetProcessHeap(), 0, msg32
);
1704 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
1705 result
= MAKELONG( HMENU_16(next
->hmenuNext
), HWND_16(next
->hwndNext
) );
1706 HeapFree( GetProcessHeap(), 0, next
);
1714 /**********************************************************************
1715 * WINPROC_MapMsg16To32W
1717 * Map a message from 16- to 32-bit Unicode.
1718 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1720 INT
WINPROC_MapMsg16To32W( HWND hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1721 WPARAM
*pwparam32
, LPARAM
*plparam
)
1726 *pmsg32
=(UINT
)msg16
;
1727 *pwparam32
= (WPARAM
)wParam16
;
1732 case WM_WININICHANGE
:
1733 case WM_DEVMODECHANGE
:
1734 case WM_ASKCBFORMATNAME
:
1735 *plparam
= (LPARAM
)MapSL(*plparam
);
1736 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1737 case WM_GETTEXTLENGTH
:
1738 case CB_GETLBTEXTLEN
:
1740 return 1; /* need to map result */
1744 CREATESTRUCT16
*cs16
= MapSL(*plparam
);
1745 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0,
1746 sizeof(*cs
) + sizeof(LPARAM
) );
1748 CREATESTRUCT16to32A( cs16
, (CREATESTRUCTA
*)cs
);
1749 cs
->lpszName
= map_str_16_to_32W(cs16
->lpszName
);
1750 cs
->lpszClass
= map_str_16_to_32W(cs16
->lpszClass
);
1752 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
1754 MDICREATESTRUCT16
*mdi_cs16
;
1755 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)HeapAlloc(GetProcessHeap(), 0,
1759 HeapFree(GetProcessHeap(), 0, cs
);
1762 mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs16
->lpCreateParams
);
1763 MDICREATESTRUCT16to32A(mdi_cs16
, (MDICREATESTRUCTA
*)mdi_cs
);
1764 mdi_cs
->szTitle
= map_str_16_to_32W(mdi_cs16
->szTitle
);
1765 mdi_cs
->szClass
= map_str_16_to_32W(mdi_cs16
->szClass
);
1767 cs
->lpCreateParams
= mdi_cs
;
1769 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1770 *plparam
= (LPARAM
)cs
;
1775 MDICREATESTRUCT16
*cs16
= MapSL(*plparam
);
1776 MDICREATESTRUCTW
*cs
=
1777 (MDICREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0,
1778 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
= (LPMSG
)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
,
1853 case WM_GETTEXTLENGTH
:
1854 case CB_GETLBTEXTLEN
:
1856 case WM_ASKCBFORMATNAME
:
1857 return WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
);
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
);
2128 case WM_CTLCOLORMSGBOX
:
2129 case WM_CTLCOLOREDIT
:
2130 case WM_CTLCOLORLISTBOX
:
2131 case WM_CTLCOLORBTN
:
2132 case WM_CTLCOLORDLG
:
2133 case WM_CTLCOLORSCROLLBAR
:
2134 case WM_CTLCOLORSTATIC
:
2135 *pmsg16
= WM_CTLCOLOR
;
2136 *plparam
= MAKELPARAM( (HWND16
)*plparam
,
2137 (WORD
)msg32
- WM_CTLCOLORMSGBOX
);
2139 case WM_COMPAREITEM
:
2141 COMPAREITEMSTRUCT
*cis32
= (COMPAREITEMSTRUCT
*)*plparam
;
2142 COMPAREITEMSTRUCT16
*cis
= HeapAlloc( GetProcessHeap(), 0, sizeof(COMPAREITEMSTRUCT16
));
2143 if (!cis
) return -1;
2144 cis
->CtlType
= (UINT16
)cis32
->CtlType
;
2145 cis
->CtlID
= (UINT16
)cis32
->CtlID
;
2146 cis
->hwndItem
= HWND_16( cis32
->hwndItem
);
2147 cis
->itemID1
= (UINT16
)cis32
->itemID1
;
2148 cis
->itemData1
= cis32
->itemData1
;
2149 cis
->itemID2
= (UINT16
)cis32
->itemID2
;
2150 cis
->itemData2
= cis32
->itemData2
;
2151 *plparam
= MapLS( cis
);
2156 DELETEITEMSTRUCT
*dis32
= (DELETEITEMSTRUCT
*)*plparam
;
2157 DELETEITEMSTRUCT16
*dis
= HeapAlloc( GetProcessHeap(), 0, sizeof(DELETEITEMSTRUCT16
) );
2158 if (!dis
) return -1;
2159 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
2160 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
2161 dis
->itemID
= (UINT16
)dis32
->itemID
;
2162 dis
->hwndItem
= (dis
->CtlType
== ODT_MENU
) ? (HWND16
)LOWORD(dis32
->hwndItem
)
2163 : HWND_16( dis32
->hwndItem
);
2164 dis
->itemData
= dis32
->itemData
;
2165 *plparam
= MapLS( dis
);
2170 DRAWITEMSTRUCT
*dis32
= (DRAWITEMSTRUCT
*)*plparam
;
2171 DRAWITEMSTRUCT16
*dis
= HeapAlloc( GetProcessHeap(), 0, sizeof(DRAWITEMSTRUCT16
) );
2172 if (!dis
) return -1;
2173 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
2174 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
2175 dis
->itemID
= (UINT16
)dis32
->itemID
;
2176 dis
->itemAction
= (UINT16
)dis32
->itemAction
;
2177 dis
->itemState
= (UINT16
)dis32
->itemState
;
2178 dis
->hwndItem
= HWND_16( dis32
->hwndItem
);
2179 dis
->hDC
= HDC_16(dis32
->hDC
);
2180 dis
->itemData
= dis32
->itemData
;
2181 dis
->rcItem
.left
= dis32
->rcItem
.left
;
2182 dis
->rcItem
.top
= dis32
->rcItem
.top
;
2183 dis
->rcItem
.right
= dis32
->rcItem
.right
;
2184 dis
->rcItem
.bottom
= dis32
->rcItem
.bottom
;
2185 *plparam
= MapLS( dis
);
2188 case WM_MEASUREITEM
:
2190 MEASUREITEMSTRUCT
*mis32
= (MEASUREITEMSTRUCT
*)*plparam
;
2191 MEASUREITEMSTRUCT16
*mis
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mis
)+sizeof(LPARAM
));
2192 if (!mis
) return -1;
2193 mis
->CtlType
= (UINT16
)mis32
->CtlType
;
2194 mis
->CtlID
= (UINT16
)mis32
->CtlID
;
2195 mis
->itemID
= (UINT16
)mis32
->itemID
;
2196 mis
->itemWidth
= (UINT16
)mis32
->itemWidth
;
2197 mis
->itemHeight
= (UINT16
)mis32
->itemHeight
;
2198 mis
->itemData
= mis32
->itemData
;
2199 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
2200 *plparam
= MapLS( mis
);
2203 case WM_GETMINMAXINFO
:
2205 MINMAXINFO16
*mmi
= HeapAlloc( GetProcessHeap(), 0, sizeof(*mmi
) + sizeof(LPARAM
) );
2206 if (!mmi
) return -1;
2207 MINMAXINFO32to16( (MINMAXINFO
*)*plparam
, mmi
);
2208 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
2209 *plparam
= MapLS( mmi
);
2213 case WM_ASKCBFORMATNAME
:
2215 LPARAM
*str
; /* store LPARAM, then *pwparam16 char space */
2216 *pwparam16
= (WPARAM16
)min( wParam32
, 0xff80 ); /* Must be < 64K */
2217 if (!(str
= HeapAlloc( GetProcessHeap(), 0, *pwparam16
+ sizeof(LPARAM
)))) return -1;
2218 *str
++ = *plparam
; /* Store the previous lParam */
2219 *plparam
= MapLS( str
);
2224 MDICREATESTRUCT16
*cs
;
2225 MDICREATESTRUCTA
*cs32
= (MDICREATESTRUCTA
*)*plparam
;
2227 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16
) ))) return -1;
2228 MDICREATESTRUCT32Ato16( cs32
, cs
);
2229 cs
->szTitle
= MapLS( cs32
->szTitle
);
2230 cs
->szClass
= MapLS( cs32
->szClass
);
2231 *plparam
= MapLS( cs
);
2234 case WM_MDIGETACTIVE
:
2237 *plparam
= MAKELPARAM( (HMENU16
)LOWORD(wParam32
),
2238 (HMENU16
)LOWORD(*plparam
) );
2239 *pwparam16
= (*plparam
== 0);
2242 if(HIWORD(wParam32
) & MF_POPUP
)
2245 if (((UINT
)HIWORD(wParam32
) != 0xFFFF) || (*plparam
))
2247 if((hmenu
= GetSubMenu((HMENU
)*plparam
, *pwparam16
)))
2248 *pwparam16
=HMENU_16(hmenu
);
2253 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2255 case WM_MDIACTIVATE
:
2256 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2258 *pwparam16
= ((HWND
)*plparam
== hwnd
);
2259 *plparam
= MAKELPARAM( (HWND16
)LOWORD(*plparam
),
2260 (HWND16
)LOWORD(wParam32
) );
2264 *pwparam16
= HWND_16( (HWND
)wParam32
);
2270 NCCALCSIZE_PARAMS
*nc32
= (NCCALCSIZE_PARAMS
*)*plparam
;
2271 NCCALCSIZE_PARAMS16
*nc
= HeapAlloc( GetProcessHeap(), 0, sizeof(*nc
) + sizeof(LPARAM
));
2274 nc
->rgrc
[0].left
= nc32
->rgrc
[0].left
;
2275 nc
->rgrc
[0].top
= nc32
->rgrc
[0].top
;
2276 nc
->rgrc
[0].right
= nc32
->rgrc
[0].right
;
2277 nc
->rgrc
[0].bottom
= nc32
->rgrc
[0].bottom
;
2281 nc
->rgrc
[1].left
= nc32
->rgrc
[1].left
;
2282 nc
->rgrc
[1].top
= nc32
->rgrc
[1].top
;
2283 nc
->rgrc
[1].right
= nc32
->rgrc
[1].right
;
2284 nc
->rgrc
[1].bottom
= nc32
->rgrc
[1].bottom
;
2285 nc
->rgrc
[2].left
= nc32
->rgrc
[2].left
;
2286 nc
->rgrc
[2].top
= nc32
->rgrc
[2].top
;
2287 nc
->rgrc
[2].right
= nc32
->rgrc
[2].right
;
2288 nc
->rgrc
[2].bottom
= nc32
->rgrc
[2].bottom
;
2289 if (!(wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(WINDOWPOS16
) )))
2291 HeapFree( GetProcessHeap(), 0, nc
);
2294 WINDOWPOS32to16( nc32
->lppos
, wp
);
2295 nc
->lppos
= MapLS( wp
);
2297 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
2298 *plparam
= MapLS( nc
);
2305 CREATESTRUCTA
*cs32
= (CREATESTRUCTA
*)*plparam
;
2307 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16
) ))) return -1;
2308 CREATESTRUCT32Ato16( cs32
, cs
);
2309 cs
->lpszName
= MapLS( cs32
->lpszName
);
2310 cs
->lpszClass
= MapLS( cs32
->lpszClass
);
2312 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2314 MDICREATESTRUCT16
*mdi_cs16
;
2315 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)cs32
->lpCreateParams
;
2316 mdi_cs16
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs16
));
2319 HeapFree(GetProcessHeap(), 0, cs
);
2322 MDICREATESTRUCT32Ato16(mdi_cs
, mdi_cs16
);
2323 mdi_cs16
->szTitle
= MapLS( mdi_cs
->szTitle
);
2324 mdi_cs16
->szClass
= MapLS( mdi_cs
->szClass
);
2325 cs
->lpCreateParams
= MapLS( mdi_cs16
);
2327 *plparam
= MapLS( cs
);
2330 case WM_PARENTNOTIFY
:
2331 if ((LOWORD(wParam32
)==WM_CREATE
) || (LOWORD(wParam32
)==WM_DESTROY
))
2332 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
));
2333 /* else nothing to do */
2336 *plparam
= MapLS( (NMHDR
*)*plparam
); /* NMHDR is already 32-bit */
2339 case WM_WININICHANGE
:
2340 case WM_DEVMODECHANGE
:
2341 *plparam
= MapLS( (LPSTR
)*plparam
);
2343 case WM_WINDOWPOSCHANGING
:
2344 case WM_WINDOWPOSCHANGED
:
2346 WINDOWPOS16
*wp
= HeapAlloc( GetProcessHeap(), 0, sizeof(*wp
) + sizeof(LPARAM
) );
2348 WINDOWPOS32to16( (WINDOWPOS
*)*plparam
, wp
);
2349 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
2350 *plparam
= MapLS( wp
);
2355 LPMSG msg32
= (LPMSG
) *plparam
;
2356 LPMSG16 msg16
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG16
) );
2358 if (!msg16
) return -1;
2359 msg16
->hwnd
= HWND_16( msg32
->hwnd
);
2360 msg16
->lParam
= msg32
->lParam
;
2361 msg16
->time
= msg32
->time
;
2362 msg16
->pt
.x
= msg32
->pt
.x
;
2363 msg16
->pt
.y
= msg32
->pt
.y
;
2364 /* this is right, right? */
2365 if (WINPROC_MapMsg32ATo16(msg32
->hwnd
,msg32
->message
,msg32
->wParam
,
2366 &msg16
->message
,&msg16
->wParam
, &msg16
->lParam
)<0)
2368 HeapFree( GetProcessHeap(), 0, msg16
);
2371 *plparam
= MapLS( msg16
);
2376 case WM_ACTIVATEAPP
:
2377 if (*plparam
) *plparam
= HTASK_16( (HANDLE
)*plparam
);
2381 MDINEXTMENU
*next
= (MDINEXTMENU
*)*plparam
;
2382 *plparam
= (LPARAM
)next
->hmenuIn
;
2386 if (IsIconic( hwnd
) && GetClassLongW( hwnd
, GCL_HICON
))
2388 *pmsg16
= WM_PAINTICON
;
2393 if (IsIconic( hwnd
) && GetClassLongW( hwnd
, GCL_HICON
))
2394 *pmsg16
= WM_ICONERASEBKGND
;
2396 case WM_PAINTCLIPBOARD
:
2397 case WM_SIZECLIPBOARD
:
2398 FIXME_(msg
)("message %04x needs translation\n", msg32
);
2400 /* following messages should not be sent to 16-bit apps */
2403 case WM_CAPTURECHANGED
:
2404 case WM_STYLECHANGING
:
2405 case WM_STYLECHANGED
:
2407 case WM_DDE_INITIATE
:
2408 case WM_DDE_TERMINATE
:
2409 case WM_DDE_UNADVISE
:
2410 case WM_DDE_REQUEST
:
2411 *pwparam16
= HWND_16((HWND
)wParam32
);
2420 *pwparam16
= HWND_16((HWND
)wParam32
);
2421 UnpackDDElParam(msg32
, *plparam
, &lo32
, &hi
);
2422 if (lo32
&& !(lo16
= convert_handle_32_to_16(lo32
, GMEM_DDESHARE
)))
2424 *plparam
= MAKELPARAM(lo16
, hi
);
2426 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2433 *pwparam16
= HWND_16((HWND
)wParam32
);
2435 UnpackDDElParam(msg32
, *plparam
, &lo
, &hi
);
2437 if (GlobalGetAtomNameA((ATOM
)hi
, buf
, sizeof(buf
)) > 0) flag
|= 1;
2438 if (GlobalSize((HANDLE
)hi
) != 0) flag
|= 2;
2444 MESSAGE("DDE_ACK: neither atom nor handle!!!\n");
2449 break; /* atom, nothing to do */
2451 MESSAGE("DDE_ACK: %x both atom and handle... choosing handle\n", hi
);
2454 hi
= convert_handle_32_to_16(hi
, GMEM_DDESHARE
);
2457 *plparam
= MAKELPARAM(lo
, hi
);
2459 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2460 case WM_DDE_EXECUTE
:
2461 *plparam
= convert_handle_32_to_16(*plparam
, GMEM_DDESHARE
);
2462 return 0; /* FIXME don't know how to free allocated memory (handle) !! */
2463 default: /* No translation needed */
2469 /**********************************************************************
2470 * WINPROC_UnmapMsg32ATo16
2472 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
2474 void WINPROC_UnmapMsg32ATo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2480 *(LPINT
)wParam
= LOWORD(p16
->lResult
);
2481 *(LPINT
)lParam
= HIWORD(p16
->lResult
);
2488 case LB_FINDSTRINGEXACT
:
2489 case LB_INSERTSTRING
:
2490 case LB_SELECTSTRING
:
2494 case CB_FINDSTRINGEXACT
:
2495 case CB_INSERTSTRING
:
2496 case CB_SELECTSTRING
:
2500 case WM_WININICHANGE
:
2501 case WM_DEVMODECHANGE
:
2502 UnMapLS( (SEGPTR
)p16
->lParam
);
2504 case LB_SETTABSTOPS
:
2505 case WM_COMPAREITEM
:
2509 void *ptr
= MapSL( p16
->lParam
);
2510 UnMapLS( p16
->lParam
);
2511 HeapFree( GetProcessHeap(), 0, ptr
);
2514 case CB_GETDROPPEDCONTROLRECT
:
2515 case LB_GETITEMRECT
:
2518 RECT16
*rect
= MapSL(p16
->lParam
);
2519 UnMapLS( p16
->lParam
);
2520 p16
->lParam
= *(LPARAM
*)(rect
+ 1);
2521 r32
= (RECT
*)p16
->lParam
;
2522 r32
->left
= rect
->left
;
2523 r32
->top
= rect
->top
;
2524 r32
->right
= rect
->right
;
2525 r32
->bottom
= rect
->bottom
;
2526 HeapFree( GetProcessHeap(), 0, rect
);
2529 case LB_GETSELITEMS
:
2532 LPINT16 items
= MapSL(p16
->lParam
);
2533 UnMapLS( p16
->lParam
);
2534 p16
->lParam
= *((LPARAM
*)items
- 1);
2535 for (i
= 0; i
< p16
->wParam
; i
++) *((LPINT
)(p16
->lParam
) + i
) = items
[i
];
2536 HeapFree( GetProcessHeap(), 0, (LPARAM
*)items
- 1 );
2542 *((PUINT
)(wParam
)) = LOWORD(p16
->lResult
);
2544 *((PUINT
)(lParam
)) = HIWORD(p16
->lResult
); /* FIXME: substract 1? */
2547 case WM_MEASUREITEM
:
2549 MEASUREITEMSTRUCT16
*mis
= MapSL(p16
->lParam
);
2550 MEASUREITEMSTRUCT
*mis32
= *(MEASUREITEMSTRUCT
**)(mis
+ 1);
2551 mis32
->itemWidth
= mis
->itemWidth
;
2552 mis32
->itemHeight
= mis
->itemHeight
;
2553 UnMapLS( p16
->lParam
);
2554 HeapFree( GetProcessHeap(), 0, mis
);
2557 case WM_GETMINMAXINFO
:
2559 MINMAXINFO16
*mmi
= MapSL(p16
->lParam
);
2560 UnMapLS( p16
->lParam
);
2561 p16
->lParam
= *(LPARAM
*)(mmi
+ 1);
2562 MINMAXINFO16to32( mmi
, (MINMAXINFO
*)(p16
->lParam
) );
2563 HeapFree( GetProcessHeap(), 0, mmi
);
2567 case WM_ASKCBFORMATNAME
:
2569 LPSTR str
= MapSL(p16
->lParam
);
2570 UnMapLS( p16
->lParam
);
2571 p16
->lParam
= *((LPARAM
*)str
- 1);
2572 lstrcpynA( (LPSTR
)(p16
->lParam
), str
, p16
->wParam
);
2573 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
- 1 );
2578 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2579 UnMapLS( cs
->szTitle
);
2580 UnMapLS( cs
->szClass
);
2581 UnMapLS( p16
->lParam
);
2582 HeapFree( GetProcessHeap(), 0, cs
);
2585 case WM_MDIGETACTIVE
:
2586 if (lParam
) *(BOOL
*)lParam
= (BOOL16
)HIWORD(p16
->lResult
);
2587 p16
->lResult
= (LRESULT
)WIN_Handle32( LOWORD(p16
->lResult
) );
2591 NCCALCSIZE_PARAMS
*nc32
;
2592 NCCALCSIZE_PARAMS16
*nc
= MapSL(p16
->lParam
);
2593 UnMapLS( p16
->lParam
);
2594 p16
->lParam
= *(LPARAM
*)(nc
+ 1);
2595 nc32
= (NCCALCSIZE_PARAMS
*)(p16
->lParam
);
2596 nc32
->rgrc
[0].left
= nc
->rgrc
[0].left
;
2597 nc32
->rgrc
[0].top
= nc
->rgrc
[0].top
;
2598 nc32
->rgrc
[0].right
= nc
->rgrc
[0].right
;
2599 nc32
->rgrc
[0].bottom
= nc
->rgrc
[0].bottom
;
2602 WINDOWPOS16
*pos
= MapSL(nc
->lppos
);
2603 UnMapLS( nc
->lppos
);
2604 nc32
->rgrc
[1].left
= nc
->rgrc
[1].left
;
2605 nc32
->rgrc
[1].top
= nc
->rgrc
[1].top
;
2606 nc32
->rgrc
[1].right
= nc
->rgrc
[1].right
;
2607 nc32
->rgrc
[1].bottom
= nc
->rgrc
[1].bottom
;
2608 nc32
->rgrc
[2].left
= nc
->rgrc
[2].left
;
2609 nc32
->rgrc
[2].top
= nc
->rgrc
[2].top
;
2610 nc32
->rgrc
[2].right
= nc
->rgrc
[2].right
;
2611 nc32
->rgrc
[2].bottom
= nc
->rgrc
[2].bottom
;
2612 WINDOWPOS16to32( pos
, nc32
->lppos
);
2613 HeapFree( GetProcessHeap(), 0, pos
);
2615 HeapFree( GetProcessHeap(), 0, nc
);
2621 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2622 UnMapLS( p16
->lParam
);
2623 UnMapLS( cs
->lpszName
);
2624 UnMapLS( cs
->lpszClass
);
2625 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2627 MDICREATESTRUCT16
*mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs
->lpCreateParams
);
2628 UnMapLS( cs
->lpCreateParams
);
2629 UnMapLS( mdi_cs16
->szTitle
);
2630 UnMapLS( mdi_cs16
->szClass
);
2631 HeapFree(GetProcessHeap(), 0, mdi_cs16
);
2633 HeapFree( GetProcessHeap(), 0, cs
);
2636 case WM_WINDOWPOSCHANGING
:
2637 case WM_WINDOWPOSCHANGED
:
2639 WINDOWPOS16
*wp
= MapSL(p16
->lParam
);
2640 UnMapLS( p16
->lParam
);
2641 p16
->lParam
= *(LPARAM
*)(wp
+ 1);
2642 WINDOWPOS16to32( wp
, (WINDOWPOS
*)p16
->lParam
);
2643 HeapFree( GetProcessHeap(), 0, wp
);
2647 UnMapLS(p16
->lParam
);
2652 LPMSG16 msg16
= MapSL(p16
->lParam
);
2654 UnMapLS( p16
->lParam
);
2655 msgp16
.wParam
=msg16
->wParam
;
2656 msgp16
.lParam
=msg16
->lParam
;
2657 WINPROC_UnmapMsg32ATo16(((LPMSG
)lParam
)->hwnd
, ((LPMSG
)lParam
)->message
,
2658 ((LPMSG
)lParam
)->wParam
, ((LPMSG
)lParam
)->lParam
,
2660 HeapFree( GetProcessHeap(), 0, msg16
);
2665 MDINEXTMENU
*next
= (MDINEXTMENU
*)lParam
;
2666 next
->hmenuNext
= HMENU_32( LOWORD(p16
->lResult
) );
2667 next
->hwndNext
= WIN_Handle32( HIWORD(p16
->lResult
) );
2675 /**********************************************************************
2676 * WINPROC_MapMsg32WTo16
2678 * Map a message from 32-bit Unicode to 16-bit.
2679 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
2681 INT
WINPROC_MapMsg32WTo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
2682 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
2688 *pmsg16
= LOWORD(msg32
);
2689 *pwparam16
= LOWORD(wParam32
);
2694 case LB_FINDSTRINGEXACT
:
2695 case LB_INSERTSTRING
:
2696 case LB_SELECTSTRING
:
2699 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2700 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2705 case CB_FINDSTRINGEXACT
:
2706 case CB_INSERTSTRING
:
2707 case CB_SELECTSTRING
:
2709 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2710 *pmsg16
= (UINT16
)msg32
+ (CB_ADDSTRING16
- CB_ADDSTRING
);
2717 CREATESTRUCTW
*cs32
= (CREATESTRUCTW
*)*plparam
;
2719 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(CREATESTRUCT16
) ))) return -1;
2720 CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs32
, cs
);
2721 cs
->lpszName
= map_str_32W_to_16( cs32
->lpszName
);
2722 cs
->lpszClass
= map_str_32W_to_16( cs32
->lpszClass
);
2724 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2726 MDICREATESTRUCT16
*mdi_cs16
;
2727 MDICREATESTRUCTW
*mdi_cs
= (MDICREATESTRUCTW
*)cs32
->lpCreateParams
;
2728 mdi_cs16
= HeapAlloc(GetProcessHeap(), 0, sizeof(*mdi_cs16
));
2731 HeapFree(GetProcessHeap(), 0, cs
);
2734 MDICREATESTRUCT32Ato16((MDICREATESTRUCTA
*)mdi_cs
, mdi_cs16
);
2735 mdi_cs16
->szTitle
= map_str_32W_to_16(mdi_cs
->szTitle
);
2736 mdi_cs16
->szClass
= map_str_32W_to_16(mdi_cs
->szClass
);
2737 cs
->lpCreateParams
= MapLS(mdi_cs16
);
2739 *plparam
= MapLS(cs
);
2744 MDICREATESTRUCT16
*cs
;
2745 MDICREATESTRUCTW
*cs32
= (MDICREATESTRUCTW
*)*plparam
;
2747 if (!(cs
= HeapAlloc( GetProcessHeap(), 0, sizeof(MDICREATESTRUCT16
) ))) return -1;
2748 MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs32
, cs
);
2749 cs
->szTitle
= map_str_32W_to_16( cs32
->szTitle
);
2750 cs
->szClass
= map_str_32W_to_16( cs32
->szClass
);
2751 *plparam
= MapLS(cs
);
2755 case WM_WININICHANGE
:
2756 case WM_DEVMODECHANGE
:
2757 *plparam
= map_str_32W_to_16( (LPWSTR
)*plparam
);
2760 if ( WINPROC_TestLBForStr( hwnd
))
2762 LPSTR str
= HeapAlloc( GetProcessHeap(), 0, 256 ); /* FIXME: fixed sized buffer */
2763 if (!str
) return -1;
2764 *pmsg16
= LB_GETTEXT16
;
2765 *plparam
= (LPARAM
)MapLS(str
);
2769 if ( WINPROC_TestCBForStr( hwnd
))
2771 LPSTR str
= HeapAlloc( GetProcessHeap(), 0, 256 ); /* FIXME: fixed sized buffer */
2772 if (!str
) return -1;
2773 *pmsg16
= CB_GETLBTEXT16
;
2774 *plparam
= (LPARAM
)MapLS(str
);
2779 wch
= LOWORD(wParam32
);
2780 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
2782 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
2785 wch
= LOWORD(wParam32
);
2786 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
2788 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
2793 case WM_SYSDEADCHAR
:
2795 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
2803 if (WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, ch
, 2, NULL
, NULL
) == 2)
2804 *pwparam16
= (ch
[0] << 8) | ch
[1];
2810 default: /* No Unicode translation needed (?) */
2811 return WINPROC_MapMsg32ATo16( hwnd
, msg32
, wParam32
, pmsg16
,
2812 pwparam16
, plparam
);
2817 /**********************************************************************
2818 * WINPROC_UnmapMsg32WTo16
2820 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2822 void WINPROC_UnmapMsg32WTo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2829 case LB_FINDSTRINGEXACT
:
2830 case LB_INSERTSTRING
:
2831 case LB_SELECTSTRING
:
2836 case CB_FINDSTRINGEXACT
:
2837 case CB_INSERTSTRING
:
2838 case CB_SELECTSTRING
:
2841 case WM_WININICHANGE
:
2842 case WM_DEVMODECHANGE
:
2843 unmap_str_32W_to_16( p16
->lParam
);
2848 CREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2849 UnMapLS( p16
->lParam
);
2850 unmap_str_32W_to_16( cs
->lpszName
);
2851 unmap_str_32W_to_16( cs
->lpszClass
);
2853 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2855 MDICREATESTRUCT16
*mdi_cs16
= (MDICREATESTRUCT16
*)MapSL(cs
->lpCreateParams
);
2856 UnMapLS( cs
->lpCreateParams
);
2857 unmap_str_32W_to_16(mdi_cs16
->szTitle
);
2858 unmap_str_32W_to_16(mdi_cs16
->szClass
);
2859 HeapFree(GetProcessHeap(), 0, mdi_cs16
);
2861 HeapFree( GetProcessHeap(), 0, cs
);
2866 MDICREATESTRUCT16
*cs
= MapSL(p16
->lParam
);
2867 UnMapLS( p16
->lParam
);
2868 unmap_str_32W_to_16( cs
->szTitle
);
2869 unmap_str_32W_to_16( cs
->szClass
);
2870 HeapFree( GetProcessHeap(), 0, cs
);
2874 case WM_ASKCBFORMATNAME
:
2876 LPSTR str
= MapSL(p16
->lParam
);
2877 UnMapLS( p16
->lParam
);
2878 p16
->lParam
= *((LPARAM
*)str
- 1);
2879 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)p16
->lParam
, 0x7fffffff );
2880 p16
->lResult
= strlenW( (LPWSTR
)p16
->lParam
);
2881 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
- 1 );
2885 if ( WINPROC_TestLBForStr( hwnd
))
2887 LPSTR str
= MapSL(p16
->lParam
);
2888 UnMapLS( p16
->lParam
);
2889 p16
->lResult
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff ) - 1;
2890 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
);
2894 if ( WINPROC_TestCBForStr( hwnd
))
2896 LPSTR str
= MapSL(p16
->lParam
);
2897 UnMapLS( p16
->lParam
);
2898 p16
->lResult
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff ) - 1;
2899 HeapFree( GetProcessHeap(), 0, (LPARAM
*)str
);
2903 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, p16
);
2909 /**********************************************************************
2910 * WINPROC_CallProc32ATo32W
2912 * Call a window procedure, translating args from Ansi to Unicode.
2914 static LRESULT
WINPROC_CallProc32ATo32W( WNDPROC func
, HWND hwnd
,
2915 UINT msg
, WPARAM wParam
,
2921 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
2922 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2924 if( (unmap
= WINPROC_MapMsg32ATo32W( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
2925 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
2926 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
2929 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2930 if (unmap
) result
= WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
, result
);
2935 /**********************************************************************
2936 * WINPROC_CallProc32WTo32A_fast
2939 static BOOL
WINPROC_CallProc32WTo32A_fast( WNDPROC func
, HWND hwnd
,
2940 UINT msg
, WPARAM wParam
,
2941 LPARAM lParam
, LRESULT
*result
)
2947 { /* csW->lpszName and csW->lpszClass are NOT supposed to be atoms
2951 char *cls
= buffer
, *name
;
2952 CREATESTRUCTW
*csW
= (CREATESTRUCTW
*)lParam
;
2953 CREATESTRUCTA csA
= *(CREATESTRUCTA
*)csW
;
2954 DWORD name_lenA
, name_lenW
, class_lenA
, class_lenW
;
2956 class_lenW
= strlenW(csW
->lpszClass
) * sizeof(WCHAR
);
2957 RtlUnicodeToMultiByteSize(&class_lenA
, csW
->lpszClass
, class_lenW
);
2961 name_lenW
= strlenW(csW
->lpszName
) * sizeof(WCHAR
);
2962 RtlUnicodeToMultiByteSize(&name_lenA
, csW
->lpszName
, name_lenW
);
2965 name_lenW
= name_lenA
= 0;
2967 if (class_lenA
+ name_lenA
+ 2 > sizeof(buffer
))
2969 cls
= HeapAlloc(GetProcessHeap(), 0, class_lenA
+ name_lenA
+ 2);
2970 if (!cls
) return FALSE
;
2973 RtlUnicodeToMultiByteN(cls
, class_lenA
, NULL
, csW
->lpszClass
, class_lenW
);
2974 cls
[class_lenA
] = 0;
2975 csA
.lpszClass
= cls
;
2979 name
= cls
+ class_lenA
+ 1;
2980 RtlUnicodeToMultiByteN(name
, name_lenA
, NULL
, csW
->lpszName
, name_lenW
);
2981 name
[name_lenA
] = 0;
2982 csA
.lpszName
= name
;
2985 if (GetWindowLongW(hwnd
, GWL_EXSTYLE
) & WS_EX_MDICHILD
)
2987 MDICREATESTRUCTA mdi_cs
;
2989 mdi_cs
= *(MDICREATESTRUCTA
*)csW
->lpCreateParams
;
2990 mdi_cs
.szTitle
= csA
.lpszName
;
2991 mdi_cs
.szClass
= csA
.lpszClass
;
2992 csA
.lpCreateParams
= &mdi_cs
;
2995 lParam
= (LPARAM
)&csA
;
2996 *result
= WINPROC_CallWndProc(func
, hwnd
, msg
, wParam
, lParam
);
2998 if (cls
!= buffer
) HeapFree(GetProcessHeap(), 0, cls
);
3007 /**********************************************************************
3008 * WINPROC_CallProc32WTo32A
3010 * Call a window procedure, translating args from Unicode to Ansi.
3012 static LRESULT
WINPROC_CallProc32WTo32A( WNDPROC func
, HWND hwnd
,
3013 UINT msg
, WPARAM wParam
,
3019 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3020 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3022 if (WINPROC_CallProc32WTo32A_fast( func
, hwnd
, msg
, wParam
, lParam
, &result
))
3025 if ((unmap
= WINPROC_MapMsg32WTo32A( hwnd
, msg
, &wParam
, &lParam
)) == -1) {
3026 ERR_(msg
)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
3027 SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3030 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3031 if( unmap
) result
= WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
, result
);
3036 /**********************************************************************
3037 * __wine_call_wndproc_32A (USER.1010)
3039 LRESULT WINAPI
__wine_call_wndproc_32A( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
,
3045 HWND hwnd32
= WIN_Handle32( hwnd
);
3047 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3048 func
, hwnd32
, SPY_GetMsgName(msg
, hwnd32
), wParam
, lParam
);
3050 if (WINPROC_MapMsg16To32A( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
3052 result
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
3053 return WINPROC_UnmapMsg16To32A( hwnd32
, msg32
, wParam32
, lParam
, result
);
3057 /**********************************************************************
3058 * __wine_call_wndproc_32W (USER.1011)
3060 LRESULT WINAPI
__wine_call_wndproc_32W( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
, LPARAM lParam
,
3066 HWND hwnd32
= WIN_Handle32( hwnd
);
3068 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3069 func
, hwnd32
, SPY_GetMsgName(msg
, hwnd32
), wParam
, lParam
);
3071 if (WINPROC_MapMsg16To32W( hwnd32
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
3073 result
= WINPROC_CallWndProc( func
, hwnd32
, msg32
, wParam32
, lParam
);
3074 return WINPROC_UnmapMsg16To32W( hwnd32
, msg32
, wParam32
, lParam
, result
);
3078 /**********************************************************************
3079 * WINPROC_CallProc32ATo16
3081 * Call a 16-bit window procedure, translating the 32-bit args.
3083 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
3084 UINT msg
, WPARAM wParam
,
3090 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3091 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3093 mp16
.lParam
= lParam
;
3094 if (WINPROC_MapMsg32ATo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
3096 mp16
.lResult
= WINPROC_CallWndProc16( func
, HWND_16(hwnd
), msg16
,
3097 mp16
.wParam
, mp16
.lParam
);
3098 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3099 return mp16
.lResult
;
3103 /**********************************************************************
3104 * WINPROC_CallProc32WTo16
3106 * Call a 16-bit window procedure, translating the 32-bit args.
3108 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
3109 UINT msg
, WPARAM wParam
,
3115 TRACE_(msg
)("func %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
3116 func
, hwnd
, SPY_GetMsgName(msg
, hwnd
), wParam
, lParam
);
3118 mp16
.lParam
= lParam
;
3119 if (WINPROC_MapMsg32WTo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
,
3120 &mp16
.lParam
) == -1)
3122 mp16
.lResult
= WINPROC_CallWndProc16( func
, HWND_16(hwnd
), msg16
,
3123 mp16
.wParam
, mp16
.lParam
);
3124 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
3125 return mp16
.lResult
;
3129 /**********************************************************************
3130 * CallWindowProc (USER.122)
3132 LRESULT WINAPI
CallWindowProc16( WNDPROC16 func
, HWND16 hwnd
, UINT16 msg
,
3133 WPARAM16 wParam
, LPARAM lParam
)
3137 if (!func
) return 0;
3139 if (!(proc
= WINPROC_GetPtr( (WNDPROC
)func
)))
3140 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
3143 func
= WINPROC_GetProc( (WNDPROC
)proc
, WIN_PROC_16
);
3144 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
3150 if (!proc
->thunk
.t_from32
.proc
) return 0;
3151 return WINPROC_CallWndProc16( proc
->thunk
.t_from32
.proc
,
3152 hwnd
, msg
, wParam
, lParam
);
3154 if (!proc
->thunk
.t_from16
.proc
) return 0;
3155 return __wine_call_wndproc_32A( hwnd
, msg
, wParam
, lParam
, proc
->thunk
.t_from16
.proc
);
3157 if (!proc
->thunk
.t_from16
.proc
) return 0;
3158 return __wine_call_wndproc_32W( hwnd
, msg
, wParam
, lParam
, proc
->thunk
.t_from16
.proc
);
3160 WARN_(relay
)("Invalid proc %p\n", proc
);
3166 /**********************************************************************
3167 * CallWindowProcA (USER32.@)
3169 * The CallWindowProc() function invokes the windows procedure _func_,
3170 * with _hwnd_ as the target window, the message specified by _msg_, and
3171 * the message parameters _wParam_ and _lParam_.
3173 * Some kinds of argument conversion may be done, I'm not sure what.
3175 * CallWindowProc() may be used for windows subclassing. Use
3176 * SetWindowLong() to set a new windows procedure for windows of the
3177 * subclass, and handle subclassed messages in the new windows
3178 * procedure. The new windows procedure may then use CallWindowProc()
3179 * with _func_ set to the parent class's windows procedure to dispatch
3180 * the message to the superclass.
3184 * The return value is message dependent.
3190 LRESULT WINAPI
CallWindowProcA(
3191 WNDPROC func
, /* [in] window procedure */
3192 HWND hwnd
, /* [in] target window */
3193 UINT msg
, /* [in] message */
3194 WPARAM wParam
, /* [in] message dependent parameter */
3195 LPARAM lParam
/* [in] message dependent parameter */
3199 if (!func
) return 0;
3201 if (!(proc
= WINPROC_GetPtr( func
)))
3202 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3205 func
= WINPROC_GetProc( (WNDPROC
)proc
, WIN_PROC_32A
);
3206 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3212 if (!proc
->thunk
.t_from32
.proc
) return 0;
3213 return WINPROC_CallProc32ATo16( proc
->thunk
.t_from32
.proc
,
3214 hwnd
, msg
, wParam
, lParam
);
3216 if (!proc
->thunk
.t_from16
.proc
) return 0;
3217 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
3218 hwnd
, msg
, wParam
, lParam
);
3220 if (!proc
->thunk
.t_from16
.proc
) return 0;
3221 return WINPROC_CallProc32ATo32W( proc
->thunk
.t_from16
.proc
,
3222 hwnd
, msg
, wParam
, lParam
);
3224 WARN_(relay
)("Invalid proc %p\n", proc
);
3230 /**********************************************************************
3231 * CallWindowProcW (USER32.@)
3233 LRESULT WINAPI
CallWindowProcW( WNDPROC func
, HWND hwnd
, UINT msg
,
3234 WPARAM wParam
, LPARAM lParam
)
3238 if (!func
) return 0;
3240 if (!(proc
= WINPROC_GetPtr( (WNDPROC
)func
)))
3241 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3244 func
= WINPROC_GetProc( (WNDPROC
)proc
, WIN_PROC_32W
);
3245 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
3251 if (!proc
->thunk
.t_from32
.proc
) return 0;
3252 return WINPROC_CallProc32WTo16( proc
->thunk
.t_from32
.proc
,
3253 hwnd
, msg
, wParam
, lParam
);
3255 if (!proc
->thunk
.t_from16
.proc
) return 0;
3256 return WINPROC_CallProc32WTo32A( proc
->thunk
.t_from16
.proc
,
3257 hwnd
, msg
, wParam
, lParam
);
3259 if (!proc
->thunk
.t_from16
.proc
) return 0;
3260 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
3261 hwnd
, msg
, wParam
, lParam
);
3263 WARN_(relay
)("Invalid proc %p\n", proc
);