2 * Window procedure callbacks
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1996 Alexandre Julliard
14 #include "wine/winbase16.h"
15 #include "wine/winuser16.h"
16 #include "stackframe.h"
17 #include "builtin16.h"
19 #include "selectors.h"
23 #include "debugtools.h"
30 DECLARE_DEBUG_CHANNEL(msg
);
31 DECLARE_DEBUG_CHANNEL(relay
);
32 DECLARE_DEBUG_CHANNEL(win
);
34 /* Window procedure 16-to-32-bit thunk,
35 * see BuildSpec16File() in tools/build.c */
40 WORD pushw_bp
; /* pushw %bp */
41 BYTE pushl_func
; /* pushl $proc */
43 WORD pushw_ax
; /* pushw %ax */
44 BYTE pushl_relay
; /* pushl $relay */
45 void (*relay
)(); /* WINPROC_Thunk16To32A/W() */
46 BYTE lcall
; /* lcall cs:glue */
47 void (*glue
)(); /* __wine_call_from_16_long */
48 WORD cs
; /* __FLATCS */
49 WORD lret
; /* lret $10 */
51 } WINPROC_THUNK_FROM16
;
54 /* Window procedure 32-to-16-bit thunk,
55 * see BuildSpec32File() in tools/build.c */
59 BYTE popl_eax
; /* popl %eax (return address) */
60 BYTE pushl_func
; /* pushl $proc */
61 WNDPROC16 proc WINE_PACKED
;
62 BYTE pushl_eax
; /* pushl %eax */
63 BYTE jmp
; /* jmp relay (relative jump)*/
64 void (*relay
)() WINE_PACKED
; /* WINPROC_CallProc32ATo16() */
65 } WINPROC_THUNK_FROM32
;
67 /* Simple jmp to call 32-bit procedure directly */
70 BYTE jmp
; /* jmp proc (relative jump) */
71 WNDPROC proc WINE_PACKED
;
76 WINPROC_THUNK_FROM16 t_from16
;
77 WINPROC_THUNK_FROM32 t_from32
;
80 typedef struct tagWINDOWPROC
82 WINPROC_THUNK thunk
; /* Thunk */
83 WINPROC_JUMP jmp
; /* Jump */
84 struct tagWINDOWPROC
*next
; /* Next window proc */
85 UINT magic
; /* Magic number */
86 WINDOWPROCTYPE type
; /* Function type */
87 WINDOWPROCUSER user
; /* Function user */
90 #define WINPROC_MAGIC ('W' | ('P' << 8) | ('R' << 16) | ('C' << 24))
92 #define WINPROC_THUNKPROC(pproc) \
93 (((pproc)->type == WIN_PROC_16) ? \
94 (WNDPROC16)((pproc)->thunk.t_from32.proc) : \
95 (WNDPROC16)((pproc)->thunk.t_from16.proc))
97 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
98 UINT msg
, WPARAM wParam
,
100 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
101 UINT msg
, WPARAM wParam
,
103 static LRESULT WINAPI
WINPROC_Thunk16To32A( WNDPROC func
, LPBYTE args
);
104 static LRESULT WINAPI
WINPROC_Thunk16To32W( WNDPROC func
, LPBYTE args
);
106 static HANDLE WinProcHeap
;
109 /**********************************************************************
112 BOOL
WINPROC_Init(void)
114 WinProcHeap
= HeapCreate( HEAP_WINE_SEGPTR
| HEAP_WINE_CODESEG
, 0, 0 );
117 WARN_(relay
)("Unable to create winproc heap\n" );
125 /* Some window procedures modify register they shouldn't, or are not
126 * properly declared stdcall; so we need a small assembly wrapper to
128 extern LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
129 WPARAM wParam
, LPARAM lParam
);
130 __ASM_GLOBAL_FUNC( WINPROC_wrapper
,
140 "movl 8(%ebp),%eax\n\t"
142 "leal -12(%ebp),%esp\n\t"
149 static inline LRESULT
WINPROC_wrapper( WNDPROC proc
, HWND hwnd
, UINT msg
,
150 WPARAM wParam
, LPARAM lParam
)
152 return proc( hwnd
, msg
, wParam
, lParam
);
154 #endif /* __i386__ */
156 /**********************************************************************
157 * WINPROC_CallWndProc32
159 * Call a 32-bit WndProc.
161 static LRESULT
WINPROC_CallWndProc( WNDPROC proc
, HWND hwnd
, UINT msg
,
162 WPARAM wParam
, LPARAM lParam
)
167 TRACE_(relay
)("(wndproc=%p,hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n",
168 proc
, hwnd
, SPY_GetMsgName(msg
), wParam
, lParam
);
169 /* To avoid any deadlocks, all the locks on the windows structures
170 must be suspended before the control is passed to the application */
171 iWndsLocks
= WIN_SuspendWndsLock();
172 retvalue
= WINPROC_wrapper( proc
, hwnd
, msg
, wParam
, lParam
);
173 WIN_RestoreWndsLock(iWndsLocks
);
174 TRACE_(relay
)("(wndproc=%p,hwnd=%08x,msg=%s,wp=%08x,lp=%08lx) ret=%08lx\n",
175 proc
, hwnd
, SPY_GetMsgName(msg
), wParam
, lParam
, retvalue
);
179 /***********************************************************************
180 * WINPROC_CallWndProc16
182 * Call a 16-bit window procedure
184 static LRESULT WINAPI
WINPROC_CallWndProc16( WNDPROC16 proc
, HWND16 hwnd
,
185 UINT16 msg
, WPARAM16 wParam
,
191 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
193 TEB
*teb
= NtCurrentTeb();
196 /* Window procedures want ax = hInstance, ds = es = ss */
198 memset(&context
, '\0', sizeof(context
));
199 context
.SegDs
= context
.SegEs
= SELECTOROF(teb
->cur_stack
);
200 context
.Eax
= wndPtr
? wndPtr
->hInstance
: context
.SegDs
;
201 context
.SegCs
= SELECTOROF(proc
);
202 context
.Eip
= OFFSETOF(proc
);
203 context
.Ebp
= OFFSETOF(teb
->cur_stack
)
204 + (WORD
)&((STACK16FRAME
*)0)->bp
;
206 WIN_ReleaseWndPtr(wndPtr
);
210 /* Some programs (eg. the "Undocumented Windows" examples, JWP) only
211 work if structures passed in lParam are placed in the stack/data
212 segment. Programmers easily make the mistake of converting lParam
213 to a near rather than a far pointer, since Windows apparently
214 allows this. We copy the structures to the 16 bit stack; this is
215 ugly but makes these programs work. */
220 offset
= sizeof(CREATESTRUCT16
); break;
222 offset
= sizeof(DRAWITEMSTRUCT16
); break;
224 offset
= sizeof(COMPAREITEMSTRUCT16
); break;
228 void *s
= PTR_SEG_TO_LIN(lParam
);
229 lParam
= stack16_push( offset
);
230 memcpy( PTR_SEG_TO_LIN(lParam
), s
, offset
);
234 iWndsLocks
= WIN_SuspendWndsLock();
236 args
= (WORD
*)THREAD_STACK16(teb
) - 5;
237 args
[0] = LOWORD(lParam
);
238 args
[1] = HIWORD(lParam
);
243 wine_call_to_16_regs_short( &context
, 5 * sizeof(WORD
) );
244 ret
= MAKELONG( LOWORD(context
.Eax
), LOWORD(context
.Edx
) );
245 if (offset
) stack16_pop( offset
);
247 WIN_RestoreWndsLock(iWndsLocks
);
253 /**********************************************************************
256 * Return a pointer to the win proc.
258 static WINDOWPROC
*WINPROC_GetPtr( WNDPROC16 handle
)
263 /* Check for a linear pointer */
265 if (handle
&& HeapValidate( WinProcHeap
, 0, (LPVOID
)handle
))
267 ptr
= (BYTE
*)handle
;
268 /* First check if it is the jmp address */
269 if (*ptr
== 0xe9 /* jmp */) ptr
-= (int)&((WINDOWPROC
*)0)->jmp
-
270 (int)&((WINDOWPROC
*)0)->thunk
;
271 /* Now it must be the thunk address */
272 if (*ptr
== 0x58 /* popl eax */) ptr
-= (int)&((WINDOWPROC
*)0)->thunk
;
273 /* Now we have a pointer to the WINDOWPROC struct */
274 if (((WINDOWPROC
*)ptr
)->magic
== WINPROC_MAGIC
)
275 return (WINDOWPROC
*)ptr
;
278 /* Check for a segmented pointer */
280 if (!IsBadReadPtr16((SEGPTR
)handle
,sizeof(WINDOWPROC
)-sizeof(proc
->thunk
)))
282 ptr
= (BYTE
*)PTR_SEG_TO_LIN(handle
);
283 if (!HeapValidate( WinProcHeap
, 0, ptr
)) return NULL
;
284 /* It must be the thunk address */
285 if (*ptr
== 0x58 /* popl eax */) ptr
-= (int)&((WINDOWPROC
*)0)->thunk
;
286 /* Now we have a pointer to the WINDOWPROC struct */
287 if (((WINDOWPROC
*)ptr
)->magic
== WINPROC_MAGIC
)
288 return (WINDOWPROC
*)ptr
;
295 /**********************************************************************
296 * WINPROC_AllocWinProc
298 * Allocate a new window procedure.
300 static WINDOWPROC
*WINPROC_AllocWinProc( WNDPROC16 func
, WINDOWPROCTYPE type
,
301 WINDOWPROCUSER user
)
303 WINDOWPROC
*proc
, *oldproc
;
305 /* Allocate a window procedure */
307 if (!(proc
= HeapAlloc( WinProcHeap
, 0, sizeof(WINDOWPROC
) ))) return 0;
309 /* Check if the function is already a win proc */
311 if ((oldproc
= WINPROC_GetPtr( func
)))
320 proc
->thunk
.t_from32
.popl_eax
= 0x58; /* popl %eax */
321 proc
->thunk
.t_from32
.pushl_func
= 0x68; /* pushl $proc */
322 proc
->thunk
.t_from32
.proc
= func
;
323 proc
->thunk
.t_from32
.pushl_eax
= 0x50; /* pushl %eax */
324 proc
->thunk
.t_from32
.jmp
= 0xe9; /* jmp relay*/
325 proc
->thunk
.t_from32
.relay
= /* relative jump */
326 (void(*)())((DWORD
)WINPROC_CallProc32ATo16
-
327 (DWORD
)(&proc
->thunk
.t_from32
.relay
+ 1));
331 proc
->thunk
.t_from16
.pushw_bp
= 0x5566; /* pushw %bp */
332 proc
->thunk
.t_from16
.pushl_func
= 0x68; /* pushl $proc */
333 proc
->thunk
.t_from16
.proc
= (FARPROC
)func
;
334 proc
->thunk
.t_from16
.pushw_ax
= 0x5066; /* pushw %ax */
335 proc
->thunk
.t_from16
.pushl_relay
= 0x68; /* pushl $relay */
336 proc
->thunk
.t_from16
.relay
= (type
== WIN_PROC_32A
) ?
337 (void(*)())WINPROC_Thunk16To32A
:
338 (void(*)())WINPROC_Thunk16To32W
;
339 proc
->thunk
.t_from16
.lcall
= 0x9a; /* lcall cs:glue */
340 proc
->thunk
.t_from16
.glue
= (void*)__wine_call_from_16_long
;
341 proc
->thunk
.t_from16
.cs
= __get_cs();
342 proc
->thunk
.t_from16
.lret
= 0xca66;
343 proc
->thunk
.t_from16
.nArgs
= 10;
344 proc
->jmp
.jmp
= 0xe9;
345 /* Fixup relative jump */
346 proc
->jmp
.proc
= (WNDPROC
)((DWORD
)func
-
347 (DWORD
)(&proc
->jmp
.proc
+ 1));
350 /* Should not happen */
353 proc
->magic
= WINPROC_MAGIC
;
358 TRACE_(win
)("(%08x,%d): returning %08x\n",
359 (UINT
)func
, type
, (UINT
)proc
);
364 /**********************************************************************
367 * Get a window procedure pointer that can be passed to the Windows program.
369 WNDPROC16
WINPROC_GetProc( HWINDOWPROC proc
, WINDOWPROCTYPE type
)
371 if (!proc
) return NULL
;
372 if (type
== WIN_PROC_16
) /* We want a 16:16 address */
374 if (((WINDOWPROC
*)proc
)->type
== WIN_PROC_16
)
375 return ((WINDOWPROC
*)proc
)->thunk
.t_from32
.proc
;
377 return (WNDPROC16
)HEAP_GetSegptr( WinProcHeap
, 0,
378 &((WINDOWPROC
*)proc
)->thunk
);
380 else /* We want a 32-bit address */
382 if (((WINDOWPROC
*)proc
)->type
== WIN_PROC_16
)
383 return (WNDPROC16
)&((WINDOWPROC
*)proc
)->thunk
;
384 else if (type
!= ((WINDOWPROC
*)proc
)->type
)
385 /* Have to return the jmp address if types don't match */
386 return (WNDPROC16
)&((WINDOWPROC
*)proc
)->jmp
;
388 /* Some Win16 programs want to get back the proc they set */
389 return (WNDPROC16
)((WINDOWPROC
*)proc
)->thunk
.t_from16
.proc
;
394 /**********************************************************************
397 * Set the window procedure for a window or class. There are
398 * three tree classes of winproc callbacks:
400 * 1) class -> wp - not subclassed
401 * class -> wp -> wp -> wp -> wp - SetClassLong()
403 * 2) window -' / - not subclassed
404 * window -> wp -> wp ' - SetWindowLong()
406 * 3) timer -> wp - SetTimer()
408 * Initially, winproc of the window points to the current winproc
409 * thunk of its class. Subclassing prepends a new thunk to the
410 * window winproc chain at the head of the list. Thus, window thunk
411 * list includes class thunks and the latter are preserved when the
412 * window is destroyed.
415 BOOL
WINPROC_SetProc( HWINDOWPROC
*pFirst
, WNDPROC16 func
,
416 WINDOWPROCTYPE type
, WINDOWPROCUSER user
)
418 BOOL bRecycle
= FALSE
;
419 WINDOWPROC
*proc
, **ppPrev
;
421 /* Check if function is already in the list */
423 ppPrev
= (WINDOWPROC
**)pFirst
;
424 proc
= WINPROC_GetPtr( func
);
431 if ((*ppPrev
)->user
!= user
)
433 /* terminal thunk is being restored */
435 WINPROC_FreeProc( *pFirst
, (*ppPrev
)->user
);
436 *(WINDOWPROC
**)pFirst
= *ppPrev
;
445 if (((*ppPrev
)->type
== type
) &&
446 (func
== WINPROC_THUNKPROC(*ppPrev
)))
453 /* WPF_CLASS thunk terminates window thunk list */
454 if ((*ppPrev
)->user
!= user
) break;
455 ppPrev
= &(*ppPrev
)->next
;
460 /* Extract this thunk from the list */
462 *ppPrev
= proc
->next
;
464 else /* Allocate a new one */
466 if (proc
) /* Was already a win proc */
469 func
= WINPROC_THUNKPROC(proc
);
471 proc
= WINPROC_AllocWinProc( func
, type
, user
);
472 if (!proc
) return FALSE
;
475 /* Add the win proc at the head of the list */
477 TRACE_(win
)("(%08x,%08x,%d): res=%08x\n",
478 (UINT
)*pFirst
, (UINT
)func
, type
, (UINT
)proc
);
479 proc
->next
= *(WINDOWPROC
**)pFirst
;
480 *(WINDOWPROC
**)pFirst
= proc
;
485 /**********************************************************************
488 * Free a list of win procs.
490 void WINPROC_FreeProc( HWINDOWPROC proc
, WINDOWPROCUSER user
)
494 WINDOWPROC
*next
= ((WINDOWPROC
*)proc
)->next
;
495 if (((WINDOWPROC
*)proc
)->user
!= user
) break;
496 TRACE_(win
)("freeing %08x\n", (UINT
)proc
);
497 HeapFree( WinProcHeap
, 0, proc
);
503 /**********************************************************************
504 * WINPROC_GetProcType
506 * Return the window procedure type.
508 WINDOWPROCTYPE
WINPROC_GetProcType( HWINDOWPROC proc
)
511 (((WINDOWPROC
*)proc
)->magic
!= WINPROC_MAGIC
))
512 return WIN_PROC_INVALID
;
513 return ((WINDOWPROC
*)proc
)->type
;
515 /**********************************************************************
516 * WINPROC_TestCBForStr
518 * Return TRUE if the lparam is a string
520 static BOOL
WINPROC_TestCBForStr ( HWND hwnd
)
523 WND
* wnd
= WIN_FindWndPtr(hwnd
);
524 retvalue
= ( !(LOWORD(wnd
->dwStyle
) & (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) ||
525 (LOWORD(wnd
->dwStyle
) & CBS_HASSTRINGS
) );
526 WIN_ReleaseWndPtr(wnd
);
529 /**********************************************************************
530 * WINPROC_TestLBForStr
532 * Return TRUE if the lparam is a string
534 static BOOL
WINPROC_TestLBForStr ( HWND hwnd
)
537 WND
* wnd
= WIN_FindWndPtr(hwnd
);
538 retvalue
= ( !(LOWORD(wnd
->dwStyle
) & (LBS_OWNERDRAWFIXED
| LBS_OWNERDRAWVARIABLE
)) ||
539 (LOWORD(wnd
->dwStyle
) & LBS_HASSTRINGS
) );
540 WIN_ReleaseWndPtr(wnd
);
544 /**********************************************************************
545 * WINPROC_MapMsg32ATo32W
547 * Map a message from Ansi to Unicode.
548 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
551 * WM_CHARTOITEM, WM_MENUCHAR
554 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
555 * the first four bytes are the handle of the icon
556 * when the WM_SETTEXT message has been used to set the icon
558 INT
WINPROC_MapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
564 LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0,
565 *pwparam
* sizeof(WCHAR
) + sizeof(LPARAM
) );
567 *ptr
++ = *plparam
; /* Store previous lParam */
568 *plparam
= (LPARAM
)ptr
;
571 /* lparam is string (0-terminated) */
573 case WM_WININICHANGE
:
576 case CB_FINDSTRINGEXACT
:
577 case CB_SELECTSTRING
:
581 case LB_SELECTSTRING
:
583 *plparam
= (LPARAM
)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR
)*plparam
);
584 return (*plparam
? 1 : -1);
590 { CREATESTRUCTW cs
; /* new structure */
591 LPCWSTR lpszName
; /* allocated Name */
592 LPCWSTR lpszClass
; /* allocated Class */
595 struct s
*xs
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct s
));
597 xs
->cs
= *(CREATESTRUCTW
*)*plparam
;
598 if (HIWORD(xs
->cs
.lpszName
))
599 xs
->lpszName
= xs
->cs
.lpszName
= HEAP_strdupAtoW( GetProcessHeap(), 0,
600 (LPCSTR
)xs
->cs
.lpszName
);
601 if (HIWORD(xs
->cs
.lpszClass
))
602 xs
->lpszClass
= xs
->cs
.lpszClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
603 (LPCSTR
)xs
->cs
.lpszClass
);
604 *plparam
= (LPARAM
)xs
;
609 MDICREATESTRUCTW
*cs
=
610 (MDICREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
612 *cs
= *(MDICREATESTRUCTW
*)*plparam
;
613 if (HIWORD(cs
->szClass
))
614 cs
->szClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
615 (LPCSTR
)cs
->szClass
);
616 if (HIWORD(cs
->szTitle
))
617 cs
->szTitle
= HEAP_strdupAtoW( GetProcessHeap(), 0,
618 (LPCSTR
)cs
->szTitle
);
619 *plparam
= (LPARAM
)cs
;
625 case LB_INSERTSTRING
:
626 if ( WINPROC_TestLBForStr( hwnd
))
627 *plparam
= (LPARAM
)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR
)*plparam
);
628 return (*plparam
? 1 : -1);
630 case LB_GETTEXT
: /* fixme: fixed sized buffer */
631 { if ( WINPROC_TestLBForStr( hwnd
))
632 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR
) + sizeof(LPARAM
) );
634 *ptr
++ = *plparam
; /* Store previous lParam */
635 *plparam
= (LPARAM
)ptr
;
642 case CB_INSERTSTRING
:
643 if ( WINPROC_TestCBForStr( hwnd
))
644 *plparam
= (LPARAM
)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR
)*plparam
);
645 return (*plparam
? 1 : -1);
647 case CB_GETLBTEXT
: /* fixme: fixed sized buffer */
648 { if ( WINPROC_TestCBForStr( hwnd
))
649 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR
) + sizeof(LPARAM
) );
651 *ptr
++ = *plparam
; /* Store previous lParam */
652 *plparam
= (LPARAM
)ptr
;
659 { WORD len
= (WORD
)*plparam
;
660 LPARAM
*ptr
= (LPARAM
*) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(WCHAR
) );
662 *ptr
++ = *plparam
; /* Store previous lParam */
663 *((WORD
*) ptr
) = len
; /* Store the length */
664 *plparam
= (LPARAM
)ptr
;
672 case EM_SETPASSWORDCHAR
:
676 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wch
, 1);
681 case WM_ASKCBFORMATNAME
:
682 case WM_DEVMODECHANGE
:
683 case WM_PAINTCLIPBOARD
:
684 case WM_SIZECLIPBOARD
:
685 FIXME_(msg
)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg
), msg
);
687 default: /* No translation needed */
693 /**********************************************************************
694 * WINPROC_UnmapMsg32ATo32W
696 * Unmap a message that was mapped from Ansi to Unicode.
698 void WINPROC_UnmapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
704 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
705 if (wParam
> 0 && !WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
706 (LPSTR
)*ptr
, wParam
, NULL
, NULL
))
707 ((LPSTR
)*ptr
)[wParam
-1] = 0;
708 HeapFree( GetProcessHeap(), 0, ptr
);
716 { CREATESTRUCTW cs
; /* new structure */
717 LPWSTR lpszName
; /* allocated Name */
718 LPWSTR lpszClass
; /* allocated Class */
720 struct s
*xs
= (struct s
*)lParam
;
721 if (xs
->lpszName
) HeapFree( GetProcessHeap(), 0, xs
->lpszName
);
722 if (xs
->lpszClass
) HeapFree( GetProcessHeap(), 0, xs
->lpszClass
);
723 HeapFree( GetProcessHeap(), 0, xs
);
729 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
730 if (HIWORD(cs
->szTitle
))
731 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
732 if (HIWORD(cs
->szClass
))
733 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
734 HeapFree( GetProcessHeap(), 0, cs
);
739 case WM_WININICHANGE
:
742 case CB_FINDSTRINGEXACT
:
743 case CB_SELECTSTRING
:
747 case LB_SELECTSTRING
:
749 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
754 case LB_INSERTSTRING
:
755 if ( WINPROC_TestLBForStr( hwnd
))
756 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
760 { if ( WINPROC_TestLBForStr( hwnd
))
761 { LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
762 WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1, (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
);
763 HeapFree( GetProcessHeap(), 0, ptr
);
770 case CB_INSERTSTRING
:
771 if ( WINPROC_TestCBForStr( hwnd
))
772 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
776 { if ( WINPROC_TestCBForStr( hwnd
))
777 { LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
778 WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1, (LPSTR
)*ptr
, 0x7fffffff, NULL
, NULL
);
779 HeapFree( GetProcessHeap(), 0, ptr
);
786 { LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lParam */
787 WORD len
= *(WORD
*) lParam
;
788 if (len
> 0 && !WideCharToMultiByte( CP_ACP
, 0, (LPWSTR
)lParam
, -1,
789 (LPSTR
)*ptr
, len
, NULL
, NULL
))
790 ((LPSTR
)*ptr
)[len
-1] = 0;
791 HeapFree( GetProcessHeap(), 0, ptr
);
798 /**********************************************************************
799 * WINPROC_MapMsg32WTo32A
801 * Map a message from Unicode to Ansi.
802 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
804 INT
WINPROC_MapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM
*pwparam
, LPARAM
*plparam
)
810 LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0,
811 *pwparam
+ sizeof(LPARAM
) );
813 *ptr
++ = *plparam
; /* Store previous lParam */
814 *plparam
= (LPARAM
)ptr
;
819 case WM_WININICHANGE
:
822 case CB_FINDSTRINGEXACT
:
823 case CB_SELECTSTRING
:
827 case LB_SELECTSTRING
:
829 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
830 return (*plparam
? 1 : -1);
835 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0,
838 *cs
= *(CREATESTRUCTA
*)*plparam
;
839 if (HIWORD(cs
->lpszName
))
840 cs
->lpszName
= HEAP_strdupWtoA( GetProcessHeap(), 0,
841 (LPCWSTR
)cs
->lpszName
);
842 if (HIWORD(cs
->lpszClass
))
843 cs
->lpszClass
= HEAP_strdupWtoA( GetProcessHeap(), 0,
844 (LPCWSTR
)cs
->lpszClass
);
845 *plparam
= (LPARAM
)cs
;
850 MDICREATESTRUCTA
*cs
=
851 (MDICREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs
) );
853 *cs
= *(MDICREATESTRUCTA
*)*plparam
;
854 if (HIWORD(cs
->szTitle
))
855 cs
->szTitle
= HEAP_strdupWtoA( GetProcessHeap(), 0,
856 (LPCWSTR
)cs
->szTitle
);
857 if (HIWORD(cs
->szClass
))
858 cs
->szClass
= HEAP_strdupWtoA( GetProcessHeap(), 0,
859 (LPCWSTR
)cs
->szClass
);
860 *plparam
= (LPARAM
)cs
;
866 case LB_INSERTSTRING
:
867 if ( WINPROC_TestLBForStr( hwnd
))
868 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
869 return (*plparam
? 1 : -1);
871 case LB_GETTEXT
: /* fixme: fixed sized buffer */
872 { if ( WINPROC_TestLBForStr( hwnd
))
873 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM
) );
875 *ptr
++ = *plparam
; /* Store previous lParam */
876 *plparam
= (LPARAM
)ptr
;
883 case CB_INSERTSTRING
:
884 if ( WINPROC_TestCBForStr( hwnd
))
885 *plparam
= (LPARAM
)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR
)*plparam
);
886 return (*plparam
? 1 : -1);
888 case CB_GETLBTEXT
: /* fixme: fixed sized buffer */
889 { if ( WINPROC_TestCBForStr( hwnd
))
890 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM
) );
892 *ptr
++ = *plparam
; /* Store previous lParam */
893 *plparam
= (LPARAM
)ptr
;
900 { WORD len
= (WORD
)*plparam
;
901 LPARAM
*ptr
= (LPARAM
*) HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(CHAR
) );
903 *ptr
++ = *plparam
; /* Store previous lParam */
904 *((WORD
*) ptr
) = len
; /* Store the length */
905 *plparam
= (LPARAM
)ptr
;
913 case EM_SETPASSWORDCHAR
:
915 WCHAR wch
= *pwparam
;
917 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
922 case WM_ASKCBFORMATNAME
:
923 case WM_DEVMODECHANGE
:
924 case WM_PAINTCLIPBOARD
:
925 case WM_SIZECLIPBOARD
:
926 FIXME_(msg
)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg
),msg
);
928 default: /* No translation needed */
934 /**********************************************************************
935 * WINPROC_UnmapMsg32WTo32A
937 * Unmap a message that was mapped from Unicode to Ansi.
939 void WINPROC_UnmapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
945 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
948 if (!MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, wParam
))
949 ((LPWSTR
)*ptr
)[wParam
-1] = 0;
951 HeapFree( GetProcessHeap(), 0, ptr
);
956 case WM_WININICHANGE
:
959 case CB_FINDSTRINGEXACT
:
960 case CB_SELECTSTRING
:
964 case LB_SELECTSTRING
:
966 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
972 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
973 if (HIWORD(cs
->lpszName
))
974 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszName
);
975 if (HIWORD(cs
->lpszClass
))
976 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszClass
);
977 HeapFree( GetProcessHeap(), 0, cs
);
983 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
984 if (HIWORD(cs
->szTitle
))
985 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
986 if (HIWORD(cs
->szClass
))
987 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
988 HeapFree( GetProcessHeap(), 0, cs
);
994 case LB_INSERTSTRING
:
995 if ( WINPROC_TestLBForStr( hwnd
))
996 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1000 if ( WINPROC_TestLBForStr( hwnd
))
1002 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1003 MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff );
1004 HeapFree( GetProcessHeap(), 0, ptr
);
1010 case CB_INSERTSTRING
:
1011 if ( WINPROC_TestCBForStr( hwnd
))
1012 HeapFree( GetProcessHeap(), 0, (void *)lParam
);
1016 if ( WINPROC_TestCBForStr( hwnd
))
1018 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
1019 MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, 0x7fffffff );
1020 HeapFree( GetProcessHeap(), 0, ptr
);
1024 /* Multiline edit */
1026 { LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lparam */
1027 WORD len
= *(WORD
*)ptr
;
1030 if (!MultiByteToWideChar( CP_ACP
, 0, (LPSTR
)lParam
, -1, (LPWSTR
)*ptr
, len
))
1031 ((LPWSTR
)*ptr
)[len
-1] = 0;
1033 HeapFree( GetProcessHeap(), 0, ptr
);
1040 /**********************************************************************
1041 * WINPROC_MapMsg16To32A
1043 * Map a message from 16- to 32-bit Ansi.
1044 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1046 INT
WINPROC_MapMsg16To32A( UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1047 WPARAM
*pwparam32
, LPARAM
*plparam
)
1049 *pmsg32
= (UINT
)msg16
;
1050 *pwparam32
= (WPARAM
)wParam16
;
1057 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1058 *plparam
= (LPARAM
)(HWND
)LOWORD(*plparam
);
1062 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1063 *plparam
= (LPARAM
)(HWND
)HIWORD(*plparam
);
1066 if ( HIWORD(*plparam
) > CTLCOLOR_STATIC
) return -1;
1067 *pmsg32
= WM_CTLCOLORMSGBOX
+ HIWORD(*plparam
);
1068 *pwparam32
= (WPARAM
)(HDC
)wParam16
;
1069 *plparam
= (LPARAM
)(HWND
)LOWORD(*plparam
);
1071 case WM_COMPAREITEM
:
1073 COMPAREITEMSTRUCT16
* cis16
= (COMPAREITEMSTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1074 COMPAREITEMSTRUCT
*cis
= (COMPAREITEMSTRUCT
*)
1075 HeapAlloc(GetProcessHeap(), 0, sizeof(*cis
));
1076 if (!cis
) return -1;
1077 cis
->CtlType
= cis16
->CtlType
;
1078 cis
->CtlID
= cis16
->CtlID
;
1079 cis
->hwndItem
= cis16
->hwndItem
;
1080 cis
->itemID1
= cis16
->itemID1
;
1081 cis
->itemData1
= cis16
->itemData1
;
1082 cis
->itemID2
= cis16
->itemID2
;
1083 cis
->itemData2
= cis16
->itemData2
;
1084 cis
->dwLocaleId
= 0; /* FIXME */
1085 *plparam
= (LPARAM
)cis
;
1090 DELETEITEMSTRUCT16
* dis16
= (DELETEITEMSTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1091 DELETEITEMSTRUCT
*dis
= (DELETEITEMSTRUCT
*)
1092 HeapAlloc(GetProcessHeap(), 0, sizeof(*dis
));
1093 if (!dis
) return -1;
1094 dis
->CtlType
= dis16
->CtlType
;
1095 dis
->CtlID
= dis16
->CtlID
;
1096 dis
->hwndItem
= dis16
->hwndItem
;
1097 dis
->itemData
= dis16
->itemData
;
1098 *plparam
= (LPARAM
)dis
;
1101 case WM_MEASUREITEM
:
1103 MEASUREITEMSTRUCT16
* mis16
= (MEASUREITEMSTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1104 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)
1105 HeapAlloc(GetProcessHeap(), 0,
1106 sizeof(*mis
) + sizeof(LPARAM
));
1107 if (!mis
) return -1;
1108 mis
->CtlType
= mis16
->CtlType
;
1109 mis
->CtlID
= mis16
->CtlID
;
1110 mis
->itemID
= mis16
->itemID
;
1111 mis
->itemWidth
= mis16
->itemWidth
;
1112 mis
->itemHeight
= mis16
->itemHeight
;
1113 mis
->itemData
= mis16
->itemData
;
1114 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1115 *plparam
= (LPARAM
)mis
;
1120 DRAWITEMSTRUCT16
* dis16
= (DRAWITEMSTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1121 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)HeapAlloc(GetProcessHeap(), 0,
1123 if (!dis
) return -1;
1124 dis
->CtlType
= dis16
->CtlType
;
1125 dis
->CtlID
= dis16
->CtlID
;
1126 dis
->itemID
= dis16
->itemID
;
1127 dis
->itemAction
= dis16
->itemAction
;
1128 dis
->itemState
= dis16
->itemState
;
1129 dis
->hwndItem
= dis16
->hwndItem
;
1130 dis
->hDC
= dis16
->hDC
;
1131 dis
->itemData
= dis16
->itemData
;
1132 CONV_RECT16TO32( &dis16
->rcItem
, &dis
->rcItem
);
1133 *plparam
= (LPARAM
)dis
;
1136 case WM_GETMINMAXINFO
:
1138 MINMAXINFO
*mmi
= (MINMAXINFO
*)HeapAlloc( GetProcessHeap(), 0,
1139 sizeof(*mmi
) + sizeof(LPARAM
));
1140 if (!mmi
) return -1;
1141 STRUCT32_MINMAXINFO16to32( (MINMAXINFO16
*)PTR_SEG_TO_LIN(*plparam
),
1143 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1144 *plparam
= (LPARAM
)mmi
;
1149 *plparam
= (LPARAM
)PTR_SEG_TO_LIN(*plparam
);
1153 MDICREATESTRUCT16
*cs16
=
1154 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1155 MDICREATESTRUCTA
*cs
=
1156 (MDICREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0,
1157 sizeof(*cs
) + sizeof(LPARAM
) );
1159 STRUCT32_MDICREATESTRUCT16to32A( cs16
, cs
);
1160 cs
->szTitle
= (LPCSTR
)PTR_SEG_TO_LIN(cs16
->szTitle
);
1161 cs
->szClass
= (LPCSTR
)PTR_SEG_TO_LIN(cs16
->szClass
);
1162 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1163 *plparam
= (LPARAM
)cs
;
1166 case WM_MDIGETACTIVE
:
1167 *plparam
= (LPARAM
)HeapAlloc( GetProcessHeap(), 0, sizeof(BOOL
) );
1168 *(BOOL
*)(*plparam
) = 0;
1172 *pmsg32
=WM_MDIREFRESHMENU
;
1173 *pwparam32
= (WPARAM
)(HMENU
)LOWORD(*plparam
);
1174 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1177 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1178 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1181 if((LOWORD(*plparam
) & MF_POPUP
) && (LOWORD(*plparam
) != 0xFFFF))
1183 HMENU hmenu
=(HMENU
)HIWORD(*plparam
);
1184 UINT Pos
=MENU_FindSubMenu( &hmenu
, wParam16
);
1185 if(Pos
==0xFFFF) Pos
=0; /* NO_SELECTED_ITEM */
1186 *pwparam32
= MAKEWPARAM( Pos
, LOWORD(*plparam
) );
1188 else *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1189 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1191 case WM_MDIACTIVATE
:
1194 *pwparam32
= (WPARAM
)(HWND
)HIWORD(*plparam
);
1195 *plparam
= (LPARAM
)(HWND
)LOWORD(*plparam
);
1197 else /* message sent to MDI client */
1198 *pwparam32
= wParam16
;
1202 NCCALCSIZE_PARAMS16
*nc16
;
1203 NCCALCSIZE_PARAMS
*nc
;
1205 nc
= (NCCALCSIZE_PARAMS
*)HeapAlloc( GetProcessHeap(), 0,
1206 sizeof(*nc
) + sizeof(LPARAM
) );
1208 nc16
= (NCCALCSIZE_PARAMS16
*)PTR_SEG_TO_LIN(*plparam
);
1209 CONV_RECT16TO32( &nc16
->rgrc
[0], &nc
->rgrc
[0] );
1212 nc
->lppos
= (WINDOWPOS
*)HeapAlloc( GetProcessHeap(), 0,
1213 sizeof(*nc
->lppos
) );
1214 CONV_RECT16TO32( &nc16
->rgrc
[1], &nc
->rgrc
[1] );
1215 CONV_RECT16TO32( &nc16
->rgrc
[2], &nc
->rgrc
[2] );
1216 if (nc
->lppos
) STRUCT32_WINDOWPOS16to32( (WINDOWPOS16
*)PTR_SEG_TO_LIN(nc16
->lppos
), nc
->lppos
);
1218 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1219 *plparam
= (LPARAM
)nc
;
1225 CREATESTRUCT16
*cs16
= (CREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1226 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)HeapAlloc( GetProcessHeap(), 0,
1227 sizeof(*cs
) + sizeof(LPARAM
) );
1229 STRUCT32_CREATESTRUCT16to32A( cs16
, cs
);
1230 cs
->lpszName
= (LPCSTR
)PTR_SEG_TO_LIN(cs16
->lpszName
);
1231 cs
->lpszClass
= (LPCSTR
)PTR_SEG_TO_LIN(cs16
->lpszClass
);
1232 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1233 *plparam
= (LPARAM
)cs
;
1236 case WM_PARENTNOTIFY
:
1237 if ((wParam16
== WM_CREATE
) || (wParam16
== WM_DESTROY
))
1239 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1240 *plparam
= (LPARAM
)(HWND
)LOWORD(*plparam
);
1243 case WM_WINDOWPOSCHANGING
:
1244 case WM_WINDOWPOSCHANGED
:
1246 WINDOWPOS
*wp
= (WINDOWPOS
*)HeapAlloc( GetProcessHeap(), 0,
1247 sizeof(*wp
) + sizeof(LPARAM
) );
1249 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16
*)PTR_SEG_TO_LIN(*plparam
),
1251 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1252 *plparam
= (LPARAM
)wp
;
1258 LPMSG16 msg16
= (LPMSG16
)PTR_SEG_TO_LIN(*plparam
);
1259 LPMSG msg32
= (LPMSG
)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1261 if (!msg32
) return -1;
1262 msg32
->hwnd
= msg16
->hwnd
;
1263 msg32
->lParam
= msg16
->lParam
;
1264 msg32
->time
= msg16
->time
;
1265 CONV_POINT16TO32(&msg16
->pt
,&msg32
->pt
);
1266 /* this is right, right? */
1267 if (WINPROC_MapMsg16To32A(msg16
->message
,msg16
->wParam
,
1268 &msg32
->message
,&msg32
->wParam
,
1269 &msg32
->lParam
)<0) {
1270 HeapFree( GetProcessHeap(), 0, msg32
);
1273 *plparam
= (LPARAM
)msg32
;
1278 *plparam
= (LPARAM
)PTR_SEG_TO_LIN(*plparam
);
1280 case WM_ACTIVATEAPP
:
1282 { /* We need this when SetActiveWindow sends a Sendmessage16() to
1283 a 32bit window. Might be superflous with 32bit interprocess
1286 HTASK16 htask
= (HTASK16
) *plparam
;
1287 DWORD idThread
= (DWORD
)((TDB
*)GlobalLock16(htask
))->teb
->tid
;
1288 *plparam
= (LPARAM
) idThread
;
1291 case WM_ASKCBFORMATNAME
:
1292 case WM_DEVMODECHANGE
:
1293 case WM_PAINTCLIPBOARD
:
1294 case WM_SIZECLIPBOARD
:
1295 case WM_WININICHANGE
:
1296 FIXME_(msg
)("message %04x needs translation\n",msg16
);
1299 default: /* No translation needed */
1305 /**********************************************************************
1306 * WINPROC_UnmapMsg16To32A
1308 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1310 LRESULT
WINPROC_UnmapMsg16To32A( HWND16 hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1315 case WM_COMPAREITEM
:
1318 HeapFree( GetProcessHeap(), 0, (LPVOID
)lParam
);
1320 case WM_MEASUREITEM
:
1322 MEASUREITEMSTRUCT16
*mis16
;
1323 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)lParam
;
1324 lParam
= *(LPARAM
*)(mis
+ 1);
1325 mis16
= (MEASUREITEMSTRUCT16
*)PTR_SEG_TO_LIN(lParam
);
1326 mis16
->itemWidth
= (UINT16
)mis
->itemWidth
;
1327 mis16
->itemHeight
= (UINT16
)mis
->itemHeight
;
1328 HeapFree( GetProcessHeap(), 0, mis
);
1331 case WM_GETMINMAXINFO
:
1333 MINMAXINFO
*mmi
= (MINMAXINFO
*)lParam
;
1334 lParam
= *(LPARAM
*)(mmi
+ 1);
1335 STRUCT32_MINMAXINFO32to16( mmi
,
1336 (MINMAXINFO16
*)PTR_SEG_TO_LIN(lParam
));
1337 HeapFree( GetProcessHeap(), 0, mmi
);
1342 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1343 lParam
= *(LPARAM
*)(cs
+ 1);
1344 STRUCT32_MDICREATESTRUCT32Ato16( cs
,
1345 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1346 HeapFree( GetProcessHeap(), 0, cs
);
1349 case WM_MDIGETACTIVE
:
1350 result
= MAKELONG( LOWORD(result
), (BOOL16
)(*(BOOL
*)lParam
) );
1351 HeapFree( GetProcessHeap(), 0, (BOOL
*)lParam
);
1355 NCCALCSIZE_PARAMS16
*nc16
;
1356 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lParam
;
1357 lParam
= *(LPARAM
*)(nc
+ 1);
1358 nc16
= (NCCALCSIZE_PARAMS16
*)PTR_SEG_TO_LIN(lParam
);
1359 CONV_RECT32TO16( &nc
->rgrc
[0], &nc16
->rgrc
[0] );
1362 CONV_RECT32TO16( &nc
->rgrc
[1], &nc16
->rgrc
[1] );
1363 CONV_RECT32TO16( &nc
->rgrc
[2], &nc16
->rgrc
[2] );
1366 STRUCT32_WINDOWPOS32to16( nc
->lppos
,
1367 (WINDOWPOS16
*)PTR_SEG_TO_LIN(nc16
->lppos
));
1368 HeapFree( GetProcessHeap(), 0, nc
->lppos
);
1371 HeapFree( GetProcessHeap(), 0, nc
);
1377 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
1378 lParam
= *(LPARAM
*)(cs
+ 1);
1379 STRUCT32_CREATESTRUCT32Ato16( cs
,
1380 (CREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1381 HeapFree( GetProcessHeap(), 0, cs
);
1384 case WM_WINDOWPOSCHANGING
:
1385 case WM_WINDOWPOSCHANGED
:
1387 WINDOWPOS
*wp
= (WINDOWPOS
*)lParam
;
1388 lParam
= *(LPARAM
*)(wp
+ 1);
1389 STRUCT32_WINDOWPOS32to16(wp
,(WINDOWPOS16
*)PTR_SEG_TO_LIN(lParam
));
1390 HeapFree( GetProcessHeap(), 0, wp
);
1396 LPMSG msg32
= (LPMSG
)lParam
;
1398 WINPROC_UnmapMsg16To32A( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1400 HeapFree( GetProcessHeap(), 0, msg32
);
1408 /**********************************************************************
1409 * WINPROC_MapMsg16To32W
1411 * Map a message from 16- to 32-bit Unicode.
1412 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1414 INT
WINPROC_MapMsg16To32W( HWND16 hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1415 WPARAM
*pwparam32
, LPARAM
*plparam
)
1421 WORD len
= (WORD
)*plparam
;
1422 LPARAM
*ptr
= (LPARAM
*)HeapAlloc(GetProcessHeap(), 0, sizeof(LPARAM
) + sizeof(WORD
) + len
* sizeof(WCHAR
));
1424 *ptr
++ = *plparam
; /* Store previous lParam */
1425 *((WORD
*)ptr
) = len
; /* Store the length */
1426 *plparam
= (LPARAM
)ptr
;
1430 case EM_REPLACESEL16
:
1434 *plparam
= (LPARAM
)PTR_SEG_TO_LIN(*plparam
);
1435 len
= MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*plparam
, -1, NULL
, 0);
1436 str
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1438 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)*plparam
, -1, str
, len
);
1439 *plparam
= (LPARAM
)str
;
1443 case EM_SETPASSWORDCHAR16
:
1447 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wch
, 1);
1454 *plparam
= (LPARAM
)PTR_SEG_TO_LIN(*plparam
);
1455 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1459 CREATESTRUCT16
*cs16
= (CREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1460 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0,
1461 sizeof(*cs
) + sizeof(LPARAM
) );
1463 STRUCT32_CREATESTRUCT16to32A( cs16
, (CREATESTRUCTA
*)cs
);
1464 cs
->lpszName
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->lpszName
);
1465 cs
->lpszClass
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->lpszClass
);
1466 if (HIWORD(cs
->lpszName
))
1467 cs
->lpszName
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1468 (LPCSTR
)cs
->lpszName
);
1469 if (HIWORD(cs
->lpszClass
))
1470 cs
->lpszClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1471 (LPCSTR
)cs
->lpszClass
);
1472 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1473 *plparam
= (LPARAM
)cs
;
1478 MDICREATESTRUCT16
*cs16
=
1479 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1480 MDICREATESTRUCTW
*cs
=
1481 (MDICREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0,
1482 sizeof(*cs
) + sizeof(LPARAM
) );
1484 STRUCT32_MDICREATESTRUCT16to32A( cs16
, (MDICREATESTRUCTA
*)cs
);
1485 cs
->szTitle
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->szTitle
);
1486 cs
->szClass
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->szClass
);
1487 if (HIWORD(cs
->szTitle
))
1488 cs
->szTitle
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1489 (LPCSTR
)cs
->szTitle
);
1490 if (HIWORD(cs
->szClass
))
1491 cs
->szClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1492 (LPCSTR
)cs
->szClass
);
1493 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1494 *plparam
= (LPARAM
)cs
;
1500 LPMSG16 msg16
= (LPMSG16
)PTR_SEG_TO_LIN(*plparam
);
1501 LPMSG msg32
= (LPMSG
)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1503 if (!msg32
) return -1;
1504 msg32
->hwnd
= msg16
->hwnd
;
1505 msg32
->lParam
= msg16
->lParam
;
1506 msg32
->time
= msg16
->time
;
1507 CONV_POINT16TO32(&msg16
->pt
,&msg32
->pt
);
1508 /* this is right, right? */
1509 if (WINPROC_MapMsg16To32W(hwnd
, msg16
->message
,msg16
->wParam
,
1510 &msg32
->message
,&msg32
->wParam
,
1511 &msg32
->lParam
)<0) {
1512 HeapFree( GetProcessHeap(), 0, msg32
);
1515 *plparam
= (LPARAM
)msg32
;
1523 case WM_SYSDEADCHAR
:
1527 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1532 default: /* No Unicode translation needed */
1533 return WINPROC_MapMsg16To32A( msg16
, wParam16
, pmsg32
,
1534 pwparam32
, plparam
);
1539 /**********************************************************************
1540 * WINPROC_UnmapMsg16To32W
1542 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1544 LRESULT
WINPROC_UnmapMsg16To32W( HWND16 hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1551 LPARAM
*ptr
= (LPARAM
*)lParam
- 1; /* get the old lParam */
1552 WORD len
= *(WORD
*)lParam
;
1553 *ptr
= (LPARAM
)PTR_SEG_TO_LIN(*ptr
);
1554 if(len
> 0 && !WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)lParam
, -1,
1555 (LPSTR
)*ptr
, len
, NULL
, NULL
))
1556 ((LPSTR
)*ptr
)[len
-1] = 0;
1557 HeapFree(GetProcessHeap(), 0, ptr
);
1561 case EM_REPLACESEL16
:
1562 HeapFree(GetProcessHeap(), 0, (void *)lParam
);
1567 WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
);
1572 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
1573 lParam
= *(LPARAM
*)(cs
+ 1);
1574 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs
,
1575 (CREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1576 if (HIWORD(cs
->lpszName
))
1577 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszName
);
1578 if (HIWORD(cs
->lpszClass
))
1579 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszClass
);
1580 HeapFree( GetProcessHeap(), 0, cs
);
1585 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
1586 lParam
= *(LPARAM
*)(cs
+ 1);
1587 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs
,
1588 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1589 if (HIWORD(cs
->szTitle
))
1590 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
1591 if (HIWORD(cs
->szClass
))
1592 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
1593 HeapFree( GetProcessHeap(), 0, cs
);
1599 LPMSG msg32
= (LPMSG
)lParam
;
1601 WINPROC_UnmapMsg16To32W( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1603 HeapFree( GetProcessHeap(), 0, msg32
);
1607 return WINPROC_UnmapMsg16To32A( hwnd
, msg
, wParam
, lParam
, result
);
1613 /**********************************************************************
1614 * WINPROC_MapMsg32ATo16
1616 * Map a message from 32-bit Ansi to 16-bit.
1617 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1619 INT
WINPROC_MapMsg32ATo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
1620 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
1623 *pmsg16
= (UINT16
)msg32
;
1624 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
1632 *pmsg16
= (UINT16
)msg32
+ (BM_GETCHECK16
- BM_GETCHECK
);
1641 case EM_SCROLLCARET
:
1644 case EM_GETLINECOUNT
:
1656 case EM_LINEFROMCHAR
:
1657 case EM_SETTABSTOPS
:
1658 case EM_SETPASSWORDCHAR
:
1659 case EM_EMPTYUNDOBUFFER
:
1660 case EM_GETFIRSTVISIBLELINE
:
1661 case EM_SETREADONLY
:
1662 case EM_SETWORDBREAKPROC
:
1663 case EM_GETWORDBREAKPROC
:
1664 case EM_GETPASSWORDCHAR
:
1665 *pmsg16
= (UINT16
)msg32
+ (EM_GETSEL16
- EM_GETSEL
);
1670 case LB_DELETESTRING
:
1671 case LB_GETANCHORINDEX
:
1672 case LB_GETCARETINDEX
:
1675 case LB_GETHORIZONTALEXTENT
:
1676 case LB_GETITEMDATA
:
1677 case LB_GETITEMHEIGHT
:
1679 case LB_GETSELCOUNT
:
1681 case LB_GETTOPINDEX
:
1682 case LB_RESETCONTENT
:
1683 case LB_SELITEMRANGE
:
1684 case LB_SELITEMRANGEEX
:
1685 case LB_SETANCHORINDEX
:
1686 case LB_SETCARETINDEX
:
1687 case LB_SETCOLUMNWIDTH
:
1689 case LB_SETHORIZONTALEXTENT
:
1690 case LB_SETITEMDATA
:
1691 case LB_SETITEMHEIGHT
:
1693 case LB_SETTOPINDEX
:
1694 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1696 case CB_DELETESTRING
:
1698 case CB_GETLBTEXTLEN
:
1700 case CB_RESETCONTENT
:
1704 case CB_SHOWDROPDOWN
:
1705 case CB_SETITEMDATA
:
1706 case CB_SETITEMHEIGHT
:
1707 case CB_GETITEMHEIGHT
:
1708 case CB_SETEXTENDEDUI
:
1709 case CB_GETEXTENDEDUI
:
1710 case CB_GETDROPPEDSTATE
:
1711 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
1714 *pmsg16
= CB_GETEDITSEL16
;
1719 case LB_FINDSTRINGEXACT
:
1720 case LB_INSERTSTRING
:
1721 case LB_SELECTSTRING
:
1725 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1726 if (!str
) return -1;
1727 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1729 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1734 case CB_FINDSTRINGEXACT
:
1735 case CB_INSERTSTRING
:
1736 case CB_SELECTSTRING
:
1739 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1740 if (!str
) return -1;
1741 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1743 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
1746 case LB_GETITEMRECT
:
1749 rect
= (RECT16
*)SEGPTR_ALLOC( sizeof(RECT16
) + sizeof(LPARAM
) );
1750 if (!rect
) return -1;
1751 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
1752 *plparam
= (LPARAM
)SEGPTR_GET(rect
);
1754 *pmsg16
= LB_GETITEMRECT16
;
1756 case LB_GETSELITEMS
:
1759 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
1760 if (!(items
= SEGPTR_ALLOC( *pwparam16
* sizeof(INT16
)
1761 + sizeof(LPARAM
)))) return -1;
1762 *((LPARAM
*)items
)++ = *plparam
; /* Store the previous lParam */
1763 *plparam
= (LPARAM
)SEGPTR_GET(items
);
1765 *pmsg16
= LB_GETSELITEMS16
;
1767 case LB_SETTABSTOPS
:
1772 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
1773 if (!(stops
= SEGPTR_ALLOC( *pwparam16
* sizeof(INT16
)
1774 + sizeof(LPARAM
)))) return -1;
1775 for (i
= 0; i
< *pwparam16
; i
++) stops
[i
] = *((LPINT
)*plparam
+i
);
1776 *plparam
= (LPARAM
)SEGPTR_GET(stops
);
1779 *pmsg16
= LB_SETTABSTOPS16
;
1782 case CB_GETDROPPEDCONTROLRECT
:
1785 rect
= (RECT16
*)SEGPTR_ALLOC( sizeof(RECT16
) + sizeof(LPARAM
) );
1786 if (!rect
) return -1;
1787 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
1788 *plparam
= (LPARAM
)SEGPTR_GET(rect
);
1790 *pmsg16
= CB_GETDROPPEDCONTROLRECT16
;
1794 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
1795 *pmsg16
= LB_GETTEXT16
;
1799 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
1800 *pmsg16
= CB_GETLBTEXT16
;
1805 *plparam
= MAKELONG( (INT16
)(INT
)wParam32
, (INT16
)*plparam
);
1806 *pmsg16
= EM_SETSEL16
;
1813 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
1817 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HWND16
)*plparam
);
1819 case WM_CTLCOLORMSGBOX
:
1820 case WM_CTLCOLOREDIT
:
1821 case WM_CTLCOLORLISTBOX
:
1822 case WM_CTLCOLORBTN
:
1823 case WM_CTLCOLORDLG
:
1824 case WM_CTLCOLORSCROLLBAR
:
1825 case WM_CTLCOLORSTATIC
:
1826 *pmsg16
= WM_CTLCOLOR
;
1827 *plparam
= MAKELPARAM( (HWND16
)*plparam
,
1828 (WORD
)msg32
- WM_CTLCOLORMSGBOX
);
1830 case WM_COMPAREITEM
:
1832 COMPAREITEMSTRUCT
*cis32
= (COMPAREITEMSTRUCT
*)*plparam
;
1833 COMPAREITEMSTRUCT16
*cis
= SEGPTR_NEW(COMPAREITEMSTRUCT16
);
1834 if (!cis
) return -1;
1835 cis
->CtlType
= (UINT16
)cis32
->CtlType
;
1836 cis
->CtlID
= (UINT16
)cis32
->CtlID
;
1837 cis
->hwndItem
= (HWND16
)cis32
->hwndItem
;
1838 cis
->itemID1
= (UINT16
)cis32
->itemID1
;
1839 cis
->itemData1
= cis32
->itemData1
;
1840 cis
->itemID2
= (UINT16
)cis32
->itemID2
;
1841 cis
->itemData2
= cis32
->itemData2
;
1842 *plparam
= (LPARAM
)SEGPTR_GET(cis
);
1847 DELETEITEMSTRUCT
*dis32
= (DELETEITEMSTRUCT
*)*plparam
;
1848 DELETEITEMSTRUCT16
*dis
= SEGPTR_NEW(DELETEITEMSTRUCT16
);
1849 if (!dis
) return -1;
1850 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
1851 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
1852 dis
->itemID
= (UINT16
)dis32
->itemID
;
1853 dis
->hwndItem
= (HWND16
)dis32
->hwndItem
;
1854 dis
->itemData
= dis32
->itemData
;
1855 *plparam
= (LPARAM
)SEGPTR_GET(dis
);
1860 DRAWITEMSTRUCT
*dis32
= (DRAWITEMSTRUCT
*)*plparam
;
1861 DRAWITEMSTRUCT16
*dis
= SEGPTR_NEW(DRAWITEMSTRUCT16
);
1862 if (!dis
) return -1;
1863 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
1864 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
1865 dis
->itemID
= (UINT16
)dis32
->itemID
;
1866 dis
->itemAction
= (UINT16
)dis32
->itemAction
;
1867 dis
->itemState
= (UINT16
)dis32
->itemState
;
1868 dis
->hwndItem
= (HWND16
)dis32
->hwndItem
;
1869 dis
->hDC
= (HDC16
)dis32
->hDC
;
1870 dis
->itemData
= dis32
->itemData
;
1871 CONV_RECT32TO16( &dis32
->rcItem
, &dis
->rcItem
);
1872 *plparam
= (LPARAM
)SEGPTR_GET(dis
);
1875 case WM_MEASUREITEM
:
1877 MEASUREITEMSTRUCT
*mis32
= (MEASUREITEMSTRUCT
*)*plparam
;
1878 MEASUREITEMSTRUCT16
*mis
= (MEASUREITEMSTRUCT16
*)
1879 SEGPTR_ALLOC(sizeof(*mis
)+sizeof(LPARAM
));
1880 if (!mis
) return -1;
1881 mis
->CtlType
= (UINT16
)mis32
->CtlType
;
1882 mis
->CtlID
= (UINT16
)mis32
->CtlID
;
1883 mis
->itemID
= (UINT16
)mis32
->itemID
;
1884 mis
->itemWidth
= (UINT16
)mis32
->itemWidth
;
1885 mis
->itemHeight
= (UINT16
)mis32
->itemHeight
;
1886 mis
->itemData
= mis32
->itemData
;
1887 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1888 *plparam
= (LPARAM
)SEGPTR_GET(mis
);
1891 case WM_GETMINMAXINFO
:
1893 MINMAXINFO16
*mmi
= (MINMAXINFO16
*)SEGPTR_ALLOC( sizeof(*mmi
) +
1895 if (!mmi
) return -1;
1896 STRUCT32_MINMAXINFO32to16( (MINMAXINFO
*)*plparam
, mmi
);
1897 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1898 *plparam
= (LPARAM
)SEGPTR_GET(mmi
);
1904 *pwparam16
= (WPARAM16
)min( wParam32
, 0xff80 ); /* Must be < 64K */
1905 if (!(str
= SEGPTR_ALLOC(*pwparam16
+ sizeof(LPARAM
)))) return -1;
1906 *((LPARAM
*)str
)++ = *plparam
; /* Store the previous lParam */
1907 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1912 MDICREATESTRUCT16
*cs
;
1913 MDICREATESTRUCTA
*cs32
= (MDICREATESTRUCTA
*)*plparam
;
1916 if (!(cs
= SEGPTR_NEW(MDICREATESTRUCT16
))) return -1;
1917 STRUCT32_MDICREATESTRUCT32Ato16( cs32
, cs
);
1918 name
= SEGPTR_STRDUP( cs32
->szTitle
);
1919 cls
= SEGPTR_STRDUP( cs32
->szClass
);
1920 cs
->szTitle
= SEGPTR_GET(name
);
1921 cs
->szClass
= SEGPTR_GET(cls
);
1922 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
1925 case WM_MDIGETACTIVE
:
1928 *plparam
= MAKELPARAM( (HMENU16
)LOWORD(wParam32
),
1929 (HMENU16
)LOWORD(*plparam
) );
1930 *pwparam16
= (*plparam
== 0);
1933 if(HIWORD(wParam32
) & MF_POPUP
)
1936 if (((UINT
)HIWORD(wParam32
) != 0xFFFF) || (*plparam
))
1938 if((hmenu
= GetSubMenu((HMENU16
)*plparam
, *pwparam16
)))
1944 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
1946 case WM_MDIACTIVATE
:
1948 WND
*tempWnd
= WIN_FindWndPtr(hwnd
);
1949 if( WIDGETS_IsControl(tempWnd
, BIC32_MDICLIENT
) )
1951 *pwparam16
= (HWND
)wParam32
;
1956 *pwparam16
= ((HWND
)*plparam
== hwnd
);
1957 *plparam
= MAKELPARAM( (HWND16
)LOWORD(*plparam
),
1958 (HWND16
)LOWORD(wParam32
) );
1960 WIN_ReleaseWndPtr(tempWnd
);
1965 NCCALCSIZE_PARAMS
*nc32
= (NCCALCSIZE_PARAMS
*)*plparam
;
1966 NCCALCSIZE_PARAMS16
*nc
= (NCCALCSIZE_PARAMS16
*)SEGPTR_ALLOC( sizeof(*nc
) + sizeof(LPARAM
) );
1969 CONV_RECT32TO16( &nc32
->rgrc
[0], &nc
->rgrc
[0] );
1973 CONV_RECT32TO16( &nc32
->rgrc
[1], &nc
->rgrc
[1] );
1974 CONV_RECT32TO16( &nc32
->rgrc
[2], &nc
->rgrc
[2] );
1975 if (!(wp
= SEGPTR_NEW(WINDOWPOS16
)))
1980 STRUCT32_WINDOWPOS32to16( nc32
->lppos
, wp
);
1981 nc
->lppos
= SEGPTR_GET(wp
);
1983 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1984 *plparam
= (LPARAM
)SEGPTR_GET(nc
);
1991 CREATESTRUCTA
*cs32
= (CREATESTRUCTA
*)*plparam
;
1994 if (!(cs
= SEGPTR_NEW(CREATESTRUCT16
))) return -1;
1995 STRUCT32_CREATESTRUCT32Ato16( cs32
, cs
);
1996 name
= SEGPTR_STRDUP( cs32
->lpszName
);
1997 cls
= SEGPTR_STRDUP( cs32
->lpszClass
);
1998 cs
->lpszName
= SEGPTR_GET(name
);
1999 cs
->lpszClass
= SEGPTR_GET(cls
);
2000 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2003 case WM_PARENTNOTIFY
:
2004 if ((LOWORD(wParam32
)==WM_CREATE
) || (LOWORD(wParam32
)==WM_DESTROY
))
2005 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
));
2006 /* else nothing to do */
2009 *plparam
= MapLS( (NMHDR
*)*plparam
); /* NMHDR is already 32-bit */
2013 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
2014 if (!str
) return -1;
2015 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2018 case WM_WINDOWPOSCHANGING
:
2019 case WM_WINDOWPOSCHANGED
:
2021 WINDOWPOS16
*wp
= (WINDOWPOS16
*)SEGPTR_ALLOC( sizeof(*wp
) +
2024 STRUCT32_WINDOWPOS32to16( (WINDOWPOS
*)*plparam
, wp
);
2025 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
2026 *plparam
= (LPARAM
)SEGPTR_GET(wp
);
2031 LPMSG msg32
= (LPMSG
) *plparam
;
2032 LPMSG16 msg16
= (LPMSG16
) SEGPTR_NEW( MSG16
);
2034 if (!msg16
) return -1;
2035 msg16
->hwnd
= msg32
->hwnd
;
2036 msg16
->lParam
= msg32
->lParam
;
2037 msg16
->time
= msg32
->time
;
2038 CONV_POINT32TO16(&msg32
->pt
,&msg16
->pt
);
2039 /* this is right, right? */
2040 if (WINPROC_MapMsg32ATo16(msg32
->hwnd
,msg32
->message
,msg32
->wParam
,
2041 &msg16
->message
,&msg16
->wParam
, &msg16
->lParam
)<0) {
2042 SEGPTR_FREE( msg16
);
2045 *plparam
= (LPARAM
)SEGPTR_GET(msg16
);
2050 case WM_ACTIVATEAPP
:
2052 *plparam
= (LPARAM
)THREAD_IdToTEB((DWORD
) *plparam
)->htask16
;
2055 case WM_ASKCBFORMATNAME
:
2056 case WM_DEVMODECHANGE
:
2057 case WM_PAINTCLIPBOARD
:
2058 case WM_SIZECLIPBOARD
:
2059 case WM_WININICHANGE
:
2060 FIXME_(msg
)("message %04x needs translation\n", msg32
);
2062 case WM_SIZING
: /* should not be send to 16-bit apps */
2064 default: /* No translation needed */
2070 /**********************************************************************
2071 * WINPROC_UnmapMsg32ATo16
2073 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
2075 void WINPROC_UnmapMsg32ATo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2084 case LB_FINDSTRINGEXACT
:
2085 case LB_INSERTSTRING
:
2086 case LB_SELECTSTRING
:
2087 case LB_SETTABSTOPS
:
2090 case CB_FINDSTRINGEXACT
:
2091 case CB_INSERTSTRING
:
2092 case CB_SELECTSTRING
:
2094 case WM_COMPAREITEM
:
2098 SEGPTR_FREE( PTR_SEG_TO_LIN(p16
->lParam
) );
2101 case CB_GETDROPPEDCONTROLRECT
:
2102 case LB_GETITEMRECT
:
2104 RECT16
*rect
= (RECT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2105 p16
->lParam
= *(LPARAM
*)(rect
+ 1);
2106 CONV_RECT16TO32( rect
, (RECT
*)(p16
->lParam
));
2107 SEGPTR_FREE( rect
);
2110 case LB_GETSELITEMS
:
2113 LPINT16 items
= (LPINT16
)PTR_SEG_TO_LIN(lParam
);
2114 p16
->lParam
= *((LPARAM
*)items
- 1);
2115 for (i
= 0; i
< p16
->wParam
; i
++) *((LPINT
)(p16
->lParam
) + i
) = items
[i
];
2116 SEGPTR_FREE( (LPARAM
*)items
- 1 );
2122 *((LPUINT
)(wParam
)) = LOWORD(p16
->lResult
);
2124 *((LPUINT
)(lParam
)) = HIWORD(p16
->lResult
); /* FIXME: substract 1? */
2129 UnMapLS( (SEGPTR
)(p16
->lParam
) );
2132 case WM_MEASUREITEM
:
2134 MEASUREITEMSTRUCT16
*mis
= (MEASUREITEMSTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2135 MEASUREITEMSTRUCT
*mis32
= *(MEASUREITEMSTRUCT
**)(mis
+ 1);
2136 mis32
->itemWidth
= mis
->itemWidth
;
2137 mis32
->itemHeight
= mis
->itemHeight
;
2141 case WM_GETMINMAXINFO
:
2143 MINMAXINFO16
*mmi
= (MINMAXINFO16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2144 p16
->lParam
= *(LPARAM
*)(mmi
+ 1);
2145 STRUCT32_MINMAXINFO16to32( mmi
, (MINMAXINFO
*)(p16
->lParam
) );
2151 LPSTR str
= (LPSTR
)PTR_SEG_TO_LIN(p16
->lParam
);
2152 p16
->lParam
= *((LPARAM
*)str
- 1);
2153 lstrcpynA( (LPSTR
)(p16
->lParam
), str
, p16
->wParam
);
2154 SEGPTR_FREE( (LPARAM
*)str
- 1 );
2159 MDICREATESTRUCT16
*cs
= (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2160 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->szTitle
) );
2161 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->szClass
) );
2165 case WM_MDIGETACTIVE
:
2166 if (lParam
) *(BOOL
*)lParam
= (BOOL16
)HIWORD(p16
->lResult
);
2167 p16
->lResult
= (HWND
)LOWORD(p16
->lResult
);
2171 NCCALCSIZE_PARAMS
*nc32
;
2172 NCCALCSIZE_PARAMS16
*nc
= (NCCALCSIZE_PARAMS16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2173 p16
->lParam
= *(LPARAM
*)(nc
+ 1);
2174 nc32
= (NCCALCSIZE_PARAMS
*)(p16
->lParam
);
2175 CONV_RECT16TO32( &nc
->rgrc
[0], &nc32
->rgrc
[0] );
2178 CONV_RECT16TO32( &nc
->rgrc
[1], &nc32
->rgrc
[1] );
2179 CONV_RECT16TO32( &nc
->rgrc
[2], &nc32
->rgrc
[2] );
2180 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16
*)PTR_SEG_TO_LIN(nc
->lppos
),
2182 SEGPTR_FREE( PTR_SEG_TO_LIN(nc
->lppos
) );
2190 CREATESTRUCT16
*cs
= (CREATESTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2191 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->lpszName
) );
2192 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->lpszClass
) );
2196 case WM_WINDOWPOSCHANGING
:
2197 case WM_WINDOWPOSCHANGED
:
2199 WINDOWPOS16
*wp
= (WINDOWPOS16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2200 p16
->lParam
= *(LPARAM
*)(wp
+ 1);
2201 STRUCT32_WINDOWPOS16to32( wp
, (WINDOWPOS
*)p16
->lParam
);
2206 UnMapLS(p16
->lParam
);
2211 LPMSG16 msg16
= (LPMSG16
)PTR_SEG_TO_LIN(p16
->lParam
);
2213 msgp16
.wParam
=msg16
->wParam
;
2214 msgp16
.lParam
=msg16
->lParam
;
2215 WINPROC_UnmapMsg32ATo16(((LPMSG
)lParam
)->hwnd
, ((LPMSG
)lParam
)->message
,
2216 ((LPMSG
)lParam
)->wParam
, ((LPMSG
)lParam
)->lParam
,
2225 /**********************************************************************
2226 * WINPROC_MapMsg32WTo16
2228 * Map a message from 32-bit Unicode to 16-bit.
2229 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
2231 INT
WINPROC_MapMsg32WTo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
2232 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
2235 *pmsg16
= LOWORD(msg32
);
2236 *pwparam16
= LOWORD(wParam32
);
2241 case LB_FINDSTRINGEXACT
:
2242 case LB_INSERTSTRING
:
2243 case LB_SELECTSTRING
:
2247 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2248 if (!str
) return -1;
2249 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2251 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2256 case CB_FINDSTRINGEXACT
:
2257 case CB_INSERTSTRING
:
2258 case CB_SELECTSTRING
:
2261 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2262 if (!str
) return -1;
2263 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2265 *pmsg16
= (UINT16
)msg32
+ (CB_ADDSTRING16
- CB_ADDSTRING
);
2272 CREATESTRUCTW
*cs32
= (CREATESTRUCTW
*)*plparam
;
2275 if (!(cs
= SEGPTR_NEW(CREATESTRUCT16
))) return -1;
2276 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs32
, cs
);
2277 name
= SEGPTR_STRDUP_WtoA( cs32
->lpszName
);
2278 cls
= SEGPTR_STRDUP_WtoA( cs32
->lpszClass
);
2279 cs
->lpszName
= SEGPTR_GET(name
);
2280 cs
->lpszClass
= SEGPTR_GET(cls
);
2281 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2286 MDICREATESTRUCT16
*cs
;
2287 MDICREATESTRUCTW
*cs32
= (MDICREATESTRUCTW
*)*plparam
;
2290 if (!(cs
= SEGPTR_NEW(MDICREATESTRUCT16
))) return -1;
2291 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs32
, cs
);
2292 name
= SEGPTR_STRDUP_WtoA( cs32
->szTitle
);
2293 cls
= SEGPTR_STRDUP_WtoA( cs32
->szClass
);
2294 cs
->szTitle
= SEGPTR_GET(name
);
2295 cs
->szClass
= SEGPTR_GET(cls
);
2296 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2301 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2302 if (!str
) return -1;
2303 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2308 if ( WINPROC_TestLBForStr( hwnd
))
2310 LPSTR str
= (LPSTR
) SEGPTR_ALLOC( 256 ); /* fixme: fixed sized buffer */
2311 if (!str
) return -1;
2312 *pmsg16
= (msg32
== LB_GETTEXT
)? LB_GETTEXT16
: CB_GETLBTEXT16
;
2313 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2320 case WM_SYSDEADCHAR
:
2322 WCHAR wch
= wParam32
;
2324 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
2329 default: /* No Unicode translation needed (?) */
2330 return WINPROC_MapMsg32ATo16( hwnd
, msg32
, wParam32
, pmsg16
,
2331 pwparam16
, plparam
);
2336 /**********************************************************************
2337 * WINPROC_UnmapMsg32WTo16
2339 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2341 void WINPROC_UnmapMsg32WTo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2348 LPSTR str
= (LPSTR
)PTR_SEG_TO_LIN(p16
->lParam
);
2349 p16
->lParam
= *((LPARAM
*)str
- 1);
2350 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)p16
->lParam
, 0x7fffffff );
2351 SEGPTR_FREE( (LPARAM
*)str
- 1 );
2356 if ( WINPROC_TestLBForStr( hwnd
))
2358 LPSTR str
= (LPSTR
)PTR_SEG_TO_LIN(p16
->lParam
);
2359 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff );
2360 SEGPTR_FREE( (LPARAM
*) str
);
2364 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, p16
);
2370 /**********************************************************************
2371 * WINPROC_CallProc32ATo32W
2373 * Call a window procedure, translating args from Ansi to Unicode.
2375 static LRESULT
WINPROC_CallProc32ATo32W( WNDPROC func
, HWND hwnd
,
2376 UINT msg
, WPARAM wParam
,
2381 if (WINPROC_MapMsg32ATo32W( hwnd
, msg
, &wParam
, &lParam
) == -1) return 0;
2382 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2383 WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
);
2388 /**********************************************************************
2389 * WINPROC_CallProc32WTo32A
2391 * Call a window procedure, translating args from Unicode to Ansi.
2393 static LRESULT
WINPROC_CallProc32WTo32A( WNDPROC func
, HWND hwnd
,
2394 UINT msg
, WPARAM wParam
,
2399 if (WINPROC_MapMsg32WTo32A( hwnd
, msg
, &wParam
, &lParam
) == -1) return 0;
2400 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2401 WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
);
2406 /**********************************************************************
2407 * WINPROC_CallProc16To32A
2409 * Call a 32-bit window procedure, translating the 16-bit args.
2411 static LRESULT
WINPROC_CallProc16To32A( WNDPROC func
, HWND16 hwnd
,
2412 UINT16 msg
, WPARAM16 wParam
,
2419 if (WINPROC_MapMsg16To32A( msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
2421 result
= WINPROC_CallWndProc( func
, hwnd
, msg32
, wParam32
, lParam
);
2422 return WINPROC_UnmapMsg16To32A( hwnd
, msg32
, wParam32
, lParam
, result
);
2425 /**********************************************************************
2426 * WINPROC_Thunk16To32A
2428 static LRESULT WINAPI
WINPROC_Thunk16To32A( WNDPROC func
, LPBYTE args
)
2430 HWND16 hwnd
= *(HWND16
*)( args
+8 );
2431 UINT16 msg
= *(HWND16
*)( args
+6 );
2432 WPARAM16 wParam
= *(HWND16
*)( args
+4 );
2433 LPARAM lParam
= *(LPARAM
*)( args
+0 );
2435 return WINPROC_CallProc16To32A( func
, hwnd
, msg
, wParam
, lParam
);
2439 /**********************************************************************
2440 * WINPROC_CallProc16To32W
2442 * Call a 32-bit window procedure, translating the 16-bit args.
2444 static LRESULT
WINPROC_CallProc16To32W( WNDPROC func
, HWND16 hwnd
,
2445 UINT16 msg
, WPARAM16 wParam
,
2452 if (WINPROC_MapMsg16To32W( hwnd
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
2455 result
= WINPROC_CallWndProc( func
, hwnd
, msg32
, wParam32
, lParam
);
2457 return WINPROC_UnmapMsg16To32W( hwnd
, msg32
, wParam32
, lParam
, result
);
2460 /**********************************************************************
2461 * WINPROC_Thunk16To32W
2463 static LRESULT WINAPI
WINPROC_Thunk16To32W( WNDPROC func
, LPBYTE args
)
2465 HWND16 hwnd
= *(HWND16
*)( args
+8 );
2466 UINT16 msg
= *(HWND16
*)( args
+6 );
2467 WPARAM16 wParam
= *(HWND16
*)( args
+4 );
2468 LPARAM lParam
= *(LPARAM
*)( args
+0 );
2470 return WINPROC_CallProc16To32W( func
, hwnd
, msg
, wParam
, lParam
);
2473 /**********************************************************************
2474 * WINPROC_CallProc32ATo16
2476 * Call a 16-bit window procedure, translating the 32-bit args.
2478 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
2479 UINT msg
, WPARAM wParam
,
2485 mp16
.lParam
= lParam
;
2486 if (WINPROC_MapMsg32ATo16( hwnd
, msg
, wParam
,
2487 &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
2489 mp16
.lResult
= WINPROC_CallWndProc16( func
, hwnd
, msg16
,
2490 mp16
.wParam
, mp16
.lParam
);
2491 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
2492 return mp16
.lResult
;
2496 /**********************************************************************
2497 * WINPROC_CallProc32WTo16
2499 * Call a 16-bit window procedure, translating the 32-bit args.
2501 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
2502 UINT msg
, WPARAM wParam
,
2508 mp16
.lParam
= lParam
;
2509 if (WINPROC_MapMsg32WTo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
,
2510 &mp16
.lParam
) == -1)
2512 mp16
.lResult
= WINPROC_CallWndProc16( func
, hwnd
, msg16
,
2513 mp16
.wParam
, mp16
.lParam
);
2514 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
2515 return mp16
.lResult
;
2519 /**********************************************************************
2520 * CallWindowProc16 (USER.122)
2522 LRESULT WINAPI
CallWindowProc16( WNDPROC16 func
, HWND16 hwnd
, UINT16 msg
,
2523 WPARAM16 wParam
, LPARAM lParam
)
2525 WINDOWPROC
*proc
= WINPROC_GetPtr( func
);
2528 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
2531 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_16
);
2532 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
2538 if (!proc
->thunk
.t_from32
.proc
) return 0;
2539 return WINPROC_CallWndProc16( proc
->thunk
.t_from32
.proc
,
2540 hwnd
, msg
, wParam
, lParam
);
2542 if (!proc
->thunk
.t_from16
.proc
) return 0;
2543 return WINPROC_CallProc16To32A( proc
->thunk
.t_from16
.proc
,
2544 hwnd
, msg
, wParam
, lParam
);
2546 if (!proc
->thunk
.t_from16
.proc
) return 0;
2547 return WINPROC_CallProc16To32W( proc
->thunk
.t_from16
.proc
,
2548 hwnd
, msg
, wParam
, lParam
);
2550 WARN_(relay
)("Invalid proc %p\n", proc
);
2556 /**********************************************************************
2557 * CallWindowProcA (USER32.18)
2559 * The CallWindowProc() function invokes the windows procedure _func_,
2560 * with _hwnd_ as the target window, the message specified by _msg_, and
2561 * the message parameters _wParam_ and _lParam_.
2563 * Some kinds of argument conversion may be done, I'm not sure what.
2565 * CallWindowProc() may be used for windows subclassing. Use
2566 * SetWindowLong() to set a new windows procedure for windows of the
2567 * subclass, and handle subclassed messages in the new windows
2568 * procedure. The new windows procedure may then use CallWindowProc()
2569 * with _func_ set to the parent class's windows procedure to dispatch
2570 * the message to the superclass.
2574 * The return value is message dependent.
2580 LRESULT WINAPI
CallWindowProcA(
2581 WNDPROC func
, /* [in] window procedure */
2582 HWND hwnd
, /* [in] target window */
2583 UINT msg
, /* [in] message */
2584 WPARAM wParam
, /* [in] message dependent parameter */
2585 LPARAM lParam
/* [in] message dependent parameter */
2587 WINDOWPROC
*proc
= WINPROC_GetPtr( (WNDPROC16
)func
);
2589 if (!proc
) return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2592 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_32A
);
2593 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2599 if (!proc
->thunk
.t_from32
.proc
) return 0;
2600 return WINPROC_CallProc32ATo16( proc
->thunk
.t_from32
.proc
,
2601 hwnd
, msg
, wParam
, lParam
);
2603 if (!proc
->thunk
.t_from16
.proc
) return 0;
2604 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
2605 hwnd
, msg
, wParam
, lParam
);
2607 if (!proc
->thunk
.t_from16
.proc
) return 0;
2608 return WINPROC_CallProc32ATo32W( proc
->thunk
.t_from16
.proc
,
2609 hwnd
, msg
, wParam
, lParam
);
2611 WARN_(relay
)("Invalid proc %p\n", proc
);
2617 /**********************************************************************
2618 * CallWindowProcW (USER32.19)
2620 LRESULT WINAPI
CallWindowProcW( WNDPROC func
, HWND hwnd
, UINT msg
,
2621 WPARAM wParam
, LPARAM lParam
)
2623 WINDOWPROC
*proc
= WINPROC_GetPtr( (WNDPROC16
)func
);
2625 if (!proc
) return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2628 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_32W
);
2629 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2635 if (!proc
->thunk
.t_from32
.proc
) return 0;
2636 return WINPROC_CallProc32WTo16( proc
->thunk
.t_from32
.proc
,
2637 hwnd
, msg
, wParam
, lParam
);
2639 if (!proc
->thunk
.t_from16
.proc
) return 0;
2640 return WINPROC_CallProc32WTo32A( proc
->thunk
.t_from16
.proc
,
2641 hwnd
, msg
, wParam
, lParam
);
2643 if (!proc
->thunk
.t_from16
.proc
) return 0;
2644 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
2645 hwnd
, msg
, wParam
, lParam
);
2647 WARN_(relay
)("Invalid proc %p\n", proc
);