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
;
675 MultiByteToWideChar(CP_ACP
, 0, &ch
, 1, &wch
, 1);
680 case WM_ASKCBFORMATNAME
:
681 case WM_DEVMODECHANGE
:
682 case WM_PAINTCLIPBOARD
:
683 case WM_SIZECLIPBOARD
:
684 case EM_SETPASSWORDCHAR
:
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
;
914 WCHAR wch
= *pwparam
;
916 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
921 case WM_ASKCBFORMATNAME
:
922 case WM_DEVMODECHANGE
:
923 case WM_PAINTCLIPBOARD
:
924 case WM_SIZECLIPBOARD
:
925 case EM_SETPASSWORDCHAR
:
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 *plparam
= (LPARAM
)PTR_SEG_TO_LIN(*plparam
);
1422 return WINPROC_MapMsg32ATo32W( hwnd
, *pmsg32
, pwparam32
, plparam
);
1426 CREATESTRUCT16
*cs16
= (CREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1427 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0,
1428 sizeof(*cs
) + sizeof(LPARAM
) );
1430 STRUCT32_CREATESTRUCT16to32A( cs16
, (CREATESTRUCTA
*)cs
);
1431 cs
->lpszName
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->lpszName
);
1432 cs
->lpszClass
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->lpszClass
);
1433 if (HIWORD(cs
->lpszName
))
1434 cs
->lpszName
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1435 (LPCSTR
)cs
->lpszName
);
1436 if (HIWORD(cs
->lpszClass
))
1437 cs
->lpszClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1438 (LPCSTR
)cs
->lpszClass
);
1439 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1440 *plparam
= (LPARAM
)cs
;
1445 MDICREATESTRUCT16
*cs16
=
1446 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(*plparam
);
1447 MDICREATESTRUCTW
*cs
=
1448 (MDICREATESTRUCTW
*)HeapAlloc( GetProcessHeap(), 0,
1449 sizeof(*cs
) + sizeof(LPARAM
) );
1451 STRUCT32_MDICREATESTRUCT16to32A( cs16
, (MDICREATESTRUCTA
*)cs
);
1452 cs
->szTitle
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->szTitle
);
1453 cs
->szClass
= (LPCWSTR
)PTR_SEG_TO_LIN(cs16
->szClass
);
1454 if (HIWORD(cs
->szTitle
))
1455 cs
->szTitle
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1456 (LPCSTR
)cs
->szTitle
);
1457 if (HIWORD(cs
->szClass
))
1458 cs
->szClass
= HEAP_strdupAtoW( GetProcessHeap(), 0,
1459 (LPCSTR
)cs
->szClass
);
1460 *(LPARAM
*)(cs
+ 1) = *plparam
; /* Store the previous lParam */
1461 *plparam
= (LPARAM
)cs
;
1467 LPMSG16 msg16
= (LPMSG16
)PTR_SEG_TO_LIN(*plparam
);
1468 LPMSG msg32
= (LPMSG
)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1470 if (!msg32
) return -1;
1471 msg32
->hwnd
= msg16
->hwnd
;
1472 msg32
->lParam
= msg16
->lParam
;
1473 msg32
->time
= msg16
->time
;
1474 CONV_POINT16TO32(&msg16
->pt
,&msg32
->pt
);
1475 /* this is right, right? */
1476 if (WINPROC_MapMsg16To32W(hwnd
, msg16
->message
,msg16
->wParam
,
1477 &msg32
->message
,&msg32
->wParam
,
1478 &msg32
->lParam
)<0) {
1479 HeapFree( GetProcessHeap(), 0, msg32
);
1482 *plparam
= (LPARAM
)msg32
;
1490 case WM_SYSDEADCHAR
:
1494 MultiByteToWideChar( CP_ACP
, 0, &ch
, 1, &wch
, 1);
1499 default: /* No Unicode translation needed */
1500 return WINPROC_MapMsg16To32A( msg16
, wParam16
, pmsg32
,
1501 pwparam32
, plparam
);
1506 /**********************************************************************
1507 * WINPROC_UnmapMsg16To32W
1509 * Unmap a message that was mapped from 16- to 32-bit Unicode.
1511 LRESULT
WINPROC_UnmapMsg16To32W( HWND16 hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
1518 WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
);
1523 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
1524 lParam
= *(LPARAM
*)(cs
+ 1);
1525 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs
,
1526 (CREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1527 if (HIWORD(cs
->lpszName
))
1528 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszName
);
1529 if (HIWORD(cs
->lpszClass
))
1530 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->lpszClass
);
1531 HeapFree( GetProcessHeap(), 0, cs
);
1536 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lParam
;
1537 lParam
= *(LPARAM
*)(cs
+ 1);
1538 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs
,
1539 (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
) );
1540 if (HIWORD(cs
->szTitle
))
1541 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szTitle
);
1542 if (HIWORD(cs
->szClass
))
1543 HeapFree( GetProcessHeap(), 0, (LPVOID
)cs
->szClass
);
1544 HeapFree( GetProcessHeap(), 0, cs
);
1550 LPMSG msg32
= (LPMSG
)lParam
;
1552 WINPROC_UnmapMsg16To32W( hwnd
, msg32
->message
, msg32
->wParam
, msg32
->lParam
,
1554 HeapFree( GetProcessHeap(), 0, msg32
);
1558 return WINPROC_UnmapMsg16To32A( hwnd
, msg
, wParam
, lParam
, result
);
1564 /**********************************************************************
1565 * WINPROC_MapMsg32ATo16
1567 * Map a message from 32-bit Ansi to 16-bit.
1568 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
1570 INT
WINPROC_MapMsg32ATo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
1571 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
1574 *pmsg16
= (UINT16
)msg32
;
1575 *pwparam16
= (WPARAM16
)LOWORD(wParam32
);
1583 *pmsg16
= (UINT16
)msg32
+ (BM_GETCHECK16
- BM_GETCHECK
);
1592 case EM_SCROLLCARET
:
1595 case EM_GETLINECOUNT
:
1607 case EM_LINEFROMCHAR
:
1608 case EM_SETTABSTOPS
:
1609 case EM_SETPASSWORDCHAR
:
1610 case EM_EMPTYUNDOBUFFER
:
1611 case EM_GETFIRSTVISIBLELINE
:
1612 case EM_SETREADONLY
:
1613 case EM_SETWORDBREAKPROC
:
1614 case EM_GETWORDBREAKPROC
:
1615 case EM_GETPASSWORDCHAR
:
1616 *pmsg16
= (UINT16
)msg32
+ (EM_GETSEL16
- EM_GETSEL
);
1621 case LB_DELETESTRING
:
1622 case LB_GETANCHORINDEX
:
1623 case LB_GETCARETINDEX
:
1626 case LB_GETHORIZONTALEXTENT
:
1627 case LB_GETITEMDATA
:
1628 case LB_GETITEMHEIGHT
:
1630 case LB_GETSELCOUNT
:
1632 case LB_GETTOPINDEX
:
1633 case LB_RESETCONTENT
:
1634 case LB_SELITEMRANGE
:
1635 case LB_SELITEMRANGEEX
:
1636 case LB_SETANCHORINDEX
:
1637 case LB_SETCARETINDEX
:
1638 case LB_SETCOLUMNWIDTH
:
1640 case LB_SETHORIZONTALEXTENT
:
1641 case LB_SETITEMDATA
:
1642 case LB_SETITEMHEIGHT
:
1644 case LB_SETTOPINDEX
:
1645 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1647 case CB_DELETESTRING
:
1649 case CB_GETLBTEXTLEN
:
1651 case CB_RESETCONTENT
:
1655 case CB_SHOWDROPDOWN
:
1656 case CB_SETITEMDATA
:
1657 case CB_SETITEMHEIGHT
:
1658 case CB_GETITEMHEIGHT
:
1659 case CB_SETEXTENDEDUI
:
1660 case CB_GETEXTENDEDUI
:
1661 case CB_GETDROPPEDSTATE
:
1662 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
1665 *pmsg16
= CB_GETEDITSEL16
;
1670 case LB_FINDSTRINGEXACT
:
1671 case LB_INSERTSTRING
:
1672 case LB_SELECTSTRING
:
1676 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1677 if (!str
) return -1;
1678 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1680 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
1685 case CB_FINDSTRINGEXACT
:
1686 case CB_INSERTSTRING
:
1687 case CB_SELECTSTRING
:
1690 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1691 if (!str
) return -1;
1692 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1694 *pmsg16
= (UINT16
)msg32
+ (CB_GETEDITSEL16
- CB_GETEDITSEL
);
1697 case LB_GETITEMRECT
:
1700 rect
= (RECT16
*)SEGPTR_ALLOC( sizeof(RECT16
) + sizeof(LPARAM
) );
1701 if (!rect
) return -1;
1702 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
1703 *plparam
= (LPARAM
)SEGPTR_GET(rect
);
1705 *pmsg16
= LB_GETITEMRECT16
;
1707 case LB_GETSELITEMS
:
1710 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
1711 if (!(items
= SEGPTR_ALLOC( *pwparam16
* sizeof(INT16
)
1712 + sizeof(LPARAM
)))) return -1;
1713 *((LPARAM
*)items
)++ = *plparam
; /* Store the previous lParam */
1714 *plparam
= (LPARAM
)SEGPTR_GET(items
);
1716 *pmsg16
= LB_GETSELITEMS16
;
1718 case LB_SETTABSTOPS
:
1723 *pwparam16
= (WPARAM16
)min( wParam32
, 0x7f80 ); /* Must be < 64K */
1724 if (!(stops
= SEGPTR_ALLOC( *pwparam16
* sizeof(INT16
)
1725 + sizeof(LPARAM
)))) return -1;
1726 for (i
= 0; i
< *pwparam16
; i
++) stops
[i
] = *((LPINT
)*plparam
+i
);
1727 *plparam
= (LPARAM
)SEGPTR_GET(stops
);
1730 *pmsg16
= LB_SETTABSTOPS16
;
1733 case CB_GETDROPPEDCONTROLRECT
:
1736 rect
= (RECT16
*)SEGPTR_ALLOC( sizeof(RECT16
) + sizeof(LPARAM
) );
1737 if (!rect
) return -1;
1738 *(LPARAM
*)(rect
+ 1) = *plparam
; /* Store the previous lParam */
1739 *plparam
= (LPARAM
)SEGPTR_GET(rect
);
1741 *pmsg16
= CB_GETDROPPEDCONTROLRECT16
;
1745 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
1746 *pmsg16
= LB_GETTEXT16
;
1750 *plparam
= (LPARAM
)MapLS( (LPVOID
)(*plparam
) );
1751 *pmsg16
= CB_GETLBTEXT16
;
1756 *plparam
= MAKELONG( (INT16
)(INT
)wParam32
, (INT16
)*plparam
);
1757 *pmsg16
= EM_SETSEL16
;
1764 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
) );
1768 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HWND16
)*plparam
);
1770 case WM_CTLCOLORMSGBOX
:
1771 case WM_CTLCOLOREDIT
:
1772 case WM_CTLCOLORLISTBOX
:
1773 case WM_CTLCOLORBTN
:
1774 case WM_CTLCOLORDLG
:
1775 case WM_CTLCOLORSCROLLBAR
:
1776 case WM_CTLCOLORSTATIC
:
1777 *pmsg16
= WM_CTLCOLOR
;
1778 *plparam
= MAKELPARAM( (HWND16
)*plparam
,
1779 (WORD
)msg32
- WM_CTLCOLORMSGBOX
);
1781 case WM_COMPAREITEM
:
1783 COMPAREITEMSTRUCT
*cis32
= (COMPAREITEMSTRUCT
*)*plparam
;
1784 COMPAREITEMSTRUCT16
*cis
= SEGPTR_NEW(COMPAREITEMSTRUCT16
);
1785 if (!cis
) return -1;
1786 cis
->CtlType
= (UINT16
)cis32
->CtlType
;
1787 cis
->CtlID
= (UINT16
)cis32
->CtlID
;
1788 cis
->hwndItem
= (HWND16
)cis32
->hwndItem
;
1789 cis
->itemID1
= (UINT16
)cis32
->itemID1
;
1790 cis
->itemData1
= cis32
->itemData1
;
1791 cis
->itemID2
= (UINT16
)cis32
->itemID2
;
1792 cis
->itemData2
= cis32
->itemData2
;
1793 *plparam
= (LPARAM
)SEGPTR_GET(cis
);
1798 DELETEITEMSTRUCT
*dis32
= (DELETEITEMSTRUCT
*)*plparam
;
1799 DELETEITEMSTRUCT16
*dis
= SEGPTR_NEW(DELETEITEMSTRUCT16
);
1800 if (!dis
) return -1;
1801 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
1802 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
1803 dis
->itemID
= (UINT16
)dis32
->itemID
;
1804 dis
->hwndItem
= (HWND16
)dis32
->hwndItem
;
1805 dis
->itemData
= dis32
->itemData
;
1806 *plparam
= (LPARAM
)SEGPTR_GET(dis
);
1811 DRAWITEMSTRUCT
*dis32
= (DRAWITEMSTRUCT
*)*plparam
;
1812 DRAWITEMSTRUCT16
*dis
= SEGPTR_NEW(DRAWITEMSTRUCT16
);
1813 if (!dis
) return -1;
1814 dis
->CtlType
= (UINT16
)dis32
->CtlType
;
1815 dis
->CtlID
= (UINT16
)dis32
->CtlID
;
1816 dis
->itemID
= (UINT16
)dis32
->itemID
;
1817 dis
->itemAction
= (UINT16
)dis32
->itemAction
;
1818 dis
->itemState
= (UINT16
)dis32
->itemState
;
1819 dis
->hwndItem
= (HWND16
)dis32
->hwndItem
;
1820 dis
->hDC
= (HDC16
)dis32
->hDC
;
1821 dis
->itemData
= dis32
->itemData
;
1822 CONV_RECT32TO16( &dis32
->rcItem
, &dis
->rcItem
);
1823 *plparam
= (LPARAM
)SEGPTR_GET(dis
);
1826 case WM_MEASUREITEM
:
1828 MEASUREITEMSTRUCT
*mis32
= (MEASUREITEMSTRUCT
*)*plparam
;
1829 MEASUREITEMSTRUCT16
*mis
= (MEASUREITEMSTRUCT16
*)
1830 SEGPTR_ALLOC(sizeof(*mis
)+sizeof(LPARAM
));
1831 if (!mis
) return -1;
1832 mis
->CtlType
= (UINT16
)mis32
->CtlType
;
1833 mis
->CtlID
= (UINT16
)mis32
->CtlID
;
1834 mis
->itemID
= (UINT16
)mis32
->itemID
;
1835 mis
->itemWidth
= (UINT16
)mis32
->itemWidth
;
1836 mis
->itemHeight
= (UINT16
)mis32
->itemHeight
;
1837 mis
->itemData
= mis32
->itemData
;
1838 *(LPARAM
*)(mis
+ 1) = *plparam
; /* Store the previous lParam */
1839 *plparam
= (LPARAM
)SEGPTR_GET(mis
);
1842 case WM_GETMINMAXINFO
:
1844 MINMAXINFO16
*mmi
= (MINMAXINFO16
*)SEGPTR_ALLOC( sizeof(*mmi
) +
1846 if (!mmi
) return -1;
1847 STRUCT32_MINMAXINFO32to16( (MINMAXINFO
*)*plparam
, mmi
);
1848 *(LPARAM
*)(mmi
+ 1) = *plparam
; /* Store the previous lParam */
1849 *plparam
= (LPARAM
)SEGPTR_GET(mmi
);
1855 *pwparam16
= (WPARAM16
)min( wParam32
, 0xff80 ); /* Must be < 64K */
1856 if (!(str
= SEGPTR_ALLOC(*pwparam16
+ sizeof(LPARAM
)))) return -1;
1857 *((LPARAM
*)str
)++ = *plparam
; /* Store the previous lParam */
1858 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1863 MDICREATESTRUCT16
*cs
;
1864 MDICREATESTRUCTA
*cs32
= (MDICREATESTRUCTA
*)*plparam
;
1867 if (!(cs
= SEGPTR_NEW(MDICREATESTRUCT16
))) return -1;
1868 STRUCT32_MDICREATESTRUCT32Ato16( cs32
, cs
);
1869 name
= SEGPTR_STRDUP( cs32
->szTitle
);
1870 cls
= SEGPTR_STRDUP( cs32
->szClass
);
1871 cs
->szTitle
= SEGPTR_GET(name
);
1872 cs
->szClass
= SEGPTR_GET(cls
);
1873 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
1876 case WM_MDIGETACTIVE
:
1879 *plparam
= MAKELPARAM( (HMENU16
)LOWORD(wParam32
),
1880 (HMENU16
)LOWORD(*plparam
) );
1881 *pwparam16
= (*plparam
== 0);
1884 if(HIWORD(wParam32
) & MF_POPUP
)
1887 if (((UINT
)HIWORD(wParam32
) != 0xFFFF) || (*plparam
))
1889 if((hmenu
= GetSubMenu((HMENU16
)*plparam
, *pwparam16
)))
1895 *plparam
= MAKELPARAM( HIWORD(wParam32
), (HMENU16
)*plparam
);
1897 case WM_MDIACTIVATE
:
1899 WND
*tempWnd
= WIN_FindWndPtr(hwnd
);
1900 if( WIDGETS_IsControl(tempWnd
, BIC32_MDICLIENT
) )
1902 *pwparam16
= (HWND
)wParam32
;
1907 *pwparam16
= ((HWND
)*plparam
== hwnd
);
1908 *plparam
= MAKELPARAM( (HWND16
)LOWORD(*plparam
),
1909 (HWND16
)LOWORD(wParam32
) );
1911 WIN_ReleaseWndPtr(tempWnd
);
1916 NCCALCSIZE_PARAMS
*nc32
= (NCCALCSIZE_PARAMS
*)*plparam
;
1917 NCCALCSIZE_PARAMS16
*nc
= (NCCALCSIZE_PARAMS16
*)SEGPTR_ALLOC( sizeof(*nc
) + sizeof(LPARAM
) );
1920 CONV_RECT32TO16( &nc32
->rgrc
[0], &nc
->rgrc
[0] );
1924 CONV_RECT32TO16( &nc32
->rgrc
[1], &nc
->rgrc
[1] );
1925 CONV_RECT32TO16( &nc32
->rgrc
[2], &nc
->rgrc
[2] );
1926 if (!(wp
= SEGPTR_NEW(WINDOWPOS16
)))
1931 STRUCT32_WINDOWPOS32to16( nc32
->lppos
, wp
);
1932 nc
->lppos
= SEGPTR_GET(wp
);
1934 *(LPARAM
*)(nc
+ 1) = *plparam
; /* Store the previous lParam */
1935 *plparam
= (LPARAM
)SEGPTR_GET(nc
);
1942 CREATESTRUCTA
*cs32
= (CREATESTRUCTA
*)*plparam
;
1945 if (!(cs
= SEGPTR_NEW(CREATESTRUCT16
))) return -1;
1946 STRUCT32_CREATESTRUCT32Ato16( cs32
, cs
);
1947 name
= SEGPTR_STRDUP( cs32
->lpszName
);
1948 cls
= SEGPTR_STRDUP( cs32
->lpszClass
);
1949 cs
->lpszName
= SEGPTR_GET(name
);
1950 cs
->lpszClass
= SEGPTR_GET(cls
);
1951 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
1954 case WM_PARENTNOTIFY
:
1955 if ((LOWORD(wParam32
)==WM_CREATE
) || (LOWORD(wParam32
)==WM_DESTROY
))
1956 *plparam
= MAKELPARAM( (HWND16
)*plparam
, HIWORD(wParam32
));
1957 /* else nothing to do */
1960 *plparam
= MapLS( (NMHDR
*)*plparam
); /* NMHDR is already 32-bit */
1964 LPSTR str
= SEGPTR_STRDUP( (LPSTR
)*plparam
);
1965 if (!str
) return -1;
1966 *plparam
= (LPARAM
)SEGPTR_GET(str
);
1969 case WM_WINDOWPOSCHANGING
:
1970 case WM_WINDOWPOSCHANGED
:
1972 WINDOWPOS16
*wp
= (WINDOWPOS16
*)SEGPTR_ALLOC( sizeof(*wp
) +
1975 STRUCT32_WINDOWPOS32to16( (WINDOWPOS
*)*plparam
, wp
);
1976 *(LPARAM
*)(wp
+ 1) = *plparam
; /* Store the previous lParam */
1977 *plparam
= (LPARAM
)SEGPTR_GET(wp
);
1982 LPMSG msg32
= (LPMSG
) *plparam
;
1983 LPMSG16 msg16
= (LPMSG16
) SEGPTR_NEW( MSG16
);
1985 if (!msg16
) return -1;
1986 msg16
->hwnd
= msg32
->hwnd
;
1987 msg16
->lParam
= msg32
->lParam
;
1988 msg16
->time
= msg32
->time
;
1989 CONV_POINT32TO16(&msg32
->pt
,&msg16
->pt
);
1990 /* this is right, right? */
1991 if (WINPROC_MapMsg32ATo16(msg32
->hwnd
,msg32
->message
,msg32
->wParam
,
1992 &msg16
->message
,&msg16
->wParam
, &msg16
->lParam
)<0) {
1993 SEGPTR_FREE( msg16
);
1996 *plparam
= (LPARAM
)SEGPTR_GET(msg16
);
2001 case WM_ACTIVATEAPP
:
2003 *plparam
= (LPARAM
)THREAD_IdToTEB((DWORD
) *plparam
)->htask16
;
2006 case WM_ASKCBFORMATNAME
:
2007 case WM_DEVMODECHANGE
:
2008 case WM_PAINTCLIPBOARD
:
2009 case WM_SIZECLIPBOARD
:
2010 case WM_WININICHANGE
:
2011 FIXME_(msg
)("message %04x needs translation\n", msg32
);
2013 case WM_SIZING
: /* should not be send to 16-bit apps */
2015 default: /* No translation needed */
2021 /**********************************************************************
2022 * WINPROC_UnmapMsg32ATo16
2024 * Unmap a message that was mapped from 32-bit Ansi to 16-bit.
2026 void WINPROC_UnmapMsg32ATo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2035 case LB_FINDSTRINGEXACT
:
2036 case LB_INSERTSTRING
:
2037 case LB_SELECTSTRING
:
2038 case LB_SETTABSTOPS
:
2041 case CB_FINDSTRINGEXACT
:
2042 case CB_INSERTSTRING
:
2043 case CB_SELECTSTRING
:
2045 case WM_COMPAREITEM
:
2049 SEGPTR_FREE( PTR_SEG_TO_LIN(p16
->lParam
) );
2052 case CB_GETDROPPEDCONTROLRECT
:
2053 case LB_GETITEMRECT
:
2055 RECT16
*rect
= (RECT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2056 p16
->lParam
= *(LPARAM
*)(rect
+ 1);
2057 CONV_RECT16TO32( rect
, (RECT
*)(p16
->lParam
));
2058 SEGPTR_FREE( rect
);
2061 case LB_GETSELITEMS
:
2064 LPINT16 items
= (LPINT16
)PTR_SEG_TO_LIN(lParam
);
2065 p16
->lParam
= *((LPARAM
*)items
- 1);
2066 for (i
= 0; i
< p16
->wParam
; i
++) *((LPINT
)(p16
->lParam
) + i
) = items
[i
];
2067 SEGPTR_FREE( (LPARAM
*)items
- 1 );
2073 *((LPUINT
)(wParam
)) = LOWORD(p16
->lResult
);
2075 *((LPUINT
)(lParam
)) = HIWORD(p16
->lResult
); /* FIXME: substract 1? */
2080 UnMapLS( (SEGPTR
)(p16
->lParam
) );
2083 case WM_MEASUREITEM
:
2085 MEASUREITEMSTRUCT16
*mis
= (MEASUREITEMSTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2086 MEASUREITEMSTRUCT
*mis32
= *(MEASUREITEMSTRUCT
**)(mis
+ 1);
2087 mis32
->itemWidth
= mis
->itemWidth
;
2088 mis32
->itemHeight
= mis
->itemHeight
;
2092 case WM_GETMINMAXINFO
:
2094 MINMAXINFO16
*mmi
= (MINMAXINFO16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2095 p16
->lParam
= *(LPARAM
*)(mmi
+ 1);
2096 STRUCT32_MINMAXINFO16to32( mmi
, (MINMAXINFO
*)(p16
->lParam
) );
2102 LPSTR str
= (LPSTR
)PTR_SEG_TO_LIN(p16
->lParam
);
2103 p16
->lParam
= *((LPARAM
*)str
- 1);
2104 lstrcpynA( (LPSTR
)(p16
->lParam
), str
, p16
->wParam
);
2105 SEGPTR_FREE( (LPARAM
*)str
- 1 );
2110 MDICREATESTRUCT16
*cs
= (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2111 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->szTitle
) );
2112 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->szClass
) );
2116 case WM_MDIGETACTIVE
:
2117 if (lParam
) *(BOOL
*)lParam
= (BOOL16
)HIWORD(p16
->lResult
);
2118 p16
->lResult
= (HWND
)LOWORD(p16
->lResult
);
2122 NCCALCSIZE_PARAMS
*nc32
;
2123 NCCALCSIZE_PARAMS16
*nc
= (NCCALCSIZE_PARAMS16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2124 p16
->lParam
= *(LPARAM
*)(nc
+ 1);
2125 nc32
= (NCCALCSIZE_PARAMS
*)(p16
->lParam
);
2126 CONV_RECT16TO32( &nc
->rgrc
[0], &nc32
->rgrc
[0] );
2129 CONV_RECT16TO32( &nc
->rgrc
[1], &nc32
->rgrc
[1] );
2130 CONV_RECT16TO32( &nc
->rgrc
[2], &nc32
->rgrc
[2] );
2131 STRUCT32_WINDOWPOS16to32( (WINDOWPOS16
*)PTR_SEG_TO_LIN(nc
->lppos
),
2133 SEGPTR_FREE( PTR_SEG_TO_LIN(nc
->lppos
) );
2141 CREATESTRUCT16
*cs
= (CREATESTRUCT16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2142 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->lpszName
) );
2143 SEGPTR_FREE( PTR_SEG_TO_LIN(cs
->lpszClass
) );
2147 case WM_WINDOWPOSCHANGING
:
2148 case WM_WINDOWPOSCHANGED
:
2150 WINDOWPOS16
*wp
= (WINDOWPOS16
*)PTR_SEG_TO_LIN(p16
->lParam
);
2151 p16
->lParam
= *(LPARAM
*)(wp
+ 1);
2152 STRUCT32_WINDOWPOS16to32( wp
, (WINDOWPOS
*)p16
->lParam
);
2157 UnMapLS(p16
->lParam
);
2162 LPMSG16 msg16
= (LPMSG16
)PTR_SEG_TO_LIN(p16
->lParam
);
2164 msgp16
.wParam
=msg16
->wParam
;
2165 msgp16
.lParam
=msg16
->lParam
;
2166 WINPROC_UnmapMsg32ATo16(((LPMSG
)lParam
)->hwnd
, ((LPMSG
)lParam
)->message
,
2167 ((LPMSG
)lParam
)->wParam
, ((LPMSG
)lParam
)->lParam
,
2176 /**********************************************************************
2177 * WINPROC_MapMsg32WTo16
2179 * Map a message from 32-bit Unicode to 16-bit.
2180 * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
2182 INT
WINPROC_MapMsg32WTo16( HWND hwnd
, UINT msg32
, WPARAM wParam32
,
2183 UINT16
*pmsg16
, WPARAM16
*pwparam16
,
2186 *pmsg16
= LOWORD(msg32
);
2187 *pwparam16
= LOWORD(wParam32
);
2192 case LB_FINDSTRINGEXACT
:
2193 case LB_INSERTSTRING
:
2194 case LB_SELECTSTRING
:
2198 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2199 if (!str
) return -1;
2200 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2202 *pmsg16
= (UINT16
)msg32
+ (LB_ADDSTRING16
- LB_ADDSTRING
);
2207 case CB_FINDSTRINGEXACT
:
2208 case CB_INSERTSTRING
:
2209 case CB_SELECTSTRING
:
2212 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2213 if (!str
) return -1;
2214 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2216 *pmsg16
= (UINT16
)msg32
+ (CB_ADDSTRING16
- CB_ADDSTRING
);
2223 CREATESTRUCTW
*cs32
= (CREATESTRUCTW
*)*plparam
;
2226 if (!(cs
= SEGPTR_NEW(CREATESTRUCT16
))) return -1;
2227 STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA
*)cs32
, cs
);
2228 name
= SEGPTR_STRDUP_WtoA( cs32
->lpszName
);
2229 cls
= SEGPTR_STRDUP_WtoA( cs32
->lpszClass
);
2230 cs
->lpszName
= SEGPTR_GET(name
);
2231 cs
->lpszClass
= SEGPTR_GET(cls
);
2232 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2237 MDICREATESTRUCT16
*cs
;
2238 MDICREATESTRUCTW
*cs32
= (MDICREATESTRUCTW
*)*plparam
;
2241 if (!(cs
= SEGPTR_NEW(MDICREATESTRUCT16
))) return -1;
2242 STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA
*)cs32
, cs
);
2243 name
= SEGPTR_STRDUP_WtoA( cs32
->szTitle
);
2244 cls
= SEGPTR_STRDUP_WtoA( cs32
->szClass
);
2245 cs
->szTitle
= SEGPTR_GET(name
);
2246 cs
->szClass
= SEGPTR_GET(cls
);
2247 *plparam
= (LPARAM
)SEGPTR_GET(cs
);
2252 LPSTR str
= SEGPTR_STRDUP_WtoA( (LPWSTR
)*plparam
);
2253 if (!str
) return -1;
2254 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2259 if ( WINPROC_TestLBForStr( hwnd
))
2261 LPSTR str
= (LPSTR
) SEGPTR_ALLOC( 256 ); /* fixme: fixed sized buffer */
2262 if (!str
) return -1;
2263 *pmsg16
= (msg32
== LB_GETTEXT
)? LB_GETTEXT16
: CB_GETLBTEXT16
;
2264 *plparam
= (LPARAM
)SEGPTR_GET(str
);
2271 case WM_SYSDEADCHAR
:
2273 WCHAR wch
= wParam32
;
2275 WideCharToMultiByte( CP_ACP
, 0, &wch
, 1, &ch
, 1, NULL
, NULL
);
2280 default: /* No Unicode translation needed (?) */
2281 return WINPROC_MapMsg32ATo16( hwnd
, msg32
, wParam32
, pmsg16
,
2282 pwparam16
, plparam
);
2287 /**********************************************************************
2288 * WINPROC_UnmapMsg32WTo16
2290 * Unmap a message that was mapped from 32-bit Unicode to 16-bit.
2292 void WINPROC_UnmapMsg32WTo16( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
,
2299 LPSTR str
= (LPSTR
)PTR_SEG_TO_LIN(p16
->lParam
);
2300 p16
->lParam
= *((LPARAM
*)str
- 1);
2301 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)p16
->lParam
, 0x7fffffff );
2302 SEGPTR_FREE( (LPARAM
*)str
- 1 );
2307 if ( WINPROC_TestLBForStr( hwnd
))
2309 LPSTR str
= (LPSTR
)PTR_SEG_TO_LIN(p16
->lParam
);
2310 MultiByteToWideChar( CP_ACP
, 0, str
, -1, (LPWSTR
)lParam
, 0x7fffffff );
2311 SEGPTR_FREE( (LPARAM
*) str
);
2315 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, p16
);
2321 /**********************************************************************
2322 * WINPROC_CallProc32ATo32W
2324 * Call a window procedure, translating args from Ansi to Unicode.
2326 static LRESULT
WINPROC_CallProc32ATo32W( WNDPROC func
, HWND hwnd
,
2327 UINT msg
, WPARAM wParam
,
2332 if (WINPROC_MapMsg32ATo32W( hwnd
, msg
, &wParam
, &lParam
) == -1) return 0;
2333 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2334 WINPROC_UnmapMsg32ATo32W( hwnd
, msg
, wParam
, lParam
);
2339 /**********************************************************************
2340 * WINPROC_CallProc32WTo32A
2342 * Call a window procedure, translating args from Unicode to Ansi.
2344 static LRESULT
WINPROC_CallProc32WTo32A( WNDPROC func
, HWND hwnd
,
2345 UINT msg
, WPARAM wParam
,
2350 if (WINPROC_MapMsg32WTo32A( hwnd
, msg
, &wParam
, &lParam
) == -1) return 0;
2351 result
= WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2352 WINPROC_UnmapMsg32WTo32A( hwnd
, msg
, wParam
, lParam
);
2357 /**********************************************************************
2358 * WINPROC_CallProc16To32A
2360 * Call a 32-bit window procedure, translating the 16-bit args.
2362 static LRESULT
WINPROC_CallProc16To32A( WNDPROC func
, HWND16 hwnd
,
2363 UINT16 msg
, WPARAM16 wParam
,
2370 if (WINPROC_MapMsg16To32A( msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
2372 result
= WINPROC_CallWndProc( func
, hwnd
, msg32
, wParam32
, lParam
);
2373 return WINPROC_UnmapMsg16To32A( hwnd
, msg32
, wParam32
, lParam
, result
);
2376 /**********************************************************************
2377 * WINPROC_Thunk16To32A
2379 static LRESULT WINAPI
WINPROC_Thunk16To32A( WNDPROC func
, LPBYTE args
)
2381 HWND16 hwnd
= *(HWND16
*)( args
+8 );
2382 UINT16 msg
= *(HWND16
*)( args
+6 );
2383 WPARAM16 wParam
= *(HWND16
*)( args
+4 );
2384 LPARAM lParam
= *(LPARAM
*)( args
+0 );
2386 return WINPROC_CallProc16To32A( func
, hwnd
, msg
, wParam
, lParam
);
2390 /**********************************************************************
2391 * WINPROC_CallProc16To32W
2393 * Call a 32-bit window procedure, translating the 16-bit args.
2395 static LRESULT
WINPROC_CallProc16To32W( WNDPROC func
, HWND16 hwnd
,
2396 UINT16 msg
, WPARAM16 wParam
,
2403 if (WINPROC_MapMsg16To32W( hwnd
, msg
, wParam
, &msg32
, &wParam32
, &lParam
) == -1)
2406 result
= WINPROC_CallWndProc( func
, hwnd
, msg32
, wParam32
, lParam
);
2408 return WINPROC_UnmapMsg16To32W( hwnd
, msg32
, wParam32
, lParam
, result
);
2411 /**********************************************************************
2412 * WINPROC_Thunk16To32W
2414 static LRESULT WINAPI
WINPROC_Thunk16To32W( WNDPROC func
, LPBYTE args
)
2416 HWND16 hwnd
= *(HWND16
*)( args
+8 );
2417 UINT16 msg
= *(HWND16
*)( args
+6 );
2418 WPARAM16 wParam
= *(HWND16
*)( args
+4 );
2419 LPARAM lParam
= *(LPARAM
*)( args
+0 );
2421 return WINPROC_CallProc16To32W( func
, hwnd
, msg
, wParam
, lParam
);
2424 /**********************************************************************
2425 * WINPROC_CallProc32ATo16
2427 * Call a 16-bit window procedure, translating the 32-bit args.
2429 static LRESULT WINAPI
WINPROC_CallProc32ATo16( WNDPROC16 func
, HWND hwnd
,
2430 UINT msg
, WPARAM wParam
,
2436 mp16
.lParam
= lParam
;
2437 if (WINPROC_MapMsg32ATo16( hwnd
, msg
, wParam
,
2438 &msg16
, &mp16
.wParam
, &mp16
.lParam
) == -1)
2440 mp16
.lResult
= WINPROC_CallWndProc16( func
, hwnd
, msg16
,
2441 mp16
.wParam
, mp16
.lParam
);
2442 WINPROC_UnmapMsg32ATo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
2443 return mp16
.lResult
;
2447 /**********************************************************************
2448 * WINPROC_CallProc32WTo16
2450 * Call a 16-bit window procedure, translating the 32-bit args.
2452 static LRESULT WINAPI
WINPROC_CallProc32WTo16( WNDPROC16 func
, HWND hwnd
,
2453 UINT msg
, WPARAM wParam
,
2459 mp16
.lParam
= lParam
;
2460 if (WINPROC_MapMsg32WTo16( hwnd
, msg
, wParam
, &msg16
, &mp16
.wParam
,
2461 &mp16
.lParam
) == -1)
2463 mp16
.lResult
= WINPROC_CallWndProc16( func
, hwnd
, msg16
,
2464 mp16
.wParam
, mp16
.lParam
);
2465 WINPROC_UnmapMsg32WTo16( hwnd
, msg
, wParam
, lParam
, &mp16
);
2466 return mp16
.lResult
;
2470 /**********************************************************************
2471 * CallWindowProc16 (USER.122)
2473 LRESULT WINAPI
CallWindowProc16( WNDPROC16 func
, HWND16 hwnd
, UINT16 msg
,
2474 WPARAM16 wParam
, LPARAM lParam
)
2476 WINDOWPROC
*proc
= WINPROC_GetPtr( func
);
2479 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
2482 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_16
);
2483 return WINPROC_CallWndProc16( func
, hwnd
, msg
, wParam
, lParam
);
2489 if (!proc
->thunk
.t_from32
.proc
) return 0;
2490 return WINPROC_CallWndProc16( proc
->thunk
.t_from32
.proc
,
2491 hwnd
, msg
, wParam
, lParam
);
2493 if (!proc
->thunk
.t_from16
.proc
) return 0;
2494 return WINPROC_CallProc16To32A( proc
->thunk
.t_from16
.proc
,
2495 hwnd
, msg
, wParam
, lParam
);
2497 if (!proc
->thunk
.t_from16
.proc
) return 0;
2498 return WINPROC_CallProc16To32W( proc
->thunk
.t_from16
.proc
,
2499 hwnd
, msg
, wParam
, lParam
);
2501 WARN_(relay
)("Invalid proc %p\n", proc
);
2507 /**********************************************************************
2508 * CallWindowProcA (USER32.18)
2510 * The CallWindowProc() function invokes the windows procedure _func_,
2511 * with _hwnd_ as the target window, the message specified by _msg_, and
2512 * the message parameters _wParam_ and _lParam_.
2514 * Some kinds of argument conversion may be done, I'm not sure what.
2516 * CallWindowProc() may be used for windows subclassing. Use
2517 * SetWindowLong() to set a new windows procedure for windows of the
2518 * subclass, and handle subclassed messages in the new windows
2519 * procedure. The new windows procedure may then use CallWindowProc()
2520 * with _func_ set to the parent class's windows procedure to dispatch
2521 * the message to the superclass.
2525 * The return value is message dependent.
2531 LRESULT WINAPI
CallWindowProcA(
2532 WNDPROC func
, /* [in] window procedure */
2533 HWND hwnd
, /* [in] target window */
2534 UINT msg
, /* [in] message */
2535 WPARAM wParam
, /* [in] message dependent parameter */
2536 LPARAM lParam
/* [in] message dependent parameter */
2538 WINDOWPROC
*proc
= WINPROC_GetPtr( (WNDPROC16
)func
);
2540 if (!proc
) return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2543 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_32A
);
2544 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2550 if (!proc
->thunk
.t_from32
.proc
) return 0;
2551 return WINPROC_CallProc32ATo16( proc
->thunk
.t_from32
.proc
,
2552 hwnd
, msg
, wParam
, lParam
);
2554 if (!proc
->thunk
.t_from16
.proc
) return 0;
2555 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
2556 hwnd
, msg
, wParam
, lParam
);
2558 if (!proc
->thunk
.t_from16
.proc
) return 0;
2559 return WINPROC_CallProc32ATo32W( proc
->thunk
.t_from16
.proc
,
2560 hwnd
, msg
, wParam
, lParam
);
2562 WARN_(relay
)("Invalid proc %p\n", proc
);
2568 /**********************************************************************
2569 * CallWindowProcW (USER32.19)
2571 LRESULT WINAPI
CallWindowProcW( WNDPROC func
, HWND hwnd
, UINT msg
,
2572 WPARAM wParam
, LPARAM lParam
)
2574 WINDOWPROC
*proc
= WINPROC_GetPtr( (WNDPROC16
)func
);
2576 if (!proc
) return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2579 func
= WINPROC_GetProc( (HWINDOWPROC
)proc
, WIN_PROC_32W
);
2580 return WINPROC_CallWndProc( func
, hwnd
, msg
, wParam
, lParam
);
2586 if (!proc
->thunk
.t_from32
.proc
) return 0;
2587 return WINPROC_CallProc32WTo16( proc
->thunk
.t_from32
.proc
,
2588 hwnd
, msg
, wParam
, lParam
);
2590 if (!proc
->thunk
.t_from16
.proc
) return 0;
2591 return WINPROC_CallProc32WTo32A( proc
->thunk
.t_from16
.proc
,
2592 hwnd
, msg
, wParam
, lParam
);
2594 if (!proc
->thunk
.t_from16
.proc
) return 0;
2595 return WINPROC_CallWndProc( proc
->thunk
.t_from16
.proc
,
2596 hwnd
, msg
, wParam
, lParam
);
2598 WARN_(relay
)("Invalid proc %p\n", proc
);