2 * Window procedure callbacks
4 * Copyright 1995 Martin von Loewis
5 * Copyright 1996 Alexandre Julliard
8 #include "wine/winbase16.h"
12 #include "selectors.h"
22 /* Window procedure 16-to-32-bit thunk,
23 * see BuildSpec16Files() in tools/build.c */
27 BYTE popl_eax
; /* popl %eax (return address) */
28 BYTE pushl_func
; /* pushl $proc */
29 WNDPROC proc WINE_PACKED
;
30 BYTE pushl_eax
; /* pushl %eax */
31 WORD pushw_bp WINE_PACKED
; /* pushw %bp */
32 BYTE pushl_thunk
; /* pushl $thunkfrom16 */
33 void (*thunk32
)() WINE_PACKED
;
34 BYTE lcall
; /* lcall cs:relay */
35 void (*relay
)() WINE_PACKED
; /* WINPROC_CallProc16To32A/W() */
37 } WINPROC_THUNK_FROM16
;
39 /* Window procedure 32-to-16-bit thunk,
40 * see BuildSpec32Files() in tools/build.c */
44 BYTE popl_eax
; /* popl %eax (return address) */
45 BYTE pushl_func
; /* pushl $proc */
46 WNDPROC16 proc WINE_PACKED
;
47 BYTE pushl_eax
; /* pushl %eax */
48 BYTE jmp
; /* jmp relay (relative jump)*/
49 void (*relay
)() WINE_PACKED
; /* WINPROC_CallProc32ATo16() */
50 } WINPROC_THUNK_FROM32
;
52 /* Simple jmp to call 32-bit procedure directly */
55 BYTE jmp
; /* jmp proc (relative jump) */
56 WNDPROC proc WINE_PACKED
;
61 WINPROC_THUNK_FROM16 t_from16
;
62 WINPROC_THUNK_FROM32 t_from32
;
65 typedef struct tagWINDOWPROC
67 WINPROC_THUNK thunk
; /* Thunk */
68 WINPROC_JUMP jmp
; /* Jump */
69 struct tagWINDOWPROC
*next
; /* Next window proc */
70 UINT magic
; /* Magic number */
71 WINDOWPROCTYPE type
; /* Function type */
72 WINDOWPROCUSER user
; /* Function user */
75 #define WINPROC_MAGIC ('W' | ('P' << 8) | ('R' << 16) | ('C' << 24))
77 #define WINPROC_THUNKPROC(pproc) \
78 (((pproc)->type == WIN_PROC_16) ? \
79 (WNDPROC16)((pproc)->thunk.t_from32.proc) : \
80 (WNDPROC16)((pproc)->thunk.t_from16.proc))
82 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
83 UINT msg
, WPARAM wParam
,
85 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
86 UINT msg
, WPARAM wParam
,
88 static LRESULT
WINPROC_CallProc16To32A( HWND16 hwnd
, UINT16 msg
,
89 WPARAM16 wParam
, LPARAM lParam
,
91 static LRESULT
WINPROC_CallProc16To32W( HWND16 hwnd
, UINT16 msg
,
92 WPARAM16 wParam
, LPARAM lParam
,
95 static HANDLE WinProcHeap
;
98 /**********************************************************************
101 BOOL
WINPROC_Init(void)
103 WinProcHeap
= HeapCreate( HEAP_WINE_SEGPTR
| HEAP_WINE_CODESEG
, 0, 0 );
106 WARN(relay
, "Unable to create winproc heap\n" );
113 /**********************************************************************
114 * WINPROC_CallWndProc32
116 * Call a 32-bit WndProc.
118 static LRESULT
WINPROC_CallWndProc( WNDPROC proc
, HWND hwnd
, UINT msg
,
119 WPARAM wParam
, LPARAM lParam
)
121 TRACE(relay
, "(wndproc=%p,hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n",
122 proc
, hwnd
, SPY_GetMsgName(msg
), wParam
, lParam
);
123 return proc( hwnd
, msg
, wParam
, lParam
);
127 /**********************************************************************
130 * Return a pointer to the win proc.
132 static WINDOWPROC
*WINPROC_GetPtr( WNDPROC16 handle
)
137 /* Check for a linear pointer */
139 if (HEAP_IsInsideHeap( WinProcHeap
, 0, (LPVOID
)handle
))
141 ptr
= (BYTE
*)handle
;
142 /* First check if it is the jmp address */
143 if (*ptr
== 0xe9 /* jmp */) ptr
-= (int)&((WINDOWPROC
*)0)->jmp
-
144 (int)&((WINDOWPROC
*)0)->thunk
;
145 /* Now it must be the thunk address */
146 if (*ptr
== 0x58 /* popl eax */) ptr
-= (int)&((WINDOWPROC
*)0)->thunk
;
147 /* Now we have a pointer to the WINDOWPROC struct */
148 if (((WINDOWPROC
*)ptr
)->magic
== WINPROC_MAGIC
)
149 return (WINDOWPROC
*)ptr
;
152 /* Check for a segmented pointer */
154 if (!IsBadReadPtr16((SEGPTR
)handle
,sizeof(WINDOWPROC
)-sizeof(proc
->thunk
)))
156 ptr
= (BYTE
*)PTR_SEG_TO_LIN(handle
);
157 if (!HEAP_IsInsideHeap( WinProcHeap
, 0, ptr
)) return NULL
;
158 /* It must be the thunk address */
159 if (*ptr
== 0x58 /* popl eax */) ptr
-= (int)&((WINDOWPROC
*)0)->thunk
;
160 /* Now we have a pointer to the WINDOWPROC struct */
161 if (((WINDOWPROC
*)ptr
)->magic
== WINPROC_MAGIC
)
162 return (WINDOWPROC
*)ptr
;
169 /**********************************************************************
170 * WINPROC_AllocWinProc
172 * Allocate a new window procedure.
174 static WINDOWPROC
*WINPROC_AllocWinProc( WNDPROC16 func
, WINDOWPROCTYPE type
,
175 WINDOWPROCUSER user
)
177 WINDOWPROC
*proc
, *oldproc
;
179 /* Allocate a window procedure */
181 if (!(proc
= HeapAlloc( WinProcHeap
, 0, sizeof(WINDOWPROC
) ))) return 0;
183 /* Check if the function is already a win proc */
185 if ((oldproc
= WINPROC_GetPtr( func
)))
194 proc
->thunk
.t_from32
.popl_eax
= 0x58; /* popl %eax */
195 proc
->thunk
.t_from32
.pushl_func
= 0x68; /* pushl $proc */
196 proc
->thunk
.t_from32
.proc
= func
;
197 proc
->thunk
.t_from32
.pushl_eax
= 0x50; /* pushl %eax */
198 proc
->thunk
.t_from32
.jmp
= 0xe9; /* jmp relay*/
199 proc
->thunk
.t_from32
.relay
= /* relative jump */
200 (void(*)())((DWORD
)WINPROC_CallProc32ATo16
-
201 (DWORD
)(&proc
->thunk
.t_from32
.relay
+ 1));
205 proc
->thunk
.t_from16
.popl_eax
= 0x58; /* popl %eax */
206 proc
->thunk
.t_from16
.pushl_func
= 0x68; /* pushl $proc */
207 proc
->thunk
.t_from16
.proc
= (FARPROC
)func
;
208 proc
->thunk
.t_from16
.pushl_eax
= 0x50; /* pushl %eax */
209 proc
->thunk
.t_from16
.pushw_bp
= 0x5566; /* pushw %bp */
210 proc
->thunk
.t_from16
.pushl_thunk
= 0x68; /* pushl $thunkfrom16 */
211 proc
->thunk
.t_from16
.thunk32
= (type
== WIN_PROC_32A
) ?
212 (void(*)())WINPROC_CallProc16To32A
:
213 (void(*)())WINPROC_CallProc16To32W
;
214 proc
->thunk
.t_from16
.lcall
= 0x9a; /* lcall cs:relay */
215 proc
->thunk
.t_from16
.relay
= (void*)Callbacks
->CallFrom16WndProc
;
216 GET_CS(proc
->thunk
.t_from16
.cs
);
217 proc
->jmp
.jmp
= 0xe9;
218 /* Fixup relative jump */
219 proc
->jmp
.proc
= (WNDPROC
)((DWORD
)func
-
220 (DWORD
)(&proc
->jmp
.proc
+ 1));
223 /* Should not happen */
226 proc
->magic
= WINPROC_MAGIC
;
231 TRACE(win
, "(%08x,%d): returning %08x\n",
232 (UINT
)func
, type
, (UINT
)proc
);
237 /**********************************************************************
240 * Get a window procedure pointer that can be passed to the Windows program.
242 WNDPROC16
WINPROC_GetProc( HWINDOWPROC proc
, WINDOWPROCTYPE type
)
244 if (!proc
) return NULL
;
245 if (type
== WIN_PROC_16
) /* We want a 16:16 address */
247 if (((WINDOWPROC
*)proc
)->type
== WIN_PROC_16
)
248 return ((WINDOWPROC
*)proc
)->thunk
.t_from32
.proc
;
250 return (WNDPROC16
)HEAP_GetSegptr( WinProcHeap
, 0,
251 &((WINDOWPROC
*)proc
)->thunk
);
253 else /* We want a 32-bit address */
255 if (((WINDOWPROC
*)proc
)->type
== WIN_PROC_16
)
256 return (WNDPROC16
)&((WINDOWPROC
*)proc
)->thunk
;
257 else if (type
!= ((WINDOWPROC
*)proc
)->type
)
258 /* Have to return the jmp address if types don't match */
259 return (WNDPROC16
)&((WINDOWPROC
*)proc
)->jmp
;
261 /* Some Win16 programs want to get back the proc they set */
262 return (WNDPROC16
)((WINDOWPROC
*)proc
)->thunk
.t_from16
.proc
;
267 /**********************************************************************
270 * Set the window procedure for a window or class. There are
271 * three tree classes of winproc callbacks:
273 * 1) class -> wp - not subclassed
274 * class -> wp -> wp -> wp -> wp - SetClassLong()
276 * 2) window -' / - not subclassed
277 * window -> wp -> wp ' - SetWindowLong()
279 * 3) timer -> wp - SetTimer()
281 * Initially, winproc of the window points to the current winproc
282 * thunk of its class. Subclassing prepends a new thunk to the
283 * window winproc chain at the head of the list. Thus, window thunk
284 * list includes class thunks and the latter are preserved when the
285 * window is destroyed.
288 BOOL
WINPROC_SetProc( HWINDOWPROC
*pFirst
, WNDPROC16 func
,
289 WINDOWPROCTYPE type
, WINDOWPROCUSER user
)
291 BOOL bRecycle
= FALSE
;
292 WINDOWPROC
*proc
, **ppPrev
;
294 /* Check if function is already in the list */
296 ppPrev
= (WINDOWPROC
**)pFirst
;
297 proc
= WINPROC_GetPtr( func
);
304 if ((*ppPrev
)->user
!= user
)
306 /* terminal thunk is being restored */
308 WINPROC_FreeProc( *pFirst
, (*ppPrev
)->user
);
309 *(WINDOWPROC
**)pFirst
= *ppPrev
;
318 if (((*ppPrev
)->type
== type
) &&
319 (func
== WINPROC_THUNKPROC(*ppPrev
)))
326 /* WPF_CLASS thunk terminates window thunk list */
327 if ((*ppPrev
)->user
!= user
) break;
328 ppPrev
= &(*ppPrev
)->next
;
333 /* Extract this thunk from the list */
335 *ppPrev
= proc
->next
;
337 else /* Allocate a new one */
339 if (proc
) /* Was already a win proc */
342 func
= WINPROC_THUNKPROC(proc
);
344 proc
= WINPROC_AllocWinProc( func
, type
, user
);
345 if (!proc
) return FALSE
;
348 /* Add the win proc at the head of the list */
350 TRACE(win
, "(%08x,%08x,%d): res=%08x\n",
351 (UINT
)*pFirst
, (UINT
)func
, type
, (UINT
)proc
);
352 proc
->next
= *(WINDOWPROC
**)pFirst
;
353 *(WINDOWPROC
**)pFirst
= proc
;
358 /**********************************************************************
361 * Free a list of win procs.
363 void WINPROC_FreeProc( HWINDOWPROC proc
, WINDOWPROCUSER user
)
367 WINDOWPROC
*next
= ((WINDOWPROC
*)proc
)->next
;
368 if (((WINDOWPROC
*)proc
)->user
!= user
) break;
369 TRACE(win
, "freeing %08x\n", (UINT
)proc
);
370 HeapFree( WinProcHeap
, 0, proc
);
376 /**********************************************************************
377 * WINPROC_GetProcType
379 * Return the window procedure type.
381 WINDOWPROCTYPE
WINPROC_GetProcType( HWINDOWPROC proc
)
384 (((WINDOWPROC
*)proc
)->magic
!= WINPROC_MAGIC
))
385 return WIN_PROC_INVALID
;
386 return ((WINDOWPROC
*)proc
)->type
;
388 /**********************************************************************
389 * WINPROC_TestCBForStr
391 * Return TRUE if the lparam is a string
393 BOOL
WINPROC_TestCBForStr ( HWND hwnd
)
396 WND
* wnd
= WIN_FindWndPtr(hwnd
);
397 retvalue
= ( !(LOWORD(wnd
->dwStyle
) & (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) ||
398 (LOWORD(wnd
->dwStyle
) & CBS_HASSTRINGS
) );
399 WIN_ReleaseWndPtr(wnd
);
402 /**********************************************************************
403 * WINPROC_TestLBForStr
405 * Return TRUE if the lparam is a string
407 BOOL
WINPROC_TestLBForStr ( HWND hwnd
)
410 WND
* wnd
= WIN_FindWndPtr(hwnd
);
411 retvalue
= ( !(LOWORD(wnd
->dwStyle
) & (LBS_OWNERDRAWFIXED
| LBS_OWNERDRAWVARIABLE
)) ||
412 (LOWORD(wnd
->dwStyle
) & LBS_HASSTRINGS
) );
413 WIN_ReleaseWndPtr(wnd
);
417 /**********************************************************************
418 * WINPROC_MapMsg32ATo32W
420 * Map a message from Ansi to Unicode.
421 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
424 * WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR
427 * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
428 * the first four bytes are the handle of the icon
429 * when the WM_SETTEXT message has been used to set the icon
431 INT
WINPROC_MapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM
*plparam
)
437 LPARAM
*ptr
= (LPARAM
*)HeapAlloc( SystemHeap
, 0,
438 wParam
* sizeof(WCHAR
) + sizeof(LPARAM
) );
440 *ptr
++ = *plparam
; /* Store previous lParam */
441 *plparam
= (LPARAM
)ptr
;
444 /* lparam is string (0-terminated) */
446 case WM_WININICHANGE
:
449 case CB_FINDSTRINGEXACT
:
450 case CB_SELECTSTRING
:
454 case LB_SELECTSTRING
:
456 *plparam
= (LPARAM
)HEAP_strdupAtoW( SystemHeap
, 0, (LPCSTR
)*plparam
);
457 return (*plparam
? 1 : -1);
462 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)HeapAlloc( SystemHeap
, 0,
465 *cs
= *(CREATESTRUCTW
*)*plparam
;
466 if (HIWORD(cs
->lpszName
))
467 cs
->lpszName
= HEAP_strdupAtoW( SystemHeap
, 0,
468 (LPCSTR
)cs
->lpszName
);
469 if (HIWORD(cs
->lpszClass
))
470 cs
->lpszClass
= HEAP_strdupAtoW( SystemHeap
, 0,
471 (LPCSTR
)cs
->lpszClass
);
472 *plparam
= (LPARAM
)cs
;
477 MDICREATESTRUCTW
*cs
=
478 (MDICREATESTRUCTW
*)HeapAlloc( SystemHeap
, 0, sizeof(*cs
) );
480 *cs
= *(MDICREATESTRUCTW
*)*plparam
;
481 if (HIWORD(cs
->szClass
))
482 cs
->szClass
= HEAP_strdupAtoW( SystemHeap
, 0,
483 (LPCSTR
)cs
->szClass
);
484 if (HIWORD(cs
->szTitle
))
485 cs
->szTitle
= HEAP_strdupAtoW( SystemHeap
, 0,
486 (LPCSTR
)cs
->szTitle
);
487 *plparam
= (LPARAM
)cs
;
493 case LB_INSERTSTRING
:
494 if ( WINPROC_TestLBForStr( hwnd
))
495 *plparam
= (LPARAM
)HEAP_strdupAtoW( SystemHeap
, 0, (LPCSTR
)*plparam
);
496 return (*plparam
? 1 : -1);
498 case LB_GETTEXT
: /* fixme: fixed sized buffer */
499 { if ( WINPROC_TestLBForStr( hwnd
))
500 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( SystemHeap
, 0, 256 * sizeof(WCHAR
) + sizeof(LPARAM
) );
502 *ptr
++ = *plparam
; /* Store previous lParam */
503 *plparam
= (LPARAM
)ptr
;
510 case CB_INSERTSTRING
:
511 if ( WINPROC_TestCBForStr( hwnd
))
512 *plparam
= (LPARAM
)HEAP_strdupAtoW( SystemHeap
, 0, (LPCSTR
)*plparam
);
513 return (*plparam
? 1 : -1);
515 case CB_GETLBTEXT
: /* fixme: fixed sized buffer */
516 { if ( WINPROC_TestCBForStr( hwnd
))
517 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( SystemHeap
, 0, 256 * sizeof(WCHAR
) + sizeof(LPARAM
) );
519 *ptr
++ = *plparam
; /* Store previous lParam */
520 *plparam
= (LPARAM
)ptr
;
527 { WORD len
= (WORD
)*plparam
;
528 LPARAM
*ptr
= (LPARAM
*) HEAP_xalloc( SystemHeap
, 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(WCHAR
) );
530 *ptr
++ = *plparam
; /* Store previous lParam */
531 (WORD
)*ptr
= len
; /* Store the lenght */
532 *plparam
= (LPARAM
)ptr
;
536 case WM_ASKCBFORMATNAME
:
537 case WM_DEVMODECHANGE
:
538 case WM_PAINTCLIPBOARD
:
539 case WM_SIZECLIPBOARD
:
540 case EM_SETPASSWORDCHAR
:
541 FIXME(msg
, "message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg
), msg
);
543 default: /* No translation needed */
549 /**********************************************************************
550 * WINPROC_UnmapMsg32ATo32W
552 * Unmap a message that was mapped from Ansi to Unicode.
554 void WINPROC_UnmapMsg32ATo32W( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
560 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
561 lstrcpynWtoA( (LPSTR
)*ptr
, (LPWSTR
)lParam
, wParam
);
562 HeapFree( SystemHeap
, 0, ptr
);
569 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
570 if (HIWORD(cs
->lpszName
))
571 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->lpszName
);
572 if (HIWORD(cs
->lpszClass
))
573 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->lpszClass
);
574 HeapFree( SystemHeap
, 0, cs
);
580 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
581 if (HIWORD(cs
->szTitle
))
582 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->szTitle
);
583 if (HIWORD(cs
->szClass
))
584 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->szClass
);
585 HeapFree( SystemHeap
, 0, cs
);
590 case WM_WININICHANGE
:
593 case CB_FINDSTRINGEXACT
:
594 case CB_SELECTSTRING
:
598 case LB_SELECTSTRING
:
600 HeapFree( SystemHeap
, 0, (void *)lParam
);
605 case LB_INSERTSTRING
:
606 if ( WINPROC_TestLBForStr( hwnd
))
607 HeapFree( SystemHeap
, 0, (void *)lParam
);
611 { if ( WINPROC_TestLBForStr( hwnd
))
612 { LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
613 lstrcpyWtoA( (LPSTR
)*ptr
, (LPWSTR
)(lParam
) );
614 HeapFree( SystemHeap
, 0, ptr
);
621 case CB_INSERTSTRING
:
622 if ( WINPROC_TestCBForStr( hwnd
))
623 HeapFree( SystemHeap
, 0, (void *)lParam
);
627 { if ( WINPROC_TestCBForStr( hwnd
))
628 { LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
629 lstrcpyWtoA( (LPSTR
)*ptr
, (LPWSTR
)(lParam
) );
630 HeapFree( SystemHeap
, 0, ptr
);
637 { LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lParam */
638 WORD len
= *(WORD
*) lParam
;
639 lstrcpynWtoA( (LPSTR
)*ptr
, (LPWSTR
)lParam
, len
);
640 HeapFree( SystemHeap
, 0, ptr
);
647 /**********************************************************************
648 * WINPROC_MapMsg32WTo32A
650 * Map a message from Unicode to Ansi.
651 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
653 INT
WINPROC_MapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM
*plparam
)
658 LPARAM
*ptr
= (LPARAM
*)HeapAlloc( SystemHeap
, 0,
659 wParam
+ sizeof(LPARAM
) );
661 *ptr
++ = *plparam
; /* Store previous lParam */
662 *plparam
= (LPARAM
)ptr
;
667 case WM_WININICHANGE
:
670 case CB_FINDSTRINGEXACT
:
671 case CB_SELECTSTRING
:
675 case LB_SELECTSTRING
:
677 *plparam
= (LPARAM
)HEAP_strdupWtoA( SystemHeap
, 0, (LPCWSTR
)*plparam
);
678 return (*plparam
? 1 : -1);
683 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)HeapAlloc( SystemHeap
, 0,
686 *cs
= *(CREATESTRUCTA
*)*plparam
;
687 if (HIWORD(cs
->lpszName
))
688 cs
->lpszName
= HEAP_strdupWtoA( SystemHeap
, 0,
689 (LPCWSTR
)cs
->lpszName
);
690 if (HIWORD(cs
->lpszClass
))
691 cs
->lpszClass
= HEAP_strdupWtoA( SystemHeap
, 0,
692 (LPCWSTR
)cs
->lpszClass
);
693 *plparam
= (LPARAM
)cs
;
698 MDICREATESTRUCTA
*cs
=
699 (MDICREATESTRUCTA
*)HeapAlloc( SystemHeap
, 0, sizeof(*cs
) );
701 *cs
= *(MDICREATESTRUCTA
*)*plparam
;
702 if (HIWORD(cs
->szTitle
))
703 cs
->szTitle
= HEAP_strdupWtoA( SystemHeap
, 0,
704 (LPCWSTR
)cs
->szTitle
);
705 if (HIWORD(cs
->szClass
))
706 cs
->szClass
= HEAP_strdupWtoA( SystemHeap
, 0,
707 (LPCWSTR
)cs
->szClass
);
708 *plparam
= (LPARAM
)cs
;
714 case LB_INSERTSTRING
:
715 if ( WINPROC_TestLBForStr( hwnd
))
716 *plparam
= (LPARAM
)HEAP_strdupWtoA( SystemHeap
, 0, (LPCWSTR
)*plparam
);
717 return (*plparam
? 1 : -1);
719 case LB_GETTEXT
: /* fixme: fixed sized buffer */
720 { if ( WINPROC_TestLBForStr( hwnd
))
721 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( SystemHeap
, 0, 256 + sizeof(LPARAM
) );
723 *ptr
++ = *plparam
; /* Store previous lParam */
724 *plparam
= (LPARAM
)ptr
;
731 case CB_INSERTSTRING
:
732 if ( WINPROC_TestCBForStr( hwnd
))
733 *plparam
= (LPARAM
)HEAP_strdupWtoA( SystemHeap
, 0, (LPCWSTR
)*plparam
);
734 return (*plparam
? 1 : -1);
736 case CB_GETLBTEXT
: /* fixme: fixed sized buffer */
737 { if ( WINPROC_TestCBForStr( hwnd
))
738 { LPARAM
*ptr
= (LPARAM
*)HeapAlloc( SystemHeap
, 0, 256 + sizeof(LPARAM
) );
740 *ptr
++ = *plparam
; /* Store previous lParam */
741 *plparam
= (LPARAM
)ptr
;
748 { WORD len
= (WORD
)*plparam
;
749 LPARAM
*ptr
= (LPARAM
*) HEAP_xalloc( SystemHeap
, 0, sizeof(LPARAM
) + sizeof (WORD
) + len
*sizeof(CHAR
) );
751 *ptr
++ = *plparam
; /* Store previous lParam */
752 (WORD
)*ptr
= len
; /* Store the lenght */
753 *plparam
= (LPARAM
)ptr
;
757 case WM_ASKCBFORMATNAME
:
758 case WM_DEVMODECHANGE
:
759 case WM_PAINTCLIPBOARD
:
760 case WM_SIZECLIPBOARD
:
761 case EM_SETPASSWORDCHAR
:
762 FIXME(msg
, "message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg
),msg
);
764 default: /* No translation needed */
770 /**********************************************************************
771 * WINPROC_UnmapMsg32WTo32A
773 * Unmap a message that was mapped from Unicode to Ansi.
775 void WINPROC_UnmapMsg32WTo32A( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
781 LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
782 lstrcpynAtoW( (LPWSTR
)*ptr
, (LPSTR
)lParam
, wParam
);
783 HeapFree( SystemHeap
, 0, ptr
);
788 case WM_WININICHANGE
:
791 case CB_FINDSTRINGEXACT
:
792 case CB_SELECTSTRING
:
796 case LB_SELECTSTRING
:
798 HeapFree( SystemHeap
, 0, (void *)lParam
);
804 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
805 if (HIWORD(cs
->lpszName
))
806 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->lpszName
);
807 if (HIWORD(cs
->lpszClass
))
808 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->lpszClass
);
809 HeapFree( SystemHeap
, 0, cs
);
815 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
816 if (HIWORD(cs
->szTitle
))
817 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->szTitle
);
818 if (HIWORD(cs
->szClass
))
819 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->szClass
);
820 HeapFree( SystemHeap
, 0, cs
);
826 case LB_INSERTSTRING
:
827 if ( WINPROC_TestLBForStr( hwnd
))
828 HeapFree( SystemHeap
, 0, (void *)lParam
);
832 { if ( WINPROC_TestLBForStr( hwnd
))
833 { LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
834 lstrcpyAtoW( (LPWSTR
)*ptr
, (LPSTR
)(lParam
) );
835 HeapFree( SystemHeap
, 0, ptr
);
842 case CB_INSERTSTRING
:
843 if ( WINPROC_TestCBForStr( hwnd
))
844 HeapFree( SystemHeap
, 0, (void *)lParam
);
848 { if ( WINPROC_TestCBForStr( hwnd
))
849 { LPARAM
*ptr
= (LPARAM
*)lParam
- 1;
850 lstrcpyAtoW( (LPWSTR
)*ptr
, (LPSTR
)(lParam
) );
851 HeapFree( SystemHeap
, 0, ptr
);
858 { LPARAM
* ptr
= (LPARAM
*)lParam
- 1; /* get the old lparam */
859 WORD len
= *(WORD
*)ptr
;
860 lstrcpynAtoW( (LPWSTR
) *ptr
, (LPSTR
)lParam
, len
);
861 HeapFree( SystemHeap
, 0, ptr
);
868 /**********************************************************************
869 * WINPROC_MapMsg16To32A
871 * Map a message from 16- to 32-bit Ansi.
872 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
874 INT
WINPROC_MapMsg16To32A( UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
875 WPARAM
*pwparam32
, LPARAM
*plparam
)
877 *pmsg32
= (UINT
)msg16
;
878 *pwparam32
= (WPARAM
)wParam16
;
885 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
886 *plparam
= (LPARAM
)(HWND
)LOWORD(*plparam
);
890 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
891 *plparam
= (LPARAM
)(HWND
)HIWORD(*plparam
);
894 if ( HIWORD(*plparam
) > CTLCOLOR_STATIC
) return -1;
895 *pmsg32
= WM_CTLCOLORMSGBOX
+ HIWORD(*plparam
);
896 *pwparam32
= (WPARAM
)(HDC
)wParam16
;
897 *plparam
= (LPARAM
)(HWND
)LOWORD(*plparam
);
901 COMPAREITEMSTRUCT16
* cis16
= (COMPAREITEMSTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
902 COMPAREITEMSTRUCT
*cis
= (COMPAREITEMSTRUCT
*)
903 HeapAlloc(SystemHeap
, 0, sizeof(*cis
));
905 cis
->CtlType
= cis16
->CtlType
;
906 cis
->CtlID
= cis16
->CtlID
;
907 cis
->hwndItem
= cis16
->hwndItem
;
908 cis
->itemID1
= cis16
->itemID1
;
909 cis
->itemData1
= cis16
->itemData1
;
910 cis
->itemID2
= cis16
->itemID2
;
911 cis
->itemData2
= cis16
->itemData2
;
912 cis
->dwLocaleId
= 0; /* FIXME */
913 *plparam
= (LPARAM
)cis
;
918 DELETEITEMSTRUCT16
* dis16
= (DELETEITEMSTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
919 DELETEITEMSTRUCT
*dis
= (DELETEITEMSTRUCT
*)
920 HeapAlloc(SystemHeap
, 0, sizeof(*dis
));
922 dis
->CtlType
= dis16
->CtlType
;
923 dis
->CtlID
= dis16
->CtlID
;
924 dis
->hwndItem
= dis16
->hwndItem
;
925 dis
->itemData
= dis16
->itemData
;
926 *plparam
= (LPARAM
)dis
;
931 MEASUREITEMSTRUCT16
* mis16
= (MEASUREITEMSTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
932 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)
933 HeapAlloc(SystemHeap
, 0,
934 sizeof(*mis
) + sizeof(LPARAM
));
936 mis
->CtlType
= mis16
->CtlType
;
937 mis
->CtlID
= mis16
->CtlID
;
938 mis
->itemID
= mis16
->itemID
;
939 mis
->itemWidth
= mis16
->itemWidth
;
940 mis
->itemHeight
= mis16
->itemHeight
;
941 mis
->itemData
= mis16
->itemData
;
942 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
943 *plparam
= (LPARAM
)mis
;
948 DRAWITEMSTRUCT16
* dis16
= (DRAWITEMSTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
949 DRAWITEMSTRUCT
*dis
= (DRAWITEMSTRUCT
*)HeapAlloc(SystemHeap
, 0,
952 dis
->CtlType
= dis16
->CtlType
;
953 dis
->CtlID
= dis16
->CtlID
;
954 dis
->itemID
= dis16
->itemID
;
955 dis
->itemAction
= dis16
->itemAction
;
956 dis
->itemState
= dis16
->itemState
;
957 dis
->hwndItem
= dis16
->hwndItem
;
958 dis
->hDC
= dis16
->hDC
;
959 dis
->itemData
= dis16
->itemData
;
960 CONV_RECT16TO32( &dis16
->rcItem
, &dis
->rcItem
);
961 *plparam
= (LPARAM
)dis
;
964 case WM_GETMINMAXINFO
:
966 MINMAXINFO
*mmi
= (MINMAXINFO
*)HeapAlloc( SystemHeap
, 0,
967 sizeof(*mmi
) + sizeof(LPARAM
));
969 STRUCT32_MINMAXINFO16to32( (MINMAXINFO16
*)PTR_SEG_TO_LIN(*plparam
),
971 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
972 *plparam
= (LPARAM
)mmi
;
977 *plparam
= (LPARAM
)PTR_SEG_TO_LIN(*plparam
);
981 MDICREATESTRUCT16
*cs16
=
982 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
983 MDICREATESTRUCTA
*cs
=
984 (MDICREATESTRUCTA
*)HeapAlloc( SystemHeap
, 0,
985 sizeof(*cs
) + sizeof(LPARAM
) );
987 STRUCT32_MDICREATESTRUCT16to32A( cs16
, cs
);
988 cs
->szTitle
= (LPCSTR
)PTR_SEG_TO_LIN(cs16
->szTitle
);
989 cs
->szClass
= (LPCSTR
)PTR_SEG_TO_LIN(cs16
->szClass
);
990 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
991 *plparam
= (LPARAM
)cs
;
994 case WM_MDIGETACTIVE
:
995 *plparam
= (LPARAM
)HeapAlloc( SystemHeap
, 0, sizeof(BOOL
) );
996 *(BOOL
*)(*plparam
) = 0;
1000 *pmsg32
=WM_MDIREFRESHMENU
;
1001 *pwparam32
= (WPARAM
)(HMENU
)LOWORD(*plparam
);
1002 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1006 *pwparam32
= MAKEWPARAM( wParam16
, LOWORD(*plparam
) );
1007 *plparam
= (LPARAM
)(HMENU
)HIWORD(*plparam
);
1009 case WM_MDIACTIVATE
:
1012 *pwparam32
= (WPARAM
)(HWND
)HIWORD(*plparam
);
1013 *plparam
= (LPARAM
)(HWND
)LOWORD(*plparam
);
1015 else /* message sent to MDI client */
1016 *pwparam32
= wParam16
;
1020 NCCALCSIZE_PARAMS16
*nc16
;
1021 NCCALCSIZE_PARAMS
*nc
;
1023 nc
= (NCCALCSIZE_PARAMS
*)HeapAlloc( SystemHeap
, 0,
1024 sizeof(*nc
) + sizeof(LPARAM
) );
1026 nc16
= (NCCALCSIZE_PARAMS16
*)PTR_SEG_TO_LIN(*plparam
);
1027 CONV_RECT16TO32( &nc16
->rgrc
[0], &nc
->rgrc
[0] );
1030 nc
->lppos
= (WINDOWPOS
*)HeapAlloc( SystemHeap
, 0,
1031 sizeof(*nc
->lppos
) );
1032 CONV_RECT16TO32( &nc16
->rgrc
[1], &nc
->rgrc
[1] );
1033 CONV_RECT16TO32( &nc16
->rgrc
[2], &nc
->rgrc
[2] );
1034 if (nc
->lppos
) STRUCT32_WINDOWPOS16to32( (WINDOWPOS16
*)PTR_SEG_TO_LIN(nc16
->lppos
), nc
->lppos
);
1036 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1037 *plparam
= (LPARAM
)nc
;
1043 CREATESTRUCT16
*cs16
= (CREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1044 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)HeapAlloc( SystemHeap
, 0,
1045 sizeof(*cs
) + sizeof(LPARAM
) );
1047 STRUCT32_CREATESTRUCT16to32A( cs16
, cs
);
1048 cs
->lpszName
= (LPCSTR
)PTR_SEG_TO_LIN(cs16
->lpszName
);
1049 cs
->lpszClass
= (LPCSTR
)PTR_SEG_TO_LIN(cs16
->lpszClass
);
1050 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1051 *plparam
= (LPARAM
)cs
;
1054 case WM_PARENTNOTIFY
:
1055 if ((wParam16
== WM_CREATE
) || (wParam16
== WM_DESTROY
))
1057 *pwparam32
= MAKEWPARAM( wParam16
, HIWORD(*plparam
) );
1058 *plparam
= (LPARAM
)(HWND
)LOWORD(*plparam
);
1061 case WM_WINDOWPOSCHANGING
:
1062 case WM_WINDOWPOSCHANGED
:
1064 WINDOWPOS
*wp
= (WINDOWPOS
*)HeapAlloc( SystemHeap
, 0,
1065 sizeof(*wp
) + sizeof(LPARAM
) );
1067 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16
*)PTR_SEG_TO_LIN(*plparam
),
1069 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1070 *plparam
= (LPARAM
)wp
;
1076 LPMSG16 msg16
= (LPMSG16
)PTR_SEG_TO_LIN(*plparam
);
1077 LPMSG msg32
= (LPMSG
)HeapAlloc( SystemHeap
, 0, sizeof(MSG
) );
1079 if (!msg32
) return -1;
1080 msg32
->hwnd
= msg16
->hwnd
;
1081 msg32
->lParam
= msg16
->lParam
;
1082 msg32
->time
= msg16
->time
;
1083 CONV_POINT16TO32(&msg16
->pt
,&msg32
->pt
);
1084 /* this is right, right? */
1085 if (WINPROC_MapMsg16To32A(msg16
->message
,msg16
->wParam
,
1086 &msg32
->message
,&msg32
->wParam
,
1087 &msg32
->lParam
)<0) {
1088 HeapFree( SystemHeap
, 0, msg32
);
1091 *plparam
= (LPARAM
)msg32
;
1096 *plparam
= (LPARAM
)PTR_SEG_TO_LIN(*plparam
);
1098 case WM_ACTIVATEAPP
:
1100 { /* We need this when SetActiveWindow sends a Sendmessage16() to
1101 a 32bit window. Might be superflous with 32bit interprocess
1104 HTASK16 htask
= (HTASK16
) *plparam
;
1105 DWORD idThread
= (DWORD
)((TDB
*)GlobalLock16(htask
))->thdb
->server_tid
;
1106 *plparam
= (LPARAM
) idThread
;
1109 case WM_ASKCBFORMATNAME
:
1110 case WM_DEVMODECHANGE
:
1111 case WM_PAINTCLIPBOARD
:
1112 case WM_SIZECLIPBOARD
:
1113 case WM_WININICHANGE
:
1114 FIXME( msg
, "message %04x needs translation\n",msg16
);
1117 default: /* No translation needed */
1123 /**********************************************************************
1124 * WINPROC_UnmapMsg16To32A
1126 * Unmap a message that was mapped from 16- to 32-bit Ansi.
1128 LRESULT
WINPROC_UnmapMsg16To32A( HWND16 hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1133 case WM_COMPAREITEM
:
1136 HeapFree( SystemHeap
, 0, (LPVOID
)lParam
);
1138 case WM_MEASUREITEM
:
1140 MEASUREITEMSTRUCT16
*mis16
;
1141 MEASUREITEMSTRUCT
*mis
= (MEASUREITEMSTRUCT
*)lParam
;
1142 lParam
= *(LPARAM
*)(mis
+ 1);
1143 mis16
= (MEASUREITEMSTRUCT16
*)PTR_SEG_TO_LIN(lParam
);
1144 mis16
->itemWidth
= (UINT16
)mis
->itemWidth
;
1145 mis16
->itemHeight
= (UINT16
)mis
->itemHeight
;
1146 HeapFree( SystemHeap
, 0, mis
);
1149 case WM_GETMINMAXINFO
:
1151 MINMAXINFO
*mmi
= (MINMAXINFO
*)lParam
;
1152 lParam
= *(LPARAM
*)(mmi
+ 1);
1153 STRUCT32_MINMAXINFO32to16( mmi
,
1154 (MINMAXINFO16
*)PTR_SEG_TO_LIN(lParam
));
1155 HeapFree( SystemHeap
, 0, mmi
);
1160 MDICREATESTRUCTA
*cs
= (MDICREATESTRUCTA
*)lParam
;
1161 lParam
= *(LPARAM
*)(cs
+ 1);
1162 STRUCT32_MDICREATESTRUCT32Ato16( cs
,
1163 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1164 HeapFree( SystemHeap
, 0, cs
);
1167 case WM_MDIGETACTIVE
:
1168 result
= MAKELONG( LOWORD(result
), (BOOL16
)(*(BOOL
*)lParam
) );
1169 HeapFree( SystemHeap
, 0, (BOOL
*)lParam
);
1173 NCCALCSIZE_PARAMS16
*nc16
;
1174 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lParam
;
1175 lParam
= *(LPARAM
*)(nc
+ 1);
1176 nc16
= (NCCALCSIZE_PARAMS16
*)PTR_SEG_TO_LIN(lParam
);
1177 CONV_RECT32TO16( &nc
->rgrc
[0], &nc16
->rgrc
[0] );
1180 CONV_RECT32TO16( &nc
->rgrc
[1], &nc16
->rgrc
[1] );
1181 CONV_RECT32TO16( &nc
->rgrc
[2], &nc16
->rgrc
[2] );
1184 STRUCT32_WINDOWPOS32to16( nc
->lppos
,
1185 (WINDOWPOS16
*)PTR_SEG_TO_LIN(nc16
->lppos
));
1186 HeapFree( SystemHeap
, 0, nc
->lppos
);
1189 HeapFree( SystemHeap
, 0, nc
);
1195 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lParam
;
1196 lParam
= *(LPARAM
*)(cs
+ 1);
1197 STRUCT32_CREATESTRUCT32Ato16( cs
,
1198 (CREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1199 HeapFree( SystemHeap
, 0, cs
);
1202 case WM_WINDOWPOSCHANGING
:
1203 case WM_WINDOWPOSCHANGED
:
1205 WINDOWPOS
*wp
= (WINDOWPOS
*)lParam
;
1206 lParam
= *(LPARAM
*)(wp
+ 1);
1207 STRUCT32_WINDOWPOS32to16(wp
,(WINDOWPOS16
*)PTR_SEG_TO_LIN(lParam
));
1208 HeapFree( SystemHeap
, 0, wp
);
1214 LPMSG msg32
= (LPMSG
)lParam
;
1216 WINPROC_UnmapMsg16To32A( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1218 HeapFree( SystemHeap
, 0, msg32
);
1226 /**********************************************************************
1227 * WINPROC_MapMsg16To32W
1229 * Map a message from 16- to 32-bit Unicode.
1230 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1232 INT
WINPROC_MapMsg16To32W( HWND16 hwnd
, UINT16 msg16
, WPARAM16 wParam16
, UINT
*pmsg32
,
1233 WPARAM
*pwparam32
, LPARAM
*plparam
)
1239 *plparam
= (LPARAM
)PTR_SEG_TO_LIN(*plparam
);
1240 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, *pwparam32
, plparam
);
1244 CREATESTRUCT16
*cs16
= (CREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1245 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)HeapAlloc( SystemHeap
, 0,
1246 sizeof(*cs
) + sizeof(LPARAM
) );
1248 STRUCT32_CREATESTRUCT16to32A( cs16
, (CREATESTRUCTA
*)cs
);
1249 cs
->lpszName
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->lpszName
);
1250 cs
->lpszClass
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->lpszClass
);
1251 if (HIWORD(cs
->lpszName
))
1252 cs
->lpszName
= HEAP_strdupAtoW( SystemHeap
, 0,
1253 (LPCSTR
)cs
->lpszName
);
1254 if (HIWORD(cs
->lpszClass
))
1255 cs
->lpszClass
= HEAP_strdupAtoW( SystemHeap
, 0,
1256 (LPCSTR
)cs
->lpszClass
);
1257 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1258 *plparam
= (LPARAM
)cs
;
1263 MDICREATESTRUCT16
*cs16
=
1264 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1265 MDICREATESTRUCTW
*cs
=
1266 (MDICREATESTRUCTW
*)HeapAlloc( SystemHeap
, 0,
1267 sizeof(*cs
) + sizeof(LPARAM
) );
1269 STRUCT32_MDICREATESTRUCT16to32A( cs16
, (MDICREATESTRUCTA
*)cs
);
1270 cs
->szTitle
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->szTitle
);
1271 cs
->szClass
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->szClass
);
1272 if (HIWORD(cs
->szTitle
))
1273 cs
->szTitle
= HEAP_strdupAtoW( SystemHeap
, 0,
1274 (LPCSTR
)cs
->szTitle
);
1275 if (HIWORD(cs
->szClass
))
1276 cs
->szClass
= HEAP_strdupAtoW( SystemHeap
, 0,
1277 (LPCSTR
)cs
->szClass
);
1278 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1279 *plparam
= (LPARAM
)cs
;
1285 LPMSG16 msg16
= (LPMSG16
)PTR_SEG_TO_LIN(*plparam
);
1286 LPMSG msg32
= (LPMSG
)HeapAlloc( SystemHeap
, 0, sizeof(MSG
) );
1288 if (!msg32
) return -1;
1289 msg32
->hwnd
= msg16
->hwnd
;
1290 msg32
->lParam
= msg16
->lParam
;
1291 msg32
->time
= msg16
->time
;
1292 CONV_POINT16TO32(&msg16
->pt
,&msg32
->pt
);
1293 /* this is right, right? */
1294 if (WINPROC_MapMsg16To32W(hwnd
, msg16
->message
,msg16
->wParam
,
1295 &msg32
->message
,&msg32
->wParam
,
1296 &msg32
->lParam
)<0) {
1297 HeapFree( SystemHeap
, 0, msg32
);
1300 *plparam
= (LPARAM
)msg32
;
1304 default: /* No Unicode translation needed */
1305 return WINPROC_MapMsg16To32A( msg16
, wParam16
, pmsg32
,
1306 pwparam32
, plparam
);
1311 /**********************************************************************
1312 * WINPROC_UnmapMsg16To32W
1314 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1316 LRESULT
WINPROC_UnmapMsg16To32W( HWND16 hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1323 WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
);
1328 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
1329 lParam
= *(LPARAM
*)(cs
+ 1);
1330 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs
,
1331 (CREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1332 if (HIWORD(cs
->lpszName
))
1333 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->lpszName
);
1334 if (HIWORD(cs
->lpszClass
))
1335 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->lpszClass
);
1336 HeapFree( SystemHeap
, 0, cs
);
1341 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
1342 lParam
= *(LPARAM
*)(cs
+ 1);
1343 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs
,
1344 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1345 if (HIWORD(cs
->szTitle
))
1346 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->szTitle
);
1347 if (HIWORD(cs
->szClass
))
1348 HeapFree( SystemHeap
, 0, (LPVOID
)cs
->szClass
);
1349 HeapFree( SystemHeap
, 0, cs
);
1355 LPMSG msg32
= (LPMSG
)lParam
;
1357 WINPROC_UnmapMsg16To32W( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1359 HeapFree( SystemHeap
, 0, msg32
);
1363 return WINPROC_UnmapMsg16To32A( hwnd
, msg
, wParam
, lParam
, result
);
1369 /**********************************************************************
1370 * WINPROC_MapMsg32ATo16
1372 * Map a message from 32-bit Ansi to 16-bit.
1373 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1375 INT
WINPROC_MapMsg32ATo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
1376 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
1379 *pmsg16
= (UINT16
)msg32
;
1380 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
1388 *pmsg16
= (UINT16
)msg32
+ (BM_GETCHECK16
- BM_GETCHECK
);
1397 case EM_SCROLLCARET
:
1400 case EM_GETLINECOUNT
:
1412 case EM_LINEFROMCHAR
:
1413 case EM_SETTABSTOPS
:
1414 case EM_SETPASSWORDCHAR
:
1415 case EM_EMPTYUNDOBUFFER
:
1416 case EM_GETFIRSTVISIBLELINE
:
1417 case EM_SETREADONLY
:
1418 case EM_SETWORDBREAKPROC
:
1419 case EM_GETWORDBREAKPROC
:
1420 case EM_GETPASSWORDCHAR
:
1421 *pmsg16
= (UINT16
)msg32
+ (EM_GETSEL16
- EM_GETSEL
);
1426 case LB_DELETESTRING
:
1427 case LB_GETANCHORINDEX
:
1428 case LB_GETCARETINDEX
:
1431 case LB_GETHORIZONTALEXTENT
:
1432 case LB_GETITEMDATA
:
1433 case LB_GETITEMHEIGHT
:
1435 case LB_GETSELCOUNT
:
1437 case LB_GETTOPINDEX
:
1438 case LB_RESETCONTENT
:
1439 case LB_SELITEMRANGE
:
1440 case LB_SELITEMRANGEEX
:
1441 case LB_SETANCHORINDEX
:
1442 case LB_SETCARETINDEX
:
1443 case LB_SETCOLUMNWIDTH
:
1445 case LB_SETHORIZONTALEXTENT
:
1446 case LB_SETITEMDATA
:
1447 case LB_SETITEMHEIGHT
:
1449 case LB_SETTOPINDEX
:
1450 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1452 case CB_DELETESTRING
:
1454 case CB_GETLBTEXTLEN
:
1456 case CB_RESETCONTENT
:
1460 case CB_SHOWDROPDOWN
:
1461 case CB_SETITEMDATA
:
1462 case CB_SETITEMHEIGHT
:
1463 case CB_GETITEMHEIGHT
:
1464 case CB_SETEXTENDEDUI
:
1465 case CB_GETEXTENDEDUI
:
1466 case CB_GETDROPPEDSTATE
:
1467 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
1470 *pmsg16
= CB_GETEDITSEL16
;
1475 case LB_FINDSTRINGEXACT
:
1476 case LB_INSERTSTRING
:
1477 case LB_SELECTSTRING
:
1481 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1482 if (!str
) return -1;
1483 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1485 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1490 case CB_FINDSTRINGEXACT
:
1491 case CB_INSERTSTRING
:
1492 case CB_SELECTSTRING
:
1495 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1496 if (!str
) return -1;
1497 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1499 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
1502 case LB_GETITEMRECT
:
1505 rect
= (RECT16
*)SEGPTR_ALLOC( sizeof(RECT16
) + sizeof(LPARAM
) );
1506 if (!rect
) return -1;
1507 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
1508 *plparam
= (LPARAM
)SEGPTR_GET(rect
);
1510 *pmsg16
= LB_GETITEMRECT16
;
1512 case LB_GETSELITEMS
:
1515 *pwparam16
= (WPARAM16
)MIN( wParam32
, 0x7f80 ); /* Must be < 64K */
1516 if (!(items
= SEGPTR_ALLOC( *pwparam16
* sizeof(INT16
)
1517 + sizeof(LPARAM
)))) return -1;
1518 *((LPARAM
*)items
)++ = *plparam
; /* Store the previous lParam */
1519 *plparam
= (LPARAM
)SEGPTR_GET(items
);
1521 *pmsg16
= LB_GETSELITEMS16
;
1523 case LB_SETTABSTOPS
:
1528 *pwparam16
= (WPARAM16
)MIN( wParam32
, 0x7f80 ); /* Must be < 64K */
1529 if (!(stops
= SEGPTR_ALLOC( *pwparam16
* sizeof(INT16
)
1530 + sizeof(LPARAM
)))) return -1;
1531 for (i
= 0; i
< *pwparam16
; i
++) stops
[i
] = *((LPINT
)*plparam
+i
);
1532 *plparam
= (LPARAM
)SEGPTR_GET(stops
);
1535 *pmsg16
= LB_SETTABSTOPS16
;
1538 case CB_GETDROPPEDCONTROLRECT
:
1541 rect
= (RECT16
*)SEGPTR_ALLOC( sizeof(RECT16
) + sizeof(LPARAM
) );
1542 if (!rect
) return -1;
1543 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
1544 *plparam
= (LPARAM
)SEGPTR_GET(rect
);
1546 *pmsg16
= CB_GETDROPPEDCONTROLRECT16
;
1550 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
1551 *pmsg16
= LB_GETTEXT16
;
1555 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
1556 *pmsg16
= CB_GETLBTEXT16
;
1561 *plparam
= MAKELONG( (INT16
)(INT
)wParam32
, (INT16
)*plparam
);
1562 *pmsg16
= EM_SETSEL16
;
1569 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
1573 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HWND16
)*plparam
);
1575 case WM_CTLCOLORMSGBOX
:
1576 case WM_CTLCOLOREDIT
:
1577 case WM_CTLCOLORLISTBOX
:
1578 case WM_CTLCOLORBTN
:
1579 case WM_CTLCOLORDLG
:
1580 case WM_CTLCOLORSCROLLBAR
:
1581 case WM_CTLCOLORSTATIC
:
1582 *pmsg16
= WM_CTLCOLOR
;
1583 *plparam
= MAKELPARAM( (HWND16
)*plparam
,
1584 (WORD
)msg32
- WM_CTLCOLORMSGBOX
);
1586 case WM_COMPAREITEM
:
1588 COMPAREITEMSTRUCT
*cis32
= (COMPAREITEMSTRUCT
*)*plparam
;
1589 COMPAREITEMSTRUCT16
*cis
= SEGPTR_NEW(COMPAREITEMSTRUCT16
);
1590 if (!cis
) return -1;
1591 cis
->CtlType
= (UINT16
)cis32
->CtlType
;
1592 cis
->CtlID
= (UINT16
)cis32
->CtlID
;
1593 cis
->hwndItem
= (HWND16
)cis32
->hwndItem
;
1594 cis
->itemID1
= (UINT16
)cis32
->itemID1
;
1595 cis
->itemData1
= cis32
->itemData1
;
1596 cis
->itemID2
= (UINT16
)cis32
->itemID2
;
1597 cis
->itemData2
= cis32
->itemData2
;
1598 *plparam
= (LPARAM
)SEGPTR_GET(cis
);
1603 DELETEITEMSTRUCT
*dis32
= (DELETEITEMSTRUCT
*)*plparam
;
1604 DELETEITEMSTRUCT16
*dis
= SEGPTR_NEW(DELETEITEMSTRUCT16
);
1605 if (!dis
) return -1;
1606 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
1607 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
1608 dis
->itemID
= (UINT16
)dis32
->itemID
;
1609 dis
->hwndItem
= (HWND16
)dis32
->hwndItem
;
1610 dis
->itemData
= dis32
->itemData
;
1611 *plparam
= (LPARAM
)SEGPTR_GET(dis
);
1616 DRAWITEMSTRUCT
*dis32
= (DRAWITEMSTRUCT
*)*plparam
;
1617 DRAWITEMSTRUCT16
*dis
= SEGPTR_NEW(DRAWITEMSTRUCT16
);
1618 if (!dis
) return -1;
1619 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
1620 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
1621 dis
->itemID
= (UINT16
)dis32
->itemID
;
1622 dis
->itemAction
= (UINT16
)dis32
->itemAction
;
1623 dis
->itemState
= (UINT16
)dis32
->itemState
;
1624 dis
->hwndItem
= (HWND16
)dis32
->hwndItem
;
1625 dis
->hDC
= (HDC16
)dis32
->hDC
;
1626 dis
->itemData
= dis32
->itemData
;
1627 CONV_RECT32TO16( &dis32
->rcItem
, &dis
->rcItem
);
1628 *plparam
= (LPARAM
)SEGPTR_GET(dis
);
1631 case WM_MEASUREITEM
:
1633 MEASUREITEMSTRUCT
*mis32
= (MEASUREITEMSTRUCT
*)*plparam
;
1634 MEASUREITEMSTRUCT16
*mis
= (MEASUREITEMSTRUCT16
*)
1635 SEGPTR_ALLOC(sizeof(*mis
)+sizeof(LPARAM
));
1636 if (!mis
) return -1;
1637 mis
->CtlType
= (UINT16
)mis32
->CtlType
;
1638 mis
->CtlID
= (UINT16
)mis32
->CtlID
;
1639 mis
->itemID
= (UINT16
)mis32
->itemID
;
1640 mis
->itemWidth
= (UINT16
)mis32
->itemWidth
;
1641 mis
->itemHeight
= (UINT16
)mis32
->itemHeight
;
1642 mis
->itemData
= mis32
->itemData
;
1643 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1644 *plparam
= (LPARAM
)SEGPTR_GET(mis
);
1647 case WM_GETMINMAXINFO
:
1649 MINMAXINFO16
*mmi
= (MINMAXINFO16
*)SEGPTR_ALLOC( sizeof(*mmi
) +
1651 if (!mmi
) return -1;
1652 STRUCT32_MINMAXINFO32to16( (MINMAXINFO
*)*plparam
, mmi
);
1653 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1654 *plparam
= (LPARAM
)SEGPTR_GET(mmi
);
1660 *pwparam16
= (WPARAM16
)MIN( wParam32
, 0xff80 ); /* Must be < 64K */
1661 if (!(str
= SEGPTR_ALLOC(*pwparam16
+ sizeof(LPARAM
)))) return -1;
1662 *((LPARAM
*)str
)++ = *plparam
; /* Store the previous lParam */
1663 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1668 MDICREATESTRUCT16
*cs
;
1669 MDICREATESTRUCTA
*cs32
= (MDICREATESTRUCTA
*)*plparam
;
1672 if (!(cs
= SEGPTR_NEW(MDICREATESTRUCT16
))) return -1;
1673 STRUCT32_MDICREATESTRUCT32Ato16( cs32
, cs
);
1674 name
= SEGPTR_STRDUP( cs32
->szTitle
);
1675 cls
= SEGPTR_STRDUP( cs32
->szClass
);
1676 cs
->szTitle
= SEGPTR_GET(name
);
1677 cs
->szClass
= SEGPTR_GET(cls
);
1678 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
1681 case WM_MDIGETACTIVE
:
1684 *plparam
= MAKELPARAM( (HMENU16
)LOWORD(wParam32
),
1685 (HMENU16
)LOWORD(*plparam
) );
1686 *pwparam16
= (*plparam
== 0);
1690 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
1692 case WM_MDIACTIVATE
:
1694 WND
*tempWnd
= WIN_FindWndPtr(hwnd
);
1695 if( WIDGETS_IsControl(tempWnd
, BIC32_MDICLIENT
) )
1697 *pwparam16
= (HWND
)wParam32
;
1702 *pwparam16
= ((HWND
)*plparam
== hwnd
);
1703 *plparam
= MAKELPARAM( (HWND16
)LOWORD(*plparam
),
1704 (HWND16
)LOWORD(wParam32
) );
1706 WIN_ReleaseWndPtr(tempWnd
);
1711 NCCALCSIZE_PARAMS
*nc32
= (NCCALCSIZE_PARAMS
*)*plparam
;
1712 NCCALCSIZE_PARAMS16
*nc
= (NCCALCSIZE_PARAMS16
*)SEGPTR_ALLOC( sizeof(*nc
) + sizeof(LPARAM
) );
1715 CONV_RECT32TO16( &nc32
->rgrc
[0], &nc
->rgrc
[0] );
1719 CONV_RECT32TO16( &nc32
->rgrc
[1], &nc
->rgrc
[1] );
1720 CONV_RECT32TO16( &nc32
->rgrc
[2], &nc
->rgrc
[2] );
1721 if (!(wp
= SEGPTR_NEW(WINDOWPOS16
)))
1726 STRUCT32_WINDOWPOS32to16( nc32
->lppos
, wp
);
1727 nc
->lppos
= SEGPTR_GET(wp
);
1729 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1730 *plparam
= (LPARAM
)SEGPTR_GET(nc
);
1737 CREATESTRUCTA
*cs32
= (CREATESTRUCTA
*)*plparam
;
1740 if (!(cs
= SEGPTR_NEW(CREATESTRUCT16
))) return -1;
1741 STRUCT32_CREATESTRUCT32Ato16( cs32
, cs
);
1742 name
= SEGPTR_STRDUP( cs32
->lpszName
);
1743 cls
= SEGPTR_STRDUP( cs32
->lpszClass
);
1744 cs
->lpszName
= SEGPTR_GET(name
);
1745 cs
->lpszClass
= SEGPTR_GET(cls
);
1746 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
1749 case WM_PARENTNOTIFY
:
1750 if ((LOWORD(wParam32
)==WM_CREATE
) || (LOWORD(wParam32
)==WM_DESTROY
))
1751 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
));
1752 /* else nothing to do */
1755 *plparam
= MapLS( (NMHDR
*)*plparam
); /* NMHDR is already 32-bit */
1759 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1760 if (!str
) return -1;
1761 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1764 case WM_WINDOWPOSCHANGING
:
1765 case WM_WINDOWPOSCHANGED
:
1767 WINDOWPOS16
*wp
= (WINDOWPOS16
*)SEGPTR_ALLOC( sizeof(*wp
) +
1770 STRUCT32_WINDOWPOS32to16( (WINDOWPOS
*)*plparam
, wp
);
1771 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1772 *plparam
= (LPARAM
)SEGPTR_GET(wp
);
1777 LPMSG msg32
= (LPMSG
) *plparam
;
1778 LPMSG16 msg16
= (LPMSG16
) SEGPTR_NEW( MSG16
);
1780 if (!msg16
) return -1;
1781 msg16
->hwnd
= msg32
->hwnd
;
1782 msg16
->lParam
= msg32
->lParam
;
1783 msg16
->time
= msg32
->time
;
1784 CONV_POINT32TO16(&msg32
->pt
,&msg16
->pt
);
1785 /* this is right, right? */
1786 if (WINPROC_MapMsg32ATo16(msg32
->hwnd
,msg32
->message
,msg32
->wParam
,
1787 &msg16
->message
,&msg16
->wParam
, &msg16
->lParam
)<0) {
1788 SEGPTR_FREE( msg16
);
1791 *plparam
= (LPARAM
)SEGPTR_GET(msg16
);
1796 case WM_ACTIVATEAPP
:
1798 *plparam
= (LPARAM
)THREAD_IdToTHDB((DWORD
) *plparam
)->teb
.htask16
;
1801 case WM_ASKCBFORMATNAME
:
1802 case WM_DEVMODECHANGE
:
1803 case WM_PAINTCLIPBOARD
:
1804 case WM_SIZECLIPBOARD
:
1805 case WM_WININICHANGE
:
1806 FIXME( msg
, "message %04x needs translation\n", msg32
);
1808 default: /* No translation needed */
1814 /**********************************************************************
1815 * WINPROC_UnmapMsg32ATo16
1817 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
1819 void WINPROC_UnmapMsg32ATo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1828 case LB_FINDSTRINGEXACT
:
1829 case LB_INSERTSTRING
:
1830 case LB_SELECTSTRING
:
1831 case LB_SETTABSTOPS
:
1834 case CB_FINDSTRINGEXACT
:
1835 case CB_INSERTSTRING
:
1836 case CB_SELECTSTRING
:
1838 case WM_COMPAREITEM
:
1842 SEGPTR_FREE( PTR_SEG_TO_LIN(p16
->lParam
) );
1845 case CB_GETDROPPEDCONTROLRECT
:
1846 case LB_GETITEMRECT
:
1848 RECT16
*rect
= (RECT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
1849 p16
->lParam
= *(LPARAM
*)(rect
+ 1);
1850 CONV_RECT16TO32( rect
, (RECT
*)(p16
->lParam
));
1851 SEGPTR_FREE( rect
);
1854 case LB_GETSELITEMS
:
1857 LPINT16 items
= (LPINT16
)PTR_SEG_TO_LIN(lParam
);
1858 p16
->lParam
= *((LPARAM
*)items
- 1);
1859 for (i
= 0; i
< p16
->wParam
; i
++) *((LPINT
)(p16
->lParam
) + i
) = items
[i
];
1860 SEGPTR_FREE( (LPARAM
*)items
- 1 );
1866 *((LPUINT
)(wParam
)) = LOWORD(p16
->lResult
);
1868 *((LPUINT
)(lParam
)) = HIWORD(p16
->lResult
); /* FIXME: substract 1? */
1873 UnMapLS( (SEGPTR
)(p16
->lParam
) );
1876 case WM_MEASUREITEM
:
1878 MEASUREITEMSTRUCT16
*mis
= (MEASUREITEMSTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
1879 MEASUREITEMSTRUCT
*mis32
= *(MEASUREITEMSTRUCT
**)(mis
+ 1);
1880 mis32
->itemWidth
= mis
->itemWidth
;
1881 mis32
->itemHeight
= mis
->itemHeight
;
1885 case WM_GETMINMAXINFO
:
1887 MINMAXINFO16
*mmi
= (MINMAXINFO16
*)PTR_SEG_TO_LIN(p16
->lParam
);
1888 p16
->lParam
= *(LPARAM
*)(mmi
+ 1);
1889 STRUCT32_MINMAXINFO16to32( mmi
, (MINMAXINFO
*)(p16
->lParam
) );
1895 LPSTR str
= (LPSTR
)PTR_SEG_TO_LIN(p16
->lParam
);
1896 p16
->lParam
= *((LPARAM
*)str
- 1);
1897 lstrcpynA( (LPSTR
)(p16
->lParam
), str
, p16
->wParam
);
1898 SEGPTR_FREE( (LPARAM
*)str
- 1 );
1903 MDICREATESTRUCT16
*cs
= (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
1904 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->szTitle
) );
1905 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->szClass
) );
1909 case WM_MDIGETACTIVE
:
1910 if (lParam
) *(BOOL
*)lParam
= (BOOL16
)HIWORD(p16
->lResult
);
1911 p16
->lResult
= (HWND
)LOWORD(p16
->lResult
);
1915 NCCALCSIZE_PARAMS
*nc32
;
1916 NCCALCSIZE_PARAMS16
*nc
= (NCCALCSIZE_PARAMS16
*)PTR_SEG_TO_LIN(p16
->lParam
);
1917 p16
->lParam
= *(LPARAM
*)(nc
+ 1);
1918 nc32
= (NCCALCSIZE_PARAMS
*)(p16
->lParam
);
1919 CONV_RECT16TO32( &nc
->rgrc
[0], &nc32
->rgrc
[0] );
1922 CONV_RECT16TO32( &nc
->rgrc
[1], &nc32
->rgrc
[1] );
1923 CONV_RECT16TO32( &nc
->rgrc
[2], &nc32
->rgrc
[2] );
1924 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16
*)PTR_SEG_TO_LIN(nc
->lppos
),
1926 SEGPTR_FREE( PTR_SEG_TO_LIN(nc
->lppos
) );
1934 CREATESTRUCT16
*cs
= (CREATESTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
1935 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->lpszName
) );
1936 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->lpszClass
) );
1940 case WM_WINDOWPOSCHANGING
:
1941 case WM_WINDOWPOSCHANGED
:
1943 WINDOWPOS16
*wp
= (WINDOWPOS16
*)PTR_SEG_TO_LIN(p16
->lParam
);
1944 p16
->lParam
= *(LPARAM
*)(wp
+ 1);
1945 STRUCT32_WINDOWPOS16to32( wp
, (WINDOWPOS
*)p16
->lParam
);
1950 UnMapLS(p16
->lParam
);
1955 LPMSG16 msg16
= (LPMSG16
)PTR_SEG_TO_LIN(p16
->lParam
);
1957 msgp16
.wParam
=msg16
->wParam
;
1958 msgp16
.lParam
=msg16
->lParam
;
1959 WINPROC_UnmapMsg32ATo16(((LPMSG
)lParam
)->hwnd
, ((LPMSG
)lParam
)->message
,
1960 ((LPMSG
)lParam
)->wParam
, ((LPMSG
)lParam
)->lParam
,
1969 /**********************************************************************
1970 * WINPROC_MapMsg32WTo16
1972 * Map a message from 32-bit Unicode to 16-bit.
1973 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1975 INT
WINPROC_MapMsg32WTo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
1976 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
1983 case LB_FINDSTRINGEXACT
:
1984 case LB_INSERTSTRING
:
1985 case LB_SELECTSTRING
:
1989 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
1990 if (!str
) return -1;
1991 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
1992 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1994 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1999 case CB_FINDSTRINGEXACT
:
2000 case CB_INSERTSTRING
:
2001 case CB_SELECTSTRING
:
2004 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2005 if (!str
) return -1;
2006 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
2007 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2009 *pmsg16
= (UINT16
)msg32
+ (CB_ADDSTRING16
- CB_ADDSTRING
);
2016 CREATESTRUCTW
*cs32
= (CREATESTRUCTW
*)*plparam
;
2019 if (!(cs
= SEGPTR_NEW(CREATESTRUCT16
))) return -1;
2020 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs32
, cs
);
2021 name
= SEGPTR_STRDUP_WtoA( cs32
->lpszName
);
2022 cls
= SEGPTR_STRDUP_WtoA( cs32
->lpszClass
);
2023 cs
->lpszName
= SEGPTR_GET(name
);
2024 cs
->lpszClass
= SEGPTR_GET(cls
);
2025 *pmsg16
= (UINT16
)msg32
;
2026 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
2027 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2032 MDICREATESTRUCT16
*cs
;
2033 MDICREATESTRUCTW
*cs32
= (MDICREATESTRUCTW
*)*plparam
;
2036 if (!(cs
= SEGPTR_NEW(MDICREATESTRUCT16
))) return -1;
2037 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs32
, cs
);
2038 name
= SEGPTR_STRDUP_WtoA( cs32
->szTitle
);
2039 cls
= SEGPTR_STRDUP_WtoA( cs32
->szClass
);
2040 cs
->szTitle
= SEGPTR_GET(name
);
2041 cs
->szClass
= SEGPTR_GET(cls
);
2042 *pmsg16
= (UINT16
)msg32
;
2043 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
2044 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2049 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2050 if (!str
) return -1;
2051 *pmsg16
= (UINT16
)msg32
;
2052 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
2053 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2056 default: /* No Unicode translation needed */
2057 return WINPROC_MapMsg32ATo16( hwnd
, msg32
, wParam32
, pmsg16
,
2058 pwparam16
, plparam
);
2063 /**********************************************************************
2064 * WINPROC_UnmapMsg32WTo16
2066 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2068 void WINPROC_UnmapMsg32WTo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2075 LPSTR str
= (LPSTR
)PTR_SEG_TO_LIN(p16
->lParam
);
2076 p16
->lParam
= *((LPARAM
*)str
- 1);
2077 lstrcpyAtoW( (LPWSTR
)(p16
->lParam
), str
);
2078 SEGPTR_FREE( (LPARAM
*)str
- 1 );
2082 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, p16
);
2088 /**********************************************************************
2089 * WINPROC_CallProc32ATo32W
2091 * Call a window procedure, translating args from Ansi to Unicode.
2093 static LRESULT
WINPROC_CallProc32ATo32W( WNDPROC func
, HWND hwnd
,
2094 UINT msg
, WPARAM wParam
,
2099 if (WINPROC_MapMsg32ATo32W( hwnd
, msg
, wParam
, &lParam
) == -1) return 0;
2100 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2101 WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
);
2106 /**********************************************************************
2107 * WINPROC_CallProc32WTo32A
2109 * Call a window procedure, translating args from Unicode to Ansi.
2111 static LRESULT
WINPROC_CallProc32WTo32A( WNDPROC func
, HWND hwnd
,
2112 UINT msg
, WPARAM wParam
,
2117 if (WINPROC_MapMsg32WTo32A( hwnd
, msg
, wParam
, &lParam
) == -1) return 0;
2118 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2119 WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
);
2124 /**********************************************************************
2125 * WINPROC_CallProc16To32A
2127 * Call a 32-bit window procedure, translating the 16-bit args.
2129 LRESULT
WINPROC_CallProc16To32A( HWND16 hwnd
, UINT16 msg
,
2130 WPARAM16 wParam
, LPARAM lParam
,
2137 if (WINPROC_MapMsg16To32A( msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
2139 result
= WINPROC_CallWndProc( func
, hwnd
, msg32
, wParam32
, lParam
);
2140 return WINPROC_UnmapMsg16To32A( hwnd
, msg32
, wParam32
, lParam
, result
);
2144 /**********************************************************************
2145 * WINPROC_CallProc16To32W
2147 * Call a 32-bit window procedure, translating the 16-bit args.
2149 LRESULT
WINPROC_CallProc16To32W( HWND16 hwnd
, UINT16 msg
,
2150 WPARAM16 wParam
, LPARAM lParam
,
2157 if (WINPROC_MapMsg16To32W( hwnd
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
2159 result
= WINPROC_CallWndProc( func
, hwnd
, msg32
, wParam32
, lParam
);
2160 return WINPROC_UnmapMsg16To32W( hwnd
, msg32
, wParam32
, lParam
, result
);
2164 /**********************************************************************
2165 * WINPROC_CallProc32ATo16
2167 * Call a 16-bit window procedure, translating the 32-bit args.
2169 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
2170 UINT msg
, WPARAM wParam
,
2176 mp16
.lParam
= lParam
;
2177 if (WINPROC_MapMsg32ATo16( hwnd
, msg
, wParam
,
2178 &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
2180 mp16
.lResult
= Callbacks
->CallWndProc( func
, hwnd
, msg16
,
2181 mp16
.wParam
, mp16
.lParam
);
2182 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
2183 return mp16
.lResult
;
2187 /**********************************************************************
2188 * WINPROC_CallProc32WTo16
2190 * Call a 16-bit window procedure, translating the 32-bit args.
2192 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
2193 UINT msg
, WPARAM wParam
,
2199 mp16
.lParam
= lParam
;
2200 if (WINPROC_MapMsg32WTo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
,
2201 &mp16
.lParam
) == -1)
2203 mp16
.lResult
= Callbacks
->CallWndProc( func
, hwnd
, msg16
,
2204 mp16
.wParam
, mp16
.lParam
);
2205 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
2206 return mp16
.lResult
;
2210 /**********************************************************************
2211 * CallWindowProc16 (USER.122)
2213 LRESULT WINAPI
CallWindowProc16( WNDPROC16 func
, HWND16 hwnd
, UINT16 msg
,
2214 WPARAM16 wParam
, LPARAM lParam
)
2216 WINDOWPROC
*proc
= WINPROC_GetPtr( func
);
2219 return Callbacks
->CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2222 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_16
);
2223 return Callbacks
->CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2229 if (!proc
->thunk
.t_from32
.proc
) return 0;
2230 return Callbacks
->CallWndProc( proc
->thunk
.t_from32
.proc
,
2231 hwnd
, msg
, wParam
, lParam
);
2233 if (!proc
->thunk
.t_from16
.proc
) return 0;
2234 return WINPROC_CallProc16To32A( hwnd
, msg
, wParam
, lParam
,
2235 proc
->thunk
.t_from16
.proc
);
2237 if (!proc
->thunk
.t_from16
.proc
) return 0;
2238 return WINPROC_CallProc16To32W( hwnd
, msg
, wParam
, lParam
,
2239 proc
->thunk
.t_from16
.proc
);
2241 WARN( relay
, "Invalid proc %p\n", proc
);
2247 /**********************************************************************
2248 * CallWindowProc32A (USER32.18)
2250 * The CallWindowProc() function invokes the windows procedure _func_,
2251 * with _hwnd_ as the target window, the message specified by _msg_, and
2252 * the message parameters _wParam_ and _lParam_.
2254 * Some kinds of argument conversion may be done, I'm not sure what.
2256 * CallWindowProc() may be used for windows subclassing. Use
2257 * SetWindowLong() to set a new windows procedure for windows of the
2258 * subclass, and handle subclassed messages in the new windows
2259 * procedure. The new windows procedure may then use CallWindowProc()
2260 * with _func_ set to the parent class's windows procedure to dispatch
2261 * the message to the superclass.
2265 * The return value is message dependent.
2271 LRESULT WINAPI
CallWindowProcA(
2272 WNDPROC func
, /* window procedure */
2273 HWND hwnd
, /* target window */
2274 UINT msg
, /* message */
2275 WPARAM wParam
, /* message dependent parameter */
2276 LPARAM lParam
/* message dependent parameter */
2278 WINDOWPROC
*proc
= WINPROC_GetPtr( (WNDPROC16
)func
);
2280 if (!proc
) return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2283 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_32A
);
2284 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2290 if (!proc
->thunk
.t_from32
.proc
) return 0;
2291 return WINPROC_CallProc32ATo16( proc
->thunk
.t_from32
.proc
,
2292 hwnd
, msg
, wParam
, lParam
);
2294 if (!proc
->thunk
.t_from16
.proc
) return 0;
2295 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
2296 hwnd
, msg
, wParam
, lParam
);
2298 if (!proc
->thunk
.t_from16
.proc
) return 0;
2299 return WINPROC_CallProc32ATo32W( proc
->thunk
.t_from16
.proc
,
2300 hwnd
, msg
, wParam
, lParam
);
2302 WARN( relay
, "Invalid proc %p\n", proc
);
2308 /**********************************************************************
2309 * CallWindowProc32W (USER32.19)
2311 LRESULT WINAPI
CallWindowProcW( WNDPROC func
, HWND hwnd
, UINT msg
,
2312 WPARAM wParam
, LPARAM lParam
)
2314 WINDOWPROC
*proc
= WINPROC_GetPtr( (WNDPROC16
)func
);
2316 if (!proc
) return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2319 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_32W
);
2320 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2326 if (!proc
->thunk
.t_from32
.proc
) return 0;
2327 return WINPROC_CallProc32WTo16( proc
->thunk
.t_from32
.proc
,
2328 hwnd
, msg
, wParam
, lParam
);
2330 if (!proc
->thunk
.t_from16
.proc
) return 0;
2331 return WINPROC_CallProc32WTo32A( proc
->thunk
.t_from16
.proc
,
2332 hwnd
, msg
, wParam
, lParam
);
2334 if (!proc
->thunk
.t_from16
.proc
) return 0;
2335 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
2336 hwnd
, msg
, wParam
, lParam
);
2338 WARN( relay
, "Invalid proc %p\n", proc
);