Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Window procedure callbacks |
| 3 | * |
| 4 | * Copyright 1995 Martin von Loewis |
| 5 | * Copyright 1996 Alexandre Julliard |
| 6 | */ |
| 7 | |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 8 | #include <string.h> |
Marcus Meissner | 61afa33 | 1999-02-22 10:16:00 +0000 | [diff] [blame] | 9 | #include "wine/winbase16.h" |
| 10 | #include "winuser.h" |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 11 | #include "stackframe.h" |
| 12 | #include "builtin16.h" |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 13 | #include "heap.h" |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 14 | #include "selectors.h" |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 15 | #include "struct32.h" |
| 16 | #include "win.h" |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 17 | #include "winproc.h" |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 18 | #include "debugtools.h" |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 19 | #include "spy.h" |
Juergen Schmied | 4a84dc2 | 1998-10-23 12:04:25 +0000 | [diff] [blame] | 20 | #include "commctrl.h" |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 21 | #include "task.h" |
| 22 | #include "thread.h" |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 23 | |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 24 | DECLARE_DEBUG_CHANNEL(msg) |
| 25 | DECLARE_DEBUG_CHANNEL(relay) |
| 26 | DECLARE_DEBUG_CHANNEL(win) |
| 27 | |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 28 | /* Window procedure 16-to-32-bit thunk, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 29 | * see BuildSpec16Files() in tools/build.c */ |
| 30 | |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 31 | #include "pshpack1.h" |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 32 | typedef struct |
| 33 | { |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 34 | WORD pushw_bp; /* pushw %bp */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 35 | BYTE pushl_func; /* pushl $proc */ |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 36 | WNDPROC proc; |
| 37 | WORD pushw_ax; /* pushw %ax */ |
| 38 | BYTE pushl_relay; /* pushl $relay */ |
| 39 | void (*relay)(); /* WINPROC_Thunk16To32A/W() */ |
| 40 | BYTE lcall; /* lcall cs:glue */ |
| 41 | void (*glue)(); /* CallFrom16Long */ |
| 42 | WORD cs; /* __FLATCS */ |
| 43 | WORD lret; /* lret $10 */ |
| 44 | WORD nArgs; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 45 | } WINPROC_THUNK_FROM16; |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 46 | #include "poppack.h" |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 47 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 48 | /* Window procedure 32-to-16-bit thunk, |
| 49 | * see BuildSpec32Files() in tools/build.c */ |
| 50 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 51 | typedef struct |
| 52 | { |
| 53 | BYTE popl_eax; /* popl %eax (return address) */ |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 54 | BYTE pushl_func; /* pushl $proc */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 55 | WNDPROC16 proc WINE_PACKED; |
| 56 | BYTE pushl_eax; /* pushl %eax */ |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 57 | BYTE jmp; /* jmp relay (relative jump)*/ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 58 | void (*relay)() WINE_PACKED; /* WINPROC_CallProc32ATo16() */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 59 | } WINPROC_THUNK_FROM32; |
| 60 | |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 61 | /* Simple jmp to call 32-bit procedure directly */ |
| 62 | typedef struct |
| 63 | { |
| 64 | BYTE jmp; /* jmp proc (relative jump) */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 65 | WNDPROC proc WINE_PACKED; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 66 | } WINPROC_JUMP; |
| 67 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 68 | typedef union |
| 69 | { |
| 70 | WINPROC_THUNK_FROM16 t_from16; |
| 71 | WINPROC_THUNK_FROM32 t_from32; |
| 72 | } WINPROC_THUNK; |
| 73 | |
| 74 | typedef struct tagWINDOWPROC |
| 75 | { |
| 76 | WINPROC_THUNK thunk; /* Thunk */ |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 77 | WINPROC_JUMP jmp; /* Jump */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 78 | struct tagWINDOWPROC *next; /* Next window proc */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 79 | UINT magic; /* Magic number */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 80 | WINDOWPROCTYPE type; /* Function type */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 81 | WINDOWPROCUSER user; /* Function user */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 82 | } WINDOWPROC; |
| 83 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 84 | #define WINPROC_MAGIC ('W' | ('P' << 8) | ('R' << 16) | ('C' << 24)) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 85 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 86 | #define WINPROC_THUNKPROC(pproc) \ |
| 87 | (((pproc)->type == WIN_PROC_16) ? \ |
| 88 | (WNDPROC16)((pproc)->thunk.t_from32.proc) : \ |
| 89 | (WNDPROC16)((pproc)->thunk.t_from16.proc)) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 90 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 91 | static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND hwnd, |
| 92 | UINT msg, WPARAM wParam, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 93 | LPARAM lParam ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 94 | static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND hwnd, |
| 95 | UINT msg, WPARAM wParam, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 96 | LPARAM lParam ); |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 97 | static LRESULT WINAPI WINPROC_Thunk16To32A( WNDPROC func, LPBYTE args ); |
| 98 | static LRESULT WINAPI WINPROC_Thunk16To32W( WNDPROC func, LPBYTE args ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 99 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 100 | static HANDLE WinProcHeap; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 101 | |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 102 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 103 | /********************************************************************** |
| 104 | * WINPROC_Init |
| 105 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 106 | BOOL WINPROC_Init(void) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 107 | { |
| 108 | WinProcHeap = HeapCreate( HEAP_WINE_SEGPTR | HEAP_WINE_CODESEG, 0, 0 ); |
| 109 | if (!WinProcHeap) |
| 110 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 111 | WARN_(relay)("Unable to create winproc heap\n" ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 112 | return FALSE; |
| 113 | } |
| 114 | return TRUE; |
| 115 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 116 | |
| 117 | |
| 118 | /********************************************************************** |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 119 | * WINPROC_CallWndProc32 |
| 120 | * |
| 121 | * Call a 32-bit WndProc. |
| 122 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 123 | static LRESULT WINPROC_CallWndProc( WNDPROC proc, HWND hwnd, UINT msg, |
| 124 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 125 | { |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 126 | LRESULT retvalue; |
| 127 | int iWndsLocks; |
| 128 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 129 | TRACE_(relay)("(wndproc=%p,hwnd=%08x,msg=%s,wp=%08x,lp=%08lx)\n", |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 130 | proc, hwnd, SPY_GetMsgName(msg), wParam, lParam ); |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 131 | /* To avoid any deadlocks, all the locks on the windows structures |
| 132 | must be suspended before the control is passed to the application */ |
| 133 | iWndsLocks = WIN_SuspendWndsLock(); |
| 134 | retvalue = proc( hwnd, msg, wParam, lParam ); |
| 135 | WIN_RestoreWndsLock(iWndsLocks); |
| 136 | return retvalue; |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 139 | /*********************************************************************** |
| 140 | * WINPROC_CallWndProc16 |
| 141 | * |
| 142 | * Call a 16-bit window procedure |
| 143 | */ |
| 144 | static LRESULT WINAPI WINPROC_CallWndProc16( WNDPROC16 proc, HWND16 hwnd, |
| 145 | UINT16 msg, WPARAM16 wParam, |
| 146 | LPARAM lParam ) |
| 147 | { |
| 148 | CONTEXT86 context; |
| 149 | LRESULT ret; |
| 150 | WORD *args; |
| 151 | WND *wndPtr = WIN_FindWndPtr( hwnd ); |
| 152 | DWORD offset = 0; |
| 153 | TEB *teb = NtCurrentTeb(); |
| 154 | int iWndsLocks; |
| 155 | |
| 156 | /* Window procedures want ax = hInstance, ds = es = ss */ |
| 157 | |
| 158 | memset(&context, '\0', sizeof(context)); |
| 159 | DS_reg(&context) = SELECTOROF(teb->cur_stack); |
| 160 | ES_reg(&context) = DS_reg(&context); |
| 161 | EAX_reg(&context) = wndPtr ? wndPtr->hInstance : DS_reg(&context); |
| 162 | CS_reg(&context) = SELECTOROF(proc); |
| 163 | EIP_reg(&context) = OFFSETOF(proc); |
| 164 | EBP_reg(&context) = OFFSETOF(teb->cur_stack) |
| 165 | + (WORD)&((STACK16FRAME*)0)->bp; |
| 166 | |
| 167 | WIN_ReleaseWndPtr(wndPtr); |
| 168 | |
| 169 | if (lParam) |
| 170 | { |
| 171 | /* Some programs (eg. the "Undocumented Windows" examples, JWP) only |
| 172 | work if structures passed in lParam are placed in the stack/data |
| 173 | segment. Programmers easily make the mistake of converting lParam |
| 174 | to a near rather than a far pointer, since Windows apparently |
| 175 | allows this. We copy the structures to the 16 bit stack; this is |
| 176 | ugly but makes these programs work. */ |
| 177 | switch (msg) |
| 178 | { |
| 179 | case WM_CREATE: |
| 180 | case WM_NCCREATE: |
| 181 | offset = sizeof(CREATESTRUCT16); break; |
| 182 | case WM_DRAWITEM: |
| 183 | offset = sizeof(DRAWITEMSTRUCT16); break; |
| 184 | case WM_COMPAREITEM: |
| 185 | offset = sizeof(COMPAREITEMSTRUCT16); break; |
| 186 | } |
| 187 | if (offset) |
| 188 | { |
| 189 | void *s = PTR_SEG_TO_LIN(lParam); |
| 190 | lParam = stack16_push( offset ); |
| 191 | memcpy( PTR_SEG_TO_LIN(lParam), s, offset ); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | iWndsLocks = WIN_SuspendWndsLock(); |
| 196 | |
| 197 | args = (WORD *)THREAD_STACK16(teb) - 5; |
| 198 | args[0] = LOWORD(lParam); |
| 199 | args[1] = HIWORD(lParam); |
| 200 | args[2] = wParam; |
| 201 | args[3] = msg; |
| 202 | args[4] = hwnd; |
| 203 | |
| 204 | ret = CallTo16RegisterShort( &context, 5 * sizeof(WORD) ); |
| 205 | if (offset) stack16_pop( offset ); |
| 206 | |
| 207 | WIN_RestoreWndsLock(iWndsLocks); |
| 208 | |
| 209 | return ret; |
| 210 | } |
| 211 | |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 212 | |
| 213 | /********************************************************************** |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 214 | * WINPROC_GetPtr |
| 215 | * |
| 216 | * Return a pointer to the win proc. |
| 217 | */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 218 | static WINDOWPROC *WINPROC_GetPtr( WNDPROC16 handle ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 219 | { |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 220 | BYTE *ptr; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 221 | WINDOWPROC *proc; |
| 222 | |
| 223 | /* Check for a linear pointer */ |
| 224 | |
| 225 | if (HEAP_IsInsideHeap( WinProcHeap, 0, (LPVOID)handle )) |
| 226 | { |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 227 | ptr = (BYTE *)handle; |
| 228 | /* First check if it is the jmp address */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 229 | if (*ptr == 0xe9 /* jmp */) ptr -= (int)&((WINDOWPROC *)0)->jmp - |
| 230 | (int)&((WINDOWPROC *)0)->thunk; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 231 | /* Now it must be the thunk address */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 232 | if (*ptr == 0x58 /* popl eax */) ptr -= (int)&((WINDOWPROC *)0)->thunk; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 233 | /* Now we have a pointer to the WINDOWPROC struct */ |
| 234 | if (((WINDOWPROC *)ptr)->magic == WINPROC_MAGIC) |
| 235 | return (WINDOWPROC *)ptr; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /* Check for a segmented pointer */ |
| 239 | |
Alexandre Julliard | 8bbf818 | 1996-09-13 16:50:47 +0000 | [diff] [blame] | 240 | if (!IsBadReadPtr16((SEGPTR)handle,sizeof(WINDOWPROC)-sizeof(proc->thunk))) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 241 | { |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 242 | ptr = (BYTE *)PTR_SEG_TO_LIN(handle); |
Alexandre Julliard | 8cc3a5e | 1996-08-11 15:49:51 +0000 | [diff] [blame] | 243 | if (!HEAP_IsInsideHeap( WinProcHeap, 0, ptr )) return NULL; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 244 | /* It must be the thunk address */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 245 | if (*ptr == 0x58 /* popl eax */) ptr -= (int)&((WINDOWPROC *)0)->thunk; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 246 | /* Now we have a pointer to the WINDOWPROC struct */ |
| 247 | if (((WINDOWPROC *)ptr)->magic == WINPROC_MAGIC) |
| 248 | return (WINDOWPROC *)ptr; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | return NULL; |
| 252 | } |
| 253 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 254 | |
| 255 | /********************************************************************** |
| 256 | * WINPROC_AllocWinProc |
| 257 | * |
| 258 | * Allocate a new window procedure. |
| 259 | */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 260 | static WINDOWPROC *WINPROC_AllocWinProc( WNDPROC16 func, WINDOWPROCTYPE type, |
| 261 | WINDOWPROCUSER user ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 262 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 263 | WINDOWPROC *proc, *oldproc; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 264 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 265 | /* Allocate a window procedure */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 266 | |
| 267 | if (!(proc = HeapAlloc( WinProcHeap, 0, sizeof(WINDOWPROC) ))) return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 268 | |
| 269 | /* Check if the function is already a win proc */ |
| 270 | |
| 271 | if ((oldproc = WINPROC_GetPtr( func ))) |
| 272 | { |
| 273 | *proc = *oldproc; |
| 274 | } |
| 275 | else |
| 276 | { |
| 277 | switch(type) |
| 278 | { |
| 279 | case WIN_PROC_16: |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 280 | proc->thunk.t_from32.popl_eax = 0x58; /* popl %eax */ |
| 281 | proc->thunk.t_from32.pushl_func = 0x68; /* pushl $proc */ |
| 282 | proc->thunk.t_from32.proc = func; |
| 283 | proc->thunk.t_from32.pushl_eax = 0x50; /* pushl %eax */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 284 | proc->thunk.t_from32.jmp = 0xe9; /* jmp relay*/ |
| 285 | proc->thunk.t_from32.relay = /* relative jump */ |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 286 | (void(*)())((DWORD)WINPROC_CallProc32ATo16 - |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 287 | (DWORD)(&proc->thunk.t_from32.relay + 1)); |
| 288 | break; |
| 289 | case WIN_PROC_32A: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 290 | case WIN_PROC_32W: |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 291 | proc->thunk.t_from16.pushw_bp = 0x5566; /* pushw %bp */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 292 | proc->thunk.t_from16.pushl_func = 0x68; /* pushl $proc */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 293 | proc->thunk.t_from16.proc = (FARPROC)func; |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 294 | proc->thunk.t_from16.pushw_ax = 0x5066; /* pushw %ax */ |
| 295 | proc->thunk.t_from16.pushl_relay = 0x68; /* pushl $relay */ |
| 296 | proc->thunk.t_from16.relay = (type == WIN_PROC_32A) ? |
| 297 | (void(*)())WINPROC_Thunk16To32A : |
| 298 | (void(*)())WINPROC_Thunk16To32W; |
| 299 | proc->thunk.t_from16.lcall = 0x9a; /* lcall cs:glue */ |
| 300 | proc->thunk.t_from16.glue = (void*)CallFrom16Long; |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 301 | GET_CS(proc->thunk.t_from16.cs); |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 302 | proc->thunk.t_from16.lret = 0xca66; |
| 303 | proc->thunk.t_from16.nArgs = 10; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 304 | proc->jmp.jmp = 0xe9; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 305 | /* Fixup relative jump */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 306 | proc->jmp.proc = (WNDPROC)((DWORD)func - |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 307 | (DWORD)(&proc->jmp.proc + 1)); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 308 | break; |
| 309 | default: |
| 310 | /* Should not happen */ |
| 311 | break; |
| 312 | } |
| 313 | proc->magic = WINPROC_MAGIC; |
| 314 | proc->type = type; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 315 | proc->user = user; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 316 | } |
| 317 | proc->next = NULL; |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 318 | TRACE_(win)("(%08x,%d): returning %08x\n", |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 319 | (UINT)func, type, (UINT)proc ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 320 | return proc; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 321 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 322 | |
| 323 | |
| 324 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 325 | * WINPROC_GetProc |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 326 | * |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 327 | * Get a window procedure pointer that can be passed to the Windows program. |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 328 | */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 329 | WNDPROC16 WINPROC_GetProc( HWINDOWPROC proc, WINDOWPROCTYPE type ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 330 | { |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 331 | if (!proc) return NULL; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 332 | if (type == WIN_PROC_16) /* We want a 16:16 address */ |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 333 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 334 | if (((WINDOWPROC *)proc)->type == WIN_PROC_16) |
| 335 | return ((WINDOWPROC *)proc)->thunk.t_from32.proc; |
| 336 | else |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 337 | return (WNDPROC16)HEAP_GetSegptr( WinProcHeap, 0, |
| 338 | &((WINDOWPROC *)proc)->thunk ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 339 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 340 | else /* We want a 32-bit address */ |
| 341 | { |
| 342 | if (((WINDOWPROC *)proc)->type == WIN_PROC_16) |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 343 | return (WNDPROC16)&((WINDOWPROC *)proc)->thunk; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 344 | else if (type != ((WINDOWPROC *)proc)->type) |
| 345 | /* Have to return the jmp address if types don't match */ |
| 346 | return (WNDPROC16)&((WINDOWPROC *)proc)->jmp; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 347 | else |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 348 | /* Some Win16 programs want to get back the proc they set */ |
| 349 | return (WNDPROC16)((WINDOWPROC *)proc)->thunk.t_from16.proc; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 350 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | |
| 354 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 355 | * WINPROC_SetProc |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 356 | * |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 357 | * Set the window procedure for a window or class. There are |
| 358 | * three tree classes of winproc callbacks: |
| 359 | * |
| 360 | * 1) class -> wp - not subclassed |
| 361 | * class -> wp -> wp -> wp -> wp - SetClassLong() |
| 362 | * / / |
| 363 | * 2) window -' / - not subclassed |
| 364 | * window -> wp -> wp ' - SetWindowLong() |
| 365 | * |
| 366 | * 3) timer -> wp - SetTimer() |
| 367 | * |
| 368 | * Initially, winproc of the window points to the current winproc |
| 369 | * thunk of its class. Subclassing prepends a new thunk to the |
| 370 | * window winproc chain at the head of the list. Thus, window thunk |
| 371 | * list includes class thunks and the latter are preserved when the |
| 372 | * window is destroyed. |
| 373 | * |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 374 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 375 | BOOL WINPROC_SetProc( HWINDOWPROC *pFirst, WNDPROC16 func, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 376 | WINDOWPROCTYPE type, WINDOWPROCUSER user ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 377 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 378 | BOOL bRecycle = FALSE; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 379 | WINDOWPROC *proc, **ppPrev; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 380 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 381 | /* Check if function is already in the list */ |
| 382 | |
| 383 | ppPrev = (WINDOWPROC **)pFirst; |
| 384 | proc = WINPROC_GetPtr( func ); |
| 385 | while (*ppPrev) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 386 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 387 | if (proc) |
| 388 | { |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 389 | if (*ppPrev == proc) |
| 390 | { |
| 391 | if ((*ppPrev)->user != user) |
| 392 | { |
| 393 | /* terminal thunk is being restored */ |
| 394 | |
| 395 | WINPROC_FreeProc( *pFirst, (*ppPrev)->user ); |
| 396 | *(WINDOWPROC **)pFirst = *ppPrev; |
| 397 | return TRUE; |
| 398 | } |
| 399 | bRecycle = TRUE; |
| 400 | break; |
| 401 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 402 | } |
| 403 | else |
| 404 | { |
| 405 | if (((*ppPrev)->type == type) && |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 406 | (func == WINPROC_THUNKPROC(*ppPrev))) |
| 407 | { |
| 408 | bRecycle = TRUE; |
| 409 | break; |
| 410 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 411 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 412 | |
| 413 | /* WPF_CLASS thunk terminates window thunk list */ |
| 414 | if ((*ppPrev)->user != user) break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 415 | ppPrev = &(*ppPrev)->next; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 416 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 417 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 418 | if (bRecycle) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 419 | { |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 420 | /* Extract this thunk from the list */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 421 | proc = *ppPrev; |
| 422 | *ppPrev = proc->next; |
| 423 | } |
| 424 | else /* Allocate a new one */ |
| 425 | { |
| 426 | if (proc) /* Was already a win proc */ |
| 427 | { |
| 428 | type = proc->type; |
| 429 | func = WINPROC_THUNKPROC(proc); |
| 430 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 431 | proc = WINPROC_AllocWinProc( func, type, user ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 432 | if (!proc) return FALSE; |
| 433 | } |
| 434 | |
| 435 | /* Add the win proc at the head of the list */ |
| 436 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 437 | TRACE_(win)("(%08x,%08x,%d): res=%08x\n", |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 438 | (UINT)*pFirst, (UINT)func, type, (UINT)proc ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 439 | proc->next = *(WINDOWPROC **)pFirst; |
| 440 | *(WINDOWPROC **)pFirst = proc; |
| 441 | return TRUE; |
| 442 | } |
| 443 | |
| 444 | |
| 445 | /********************************************************************** |
| 446 | * WINPROC_FreeProc |
| 447 | * |
| 448 | * Free a list of win procs. |
| 449 | */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 450 | void WINPROC_FreeProc( HWINDOWPROC proc, WINDOWPROCUSER user ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 451 | { |
| 452 | while (proc) |
| 453 | { |
| 454 | WINDOWPROC *next = ((WINDOWPROC *)proc)->next; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 455 | if (((WINDOWPROC *)proc)->user != user) break; |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 456 | TRACE_(win)("freeing %08x\n", (UINT)proc); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 457 | HeapFree( WinProcHeap, 0, proc ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 458 | proc = next; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 459 | } |
| 460 | } |
| 461 | |
| 462 | |
| 463 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 464 | * WINPROC_GetProcType |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 465 | * |
| 466 | * Return the window procedure type. |
| 467 | */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 468 | WINDOWPROCTYPE WINPROC_GetProcType( HWINDOWPROC proc ) |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 469 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 470 | if (!proc || |
| 471 | (((WINDOWPROC *)proc)->magic != WINPROC_MAGIC)) |
| 472 | return WIN_PROC_INVALID; |
| 473 | return ((WINDOWPROC *)proc)->type; |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 474 | } |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 475 | /********************************************************************** |
| 476 | * WINPROC_TestCBForStr |
| 477 | * |
| 478 | * Return TRUE if the lparam is a string |
| 479 | */ |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 480 | static BOOL WINPROC_TestCBForStr ( HWND hwnd ) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 481 | { |
| 482 | BOOL retvalue; |
| 483 | WND * wnd = WIN_FindWndPtr(hwnd); |
| 484 | retvalue = ( !(LOWORD(wnd->dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) || |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 485 | (LOWORD(wnd->dwStyle) & CBS_HASSTRINGS) ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 486 | WIN_ReleaseWndPtr(wnd); |
| 487 | return retvalue; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 488 | } |
| 489 | /********************************************************************** |
| 490 | * WINPROC_TestLBForStr |
| 491 | * |
| 492 | * Return TRUE if the lparam is a string |
| 493 | */ |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 494 | static BOOL WINPROC_TestLBForStr ( HWND hwnd ) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 495 | { |
| 496 | BOOL retvalue; |
| 497 | WND * wnd = WIN_FindWndPtr(hwnd); |
| 498 | retvalue = ( !(LOWORD(wnd->dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) || |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 499 | (LOWORD(wnd->dwStyle) & LBS_HASSTRINGS) ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 500 | WIN_ReleaseWndPtr(wnd); |
| 501 | return retvalue; |
| 502 | |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 503 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 504 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 505 | * WINPROC_MapMsg32ATo32W |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 506 | * |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 507 | * Map a message from Ansi to Unicode. |
| 508 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. |
Juergen Schmied | 36636ed | 1998-11-15 16:53:34 +0000 | [diff] [blame] | 509 | * |
| 510 | * FIXME: |
| 511 | * WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR |
| 512 | * |
| 513 | * FIXME: |
| 514 | * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style: |
| 515 | * the first four bytes are the handle of the icon |
| 516 | * when the WM_SETTEXT message has been used to set the icon |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 517 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 518 | INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ) |
Juergen Schmied | 36636ed | 1998-11-15 16:53:34 +0000 | [diff] [blame] | 519 | { |
| 520 | switch(msg) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 521 | { |
| 522 | case WM_GETTEXT: |
| 523 | { |
| 524 | LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, |
| 525 | wParam * sizeof(WCHAR) + sizeof(LPARAM) ); |
| 526 | if (!ptr) return -1; |
| 527 | *ptr++ = *plparam; /* Store previous lParam */ |
| 528 | *plparam = (LPARAM)ptr; |
| 529 | } |
| 530 | return 1; |
Juergen Schmied | d3258fc | 1999-03-12 17:13:54 +0000 | [diff] [blame] | 531 | /* lparam is string (0-terminated) */ |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 532 | case WM_SETTEXT: |
Juergen Schmied | d3258fc | 1999-03-12 17:13:54 +0000 | [diff] [blame] | 533 | case WM_WININICHANGE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 534 | case CB_DIR: |
| 535 | case CB_FINDSTRING: |
| 536 | case CB_FINDSTRINGEXACT: |
| 537 | case CB_SELECTSTRING: |
| 538 | case LB_DIR: |
| 539 | case LB_ADDFILE: |
| 540 | case LB_FINDSTRING: |
| 541 | case LB_SELECTSTRING: |
| 542 | case EM_REPLACESEL: |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 543 | *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 544 | return (*plparam ? 1 : -1); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 545 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 546 | case WM_NCCREATE: |
| 547 | case WM_CREATE: |
| 548 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 549 | CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 550 | sizeof(*cs) ); |
| 551 | if (!cs) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 552 | *cs = *(CREATESTRUCTW *)*plparam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 553 | if (HIWORD(cs->lpszName)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 554 | cs->lpszName = HEAP_strdupAtoW( SystemHeap, 0, |
| 555 | (LPCSTR)cs->lpszName ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 556 | if (HIWORD(cs->lpszClass)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 557 | cs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0, |
| 558 | (LPCSTR)cs->lpszClass ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 559 | *plparam = (LPARAM)cs; |
| 560 | } |
| 561 | return 1; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 562 | case WM_MDICREATE: |
| 563 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 564 | MDICREATESTRUCTW *cs = |
| 565 | (MDICREATESTRUCTW *)HeapAlloc( SystemHeap, 0, sizeof(*cs) ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 566 | if (!cs) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 567 | *cs = *(MDICREATESTRUCTW *)*plparam; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 568 | if (HIWORD(cs->szClass)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 569 | cs->szClass = HEAP_strdupAtoW( SystemHeap, 0, |
| 570 | (LPCSTR)cs->szClass ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 571 | if (HIWORD(cs->szTitle)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 572 | cs->szTitle = HEAP_strdupAtoW( SystemHeap, 0, |
| 573 | (LPCSTR)cs->szTitle ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 574 | *plparam = (LPARAM)cs; |
| 575 | } |
| 576 | return 1; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 577 | |
| 578 | /* Listbox */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 579 | case LB_ADDSTRING: |
| 580 | case LB_INSERTSTRING: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 581 | if ( WINPROC_TestLBForStr( hwnd )) |
| 582 | *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam ); |
| 583 | return (*plparam ? 1 : -1); |
| 584 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 585 | case LB_GETTEXT: /* fixme: fixed sized buffer */ |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 586 | { if ( WINPROC_TestLBForStr( hwnd )) |
| 587 | { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) ); |
| 588 | if (!ptr) return -1; |
| 589 | *ptr++ = *plparam; /* Store previous lParam */ |
| 590 | *plparam = (LPARAM)ptr; |
| 591 | } |
| 592 | } |
| 593 | return 1; |
| 594 | |
| 595 | /* Combobox */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 596 | case CB_ADDSTRING: |
| 597 | case CB_INSERTSTRING: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 598 | if ( WINPROC_TestCBForStr( hwnd )) |
| 599 | *plparam = (LPARAM)HEAP_strdupAtoW( SystemHeap, 0, (LPCSTR)*plparam ); |
| 600 | return (*plparam ? 1 : -1); |
| 601 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 602 | case CB_GETLBTEXT: /* fixme: fixed sized buffer */ |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 603 | { if ( WINPROC_TestCBForStr( hwnd )) |
| 604 | { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) ); |
| 605 | if (!ptr) return -1; |
| 606 | *ptr++ = *plparam; /* Store previous lParam */ |
| 607 | *plparam = (LPARAM)ptr; |
| 608 | } |
| 609 | } |
| 610 | return 1; |
| 611 | |
| 612 | /* Multiline edit */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 613 | case EM_GETLINE: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 614 | { WORD len = (WORD)*plparam; |
| 615 | LPARAM *ptr = (LPARAM *) HEAP_xalloc( SystemHeap, 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) ); |
| 616 | if (!ptr) return -1; |
| 617 | *ptr++ = *plparam; /* Store previous lParam */ |
Patrik Stridvall | a9a671d | 1999-04-25 19:01:52 +0000 | [diff] [blame] | 618 | *((WORD *) ptr) = len; /* Store the length */ |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 619 | *plparam = (LPARAM)ptr; |
| 620 | } |
| 621 | return 1; |
| 622 | |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 623 | case WM_ASKCBFORMATNAME: |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 624 | case WM_DEVMODECHANGE: |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 625 | case WM_PAINTCLIPBOARD: |
| 626 | case WM_SIZECLIPBOARD: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 627 | case EM_SETPASSWORDCHAR: |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 628 | FIXME_(msg)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 629 | return -1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 630 | default: /* No translation needed */ |
| 631 | return 0; |
| 632 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | |
| 636 | /********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 637 | * WINPROC_UnmapMsg32ATo32W |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 638 | * |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 639 | * Unmap a message that was mapped from Ansi to Unicode. |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 640 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 641 | void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) |
Juergen Schmied | 36636ed | 1998-11-15 16:53:34 +0000 | [diff] [blame] | 642 | { |
| 643 | switch(msg) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 644 | { |
| 645 | case WM_GETTEXT: |
| 646 | { |
| 647 | LPARAM *ptr = (LPARAM *)lParam - 1; |
Juergen Schmied | 36636ed | 1998-11-15 16:53:34 +0000 | [diff] [blame] | 648 | lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam ); |
Juergen Schmied | 4a84dc2 | 1998-10-23 12:04:25 +0000 | [diff] [blame] | 649 | HeapFree( SystemHeap, 0, ptr ); |
| 650 | } |
| 651 | break; |
| 652 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 653 | case WM_NCCREATE: |
| 654 | case WM_CREATE: |
| 655 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 656 | CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 657 | if (HIWORD(cs->lpszName)) |
| 658 | HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName ); |
| 659 | if (HIWORD(cs->lpszClass)) |
| 660 | HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 661 | HeapFree( SystemHeap, 0, cs ); |
| 662 | } |
| 663 | break; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 664 | |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 665 | case WM_MDICREATE: |
| 666 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 667 | MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 668 | if (HIWORD(cs->szTitle)) |
| 669 | HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle ); |
| 670 | if (HIWORD(cs->szClass)) |
| 671 | HeapFree( SystemHeap, 0, (LPVOID)cs->szClass ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 672 | HeapFree( SystemHeap, 0, cs ); |
| 673 | } |
| 674 | break; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 675 | |
| 676 | case WM_SETTEXT: |
Juergen Schmied | d3258fc | 1999-03-12 17:13:54 +0000 | [diff] [blame] | 677 | case WM_WININICHANGE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 678 | case CB_DIR: |
| 679 | case CB_FINDSTRING: |
| 680 | case CB_FINDSTRINGEXACT: |
| 681 | case CB_SELECTSTRING: |
| 682 | case LB_DIR: |
| 683 | case LB_ADDFILE: |
| 684 | case LB_FINDSTRING: |
| 685 | case LB_SELECTSTRING: |
| 686 | case EM_REPLACESEL: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 687 | HeapFree( SystemHeap, 0, (void *)lParam ); |
| 688 | break; |
| 689 | |
| 690 | /* Listbox */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 691 | case LB_ADDSTRING: |
| 692 | case LB_INSERTSTRING: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 693 | if ( WINPROC_TestLBForStr( hwnd )) |
| 694 | HeapFree( SystemHeap, 0, (void *)lParam ); |
| 695 | break; |
| 696 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 697 | case LB_GETTEXT: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 698 | { if ( WINPROC_TestLBForStr( hwnd )) |
| 699 | { LPARAM *ptr = (LPARAM *)lParam - 1; |
| 700 | lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) ); |
| 701 | HeapFree( SystemHeap, 0, ptr ); |
| 702 | } |
| 703 | } |
| 704 | break; |
| 705 | |
| 706 | /* Combobox */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 707 | case CB_ADDSTRING: |
| 708 | case CB_INSERTSTRING: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 709 | if ( WINPROC_TestCBForStr( hwnd )) |
| 710 | HeapFree( SystemHeap, 0, (void *)lParam ); |
| 711 | break; |
| 712 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 713 | case CB_GETLBTEXT: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 714 | { if ( WINPROC_TestCBForStr( hwnd )) |
| 715 | { LPARAM *ptr = (LPARAM *)lParam - 1; |
| 716 | lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) ); |
| 717 | HeapFree( SystemHeap, 0, ptr ); |
| 718 | } |
| 719 | } |
| 720 | break; |
| 721 | |
| 722 | /* Multiline edit */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 723 | case EM_GETLINE: |
Juergen Schmied | afd5580 | 1999-01-31 09:18:58 +0000 | [diff] [blame] | 724 | { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lParam */ |
| 725 | WORD len = *(WORD *) lParam; |
| 726 | lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len ); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 727 | HeapFree( SystemHeap, 0, ptr ); |
| 728 | } |
| 729 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 730 | } |
| 731 | } |
| 732 | |
| 733 | |
| 734 | /********************************************************************** |
| 735 | * WINPROC_MapMsg32WTo32A |
| 736 | * |
| 737 | * Map a message from Unicode to Ansi. |
| 738 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. |
| 739 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 740 | INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam ) |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 741 | { switch(msg) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 742 | { |
| 743 | case WM_GETTEXT: |
| 744 | { |
| 745 | LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, |
| 746 | wParam + sizeof(LPARAM) ); |
| 747 | if (!ptr) return -1; |
| 748 | *ptr++ = *plparam; /* Store previous lParam */ |
| 749 | *plparam = (LPARAM)ptr; |
| 750 | } |
| 751 | return 1; |
Juergen Schmied | 4a84dc2 | 1998-10-23 12:04:25 +0000 | [diff] [blame] | 752 | |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 753 | case WM_SETTEXT: |
Juergen Schmied | d3258fc | 1999-03-12 17:13:54 +0000 | [diff] [blame] | 754 | case WM_WININICHANGE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 755 | case CB_DIR: |
| 756 | case CB_FINDSTRING: |
| 757 | case CB_FINDSTRINGEXACT: |
| 758 | case CB_SELECTSTRING: |
| 759 | case LB_DIR: |
| 760 | case LB_ADDFILE: |
| 761 | case LB_FINDSTRING: |
| 762 | case LB_SELECTSTRING: |
| 763 | case EM_REPLACESEL: |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 764 | *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 765 | return (*plparam ? 1 : -1); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 766 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 767 | case WM_NCCREATE: |
| 768 | case WM_CREATE: |
| 769 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 770 | CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 771 | sizeof(*cs) ); |
| 772 | if (!cs) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 773 | *cs = *(CREATESTRUCTA *)*plparam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 774 | if (HIWORD(cs->lpszName)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 775 | cs->lpszName = HEAP_strdupWtoA( SystemHeap, 0, |
| 776 | (LPCWSTR)cs->lpszName ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 777 | if (HIWORD(cs->lpszClass)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 778 | cs->lpszClass = HEAP_strdupWtoA( SystemHeap, 0, |
| 779 | (LPCWSTR)cs->lpszClass); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 780 | *plparam = (LPARAM)cs; |
| 781 | } |
| 782 | return 1; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 783 | case WM_MDICREATE: |
| 784 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 785 | MDICREATESTRUCTA *cs = |
| 786 | (MDICREATESTRUCTA *)HeapAlloc( SystemHeap, 0, sizeof(*cs) ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 787 | if (!cs) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 788 | *cs = *(MDICREATESTRUCTA *)*plparam; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 789 | if (HIWORD(cs->szTitle)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 790 | cs->szTitle = HEAP_strdupWtoA( SystemHeap, 0, |
| 791 | (LPCWSTR)cs->szTitle ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 792 | if (HIWORD(cs->szClass)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 793 | cs->szClass = HEAP_strdupWtoA( SystemHeap, 0, |
| 794 | (LPCWSTR)cs->szClass ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 795 | *plparam = (LPARAM)cs; |
| 796 | } |
| 797 | return 1; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 798 | |
| 799 | /* Listbox */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 800 | case LB_ADDSTRING: |
| 801 | case LB_INSERTSTRING: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 802 | if ( WINPROC_TestLBForStr( hwnd )) |
| 803 | *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam ); |
| 804 | return (*plparam ? 1 : -1); |
| 805 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 806 | case LB_GETTEXT: /* fixme: fixed sized buffer */ |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 807 | { if ( WINPROC_TestLBForStr( hwnd )) |
| 808 | { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 + sizeof(LPARAM) ); |
| 809 | if (!ptr) return -1; |
| 810 | *ptr++ = *plparam; /* Store previous lParam */ |
| 811 | *plparam = (LPARAM)ptr; |
| 812 | } |
| 813 | } |
| 814 | return 1; |
| 815 | |
| 816 | /* Combobox */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 817 | case CB_ADDSTRING: |
| 818 | case CB_INSERTSTRING: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 819 | if ( WINPROC_TestCBForStr( hwnd )) |
| 820 | *plparam = (LPARAM)HEAP_strdupWtoA( SystemHeap, 0, (LPCWSTR)*plparam ); |
| 821 | return (*plparam ? 1 : -1); |
| 822 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 823 | case CB_GETLBTEXT: /* fixme: fixed sized buffer */ |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 824 | { if ( WINPROC_TestCBForStr( hwnd )) |
| 825 | { LPARAM *ptr = (LPARAM *)HeapAlloc( SystemHeap, 0, 256 + sizeof(LPARAM) ); |
| 826 | if (!ptr) return -1; |
| 827 | *ptr++ = *plparam; /* Store previous lParam */ |
| 828 | *plparam = (LPARAM)ptr; |
| 829 | } |
| 830 | } |
| 831 | return 1; |
| 832 | |
| 833 | /* Multiline edit */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 834 | case EM_GETLINE: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 835 | { WORD len = (WORD)*plparam; |
| 836 | LPARAM *ptr = (LPARAM *) HEAP_xalloc( SystemHeap, 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) ); |
| 837 | if (!ptr) return -1; |
| 838 | *ptr++ = *plparam; /* Store previous lParam */ |
Patrik Stridvall | a9a671d | 1999-04-25 19:01:52 +0000 | [diff] [blame] | 839 | *((WORD *) ptr) = len; /* Store the length */ |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 840 | *plparam = (LPARAM)ptr; |
| 841 | } |
| 842 | return 1; |
| 843 | |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 844 | case WM_ASKCBFORMATNAME: |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 845 | case WM_DEVMODECHANGE: |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 846 | case WM_PAINTCLIPBOARD: |
| 847 | case WM_SIZECLIPBOARD: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 848 | case EM_SETPASSWORDCHAR: |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 849 | FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 850 | return -1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 851 | default: /* No translation needed */ |
| 852 | return 0; |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | |
| 857 | /********************************************************************** |
| 858 | * WINPROC_UnmapMsg32WTo32A |
| 859 | * |
| 860 | * Unmap a message that was mapped from Unicode to Ansi. |
| 861 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 862 | void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) |
Juergen Schmied | 36636ed | 1998-11-15 16:53:34 +0000 | [diff] [blame] | 863 | { |
| 864 | switch(msg) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 865 | { |
| 866 | case WM_GETTEXT: |
| 867 | { |
| 868 | LPARAM *ptr = (LPARAM *)lParam - 1; |
Juergen Schmied | 36636ed | 1998-11-15 16:53:34 +0000 | [diff] [blame] | 869 | lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 870 | HeapFree( SystemHeap, 0, ptr ); |
| 871 | } |
| 872 | break; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 873 | |
| 874 | case WM_SETTEXT: |
Juergen Schmied | d3258fc | 1999-03-12 17:13:54 +0000 | [diff] [blame] | 875 | case WM_WININICHANGE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 876 | case CB_DIR: |
| 877 | case CB_FINDSTRING: |
| 878 | case CB_FINDSTRINGEXACT: |
| 879 | case CB_SELECTSTRING: |
| 880 | case LB_DIR: |
| 881 | case LB_ADDFILE: |
| 882 | case LB_FINDSTRING: |
| 883 | case LB_SELECTSTRING: |
| 884 | case EM_REPLACESEL: |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 885 | HeapFree( SystemHeap, 0, (void *)lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 886 | break; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 887 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 888 | case WM_NCCREATE: |
| 889 | case WM_CREATE: |
| 890 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 891 | CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 892 | if (HIWORD(cs->lpszName)) |
| 893 | HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName ); |
| 894 | if (HIWORD(cs->lpszClass)) |
| 895 | HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 896 | HeapFree( SystemHeap, 0, cs ); |
| 897 | } |
| 898 | break; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 899 | |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 900 | case WM_MDICREATE: |
| 901 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 902 | MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 903 | if (HIWORD(cs->szTitle)) |
| 904 | HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle ); |
| 905 | if (HIWORD(cs->szClass)) |
| 906 | HeapFree( SystemHeap, 0, (LPVOID)cs->szClass ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 907 | HeapFree( SystemHeap, 0, cs ); |
| 908 | } |
| 909 | break; |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 910 | |
| 911 | /* Listbox */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 912 | case LB_ADDSTRING: |
| 913 | case LB_INSERTSTRING: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 914 | if ( WINPROC_TestLBForStr( hwnd )) |
| 915 | HeapFree( SystemHeap, 0, (void *)lParam ); |
| 916 | break; |
| 917 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 918 | case LB_GETTEXT: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 919 | { if ( WINPROC_TestLBForStr( hwnd )) |
| 920 | { LPARAM *ptr = (LPARAM *)lParam - 1; |
| 921 | lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) ); |
| 922 | HeapFree( SystemHeap, 0, ptr ); |
| 923 | } |
| 924 | } |
| 925 | break; |
| 926 | |
| 927 | /* Combobox */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 928 | case CB_ADDSTRING: |
| 929 | case CB_INSERTSTRING: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 930 | if ( WINPROC_TestCBForStr( hwnd )) |
| 931 | HeapFree( SystemHeap, 0, (void *)lParam ); |
| 932 | break; |
| 933 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 934 | case CB_GETLBTEXT: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 935 | { if ( WINPROC_TestCBForStr( hwnd )) |
| 936 | { LPARAM *ptr = (LPARAM *)lParam - 1; |
| 937 | lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) ); |
| 938 | HeapFree( SystemHeap, 0, ptr ); |
| 939 | } |
| 940 | } |
| 941 | break; |
| 942 | |
| 943 | /* Multiline edit */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 944 | case EM_GETLINE: |
Juergen Schmied | afd5580 | 1999-01-31 09:18:58 +0000 | [diff] [blame] | 945 | { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lparam */ |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 946 | WORD len = *(WORD *)ptr; |
Juergen Schmied | afd5580 | 1999-01-31 09:18:58 +0000 | [diff] [blame] | 947 | lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len ); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 948 | HeapFree( SystemHeap, 0, ptr ); |
| 949 | } |
| 950 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 951 | } |
| 952 | } |
| 953 | |
| 954 | |
| 955 | /********************************************************************** |
| 956 | * WINPROC_MapMsg16To32A |
| 957 | * |
| 958 | * Map a message from 16- to 32-bit Ansi. |
| 959 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. |
| 960 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 961 | INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32, |
| 962 | WPARAM *pwparam32, LPARAM *plparam ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 963 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 964 | *pmsg32 = (UINT)msg16; |
| 965 | *pwparam32 = (WPARAM)wParam16; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 966 | switch(msg16) |
| 967 | { |
| 968 | case WM_ACTIVATE: |
| 969 | case WM_CHARTOITEM: |
| 970 | case WM_COMMAND: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 971 | case WM_VKEYTOITEM: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 972 | *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 973 | *plparam = (LPARAM)(HWND)LOWORD(*plparam); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 974 | return 0; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 975 | case WM_HSCROLL: |
| 976 | case WM_VSCROLL: |
| 977 | *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 978 | *plparam = (LPARAM)(HWND)HIWORD(*plparam); |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 979 | return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 980 | case WM_CTLCOLOR: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 981 | if ( HIWORD(*plparam) > CTLCOLOR_STATIC ) return -1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 982 | *pmsg32 = WM_CTLCOLORMSGBOX + HIWORD(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 983 | *pwparam32 = (WPARAM)(HDC)wParam16; |
| 984 | *plparam = (LPARAM)(HWND)LOWORD(*plparam); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 985 | return 0; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 986 | case WM_COMPAREITEM: |
| 987 | { |
| 988 | COMPAREITEMSTRUCT16* cis16 = (COMPAREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 989 | COMPAREITEMSTRUCT *cis = (COMPAREITEMSTRUCT *) |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 990 | HeapAlloc(SystemHeap, 0, sizeof(*cis)); |
| 991 | if (!cis) return -1; |
| 992 | cis->CtlType = cis16->CtlType; |
| 993 | cis->CtlID = cis16->CtlID; |
| 994 | cis->hwndItem = cis16->hwndItem; |
| 995 | cis->itemID1 = cis16->itemID1; |
| 996 | cis->itemData1 = cis16->itemData1; |
| 997 | cis->itemID2 = cis16->itemID2; |
| 998 | cis->itemData2 = cis16->itemData2; |
| 999 | cis->dwLocaleId = 0; /* FIXME */ |
| 1000 | *plparam = (LPARAM)cis; |
| 1001 | } |
| 1002 | return 1; |
| 1003 | case WM_DELETEITEM: |
| 1004 | { |
| 1005 | DELETEITEMSTRUCT16* dis16 = (DELETEITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1006 | DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *) |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1007 | HeapAlloc(SystemHeap, 0, sizeof(*dis)); |
| 1008 | if (!dis) return -1; |
| 1009 | dis->CtlType = dis16->CtlType; |
| 1010 | dis->CtlID = dis16->CtlID; |
| 1011 | dis->hwndItem = dis16->hwndItem; |
| 1012 | dis->itemData = dis16->itemData; |
| 1013 | *plparam = (LPARAM)dis; |
| 1014 | } |
| 1015 | return 1; |
| 1016 | case WM_MEASUREITEM: |
| 1017 | { |
| 1018 | MEASUREITEMSTRUCT16* mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1019 | MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1020 | HeapAlloc(SystemHeap, 0, |
| 1021 | sizeof(*mis) + sizeof(LPARAM)); |
| 1022 | if (!mis) return -1; |
| 1023 | mis->CtlType = mis16->CtlType; |
| 1024 | mis->CtlID = mis16->CtlID; |
| 1025 | mis->itemID = mis16->itemID; |
| 1026 | mis->itemWidth = mis16->itemWidth; |
| 1027 | mis->itemHeight = mis16->itemHeight; |
| 1028 | mis->itemData = mis16->itemData; |
| 1029 | *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */ |
| 1030 | *plparam = (LPARAM)mis; |
| 1031 | } |
| 1032 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1033 | case WM_DRAWITEM: |
| 1034 | { |
| 1035 | DRAWITEMSTRUCT16* dis16 = (DRAWITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1036 | DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)HeapAlloc(SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1037 | sizeof(*dis)); |
| 1038 | if (!dis) return -1; |
| 1039 | dis->CtlType = dis16->CtlType; |
| 1040 | dis->CtlID = dis16->CtlID; |
| 1041 | dis->itemID = dis16->itemID; |
| 1042 | dis->itemAction = dis16->itemAction; |
| 1043 | dis->itemState = dis16->itemState; |
| 1044 | dis->hwndItem = dis16->hwndItem; |
| 1045 | dis->hDC = dis16->hDC; |
| 1046 | dis->itemData = dis16->itemData; |
| 1047 | CONV_RECT16TO32( &dis16->rcItem, &dis->rcItem ); |
| 1048 | *plparam = (LPARAM)dis; |
| 1049 | } |
| 1050 | return 1; |
| 1051 | case WM_GETMINMAXINFO: |
| 1052 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1053 | MINMAXINFO *mmi = (MINMAXINFO *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1054 | sizeof(*mmi) + sizeof(LPARAM)); |
| 1055 | if (!mmi) return -1; |
| 1056 | STRUCT32_MINMAXINFO16to32( (MINMAXINFO16*)PTR_SEG_TO_LIN(*plparam), |
| 1057 | mmi ); |
| 1058 | *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */ |
| 1059 | *plparam = (LPARAM)mmi; |
| 1060 | } |
| 1061 | return 1; |
| 1062 | case WM_GETTEXT: |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1063 | case WM_SETTEXT: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1064 | *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam); |
| 1065 | return 0; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1066 | case WM_MDICREATE: |
| 1067 | { |
| 1068 | MDICREATESTRUCT16 *cs16 = |
| 1069 | (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1070 | MDICREATESTRUCTA *cs = |
| 1071 | (MDICREATESTRUCTA *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1072 | sizeof(*cs) + sizeof(LPARAM) ); |
| 1073 | if (!cs) return -1; |
| 1074 | STRUCT32_MDICREATESTRUCT16to32A( cs16, cs ); |
| 1075 | cs->szTitle = (LPCSTR)PTR_SEG_TO_LIN(cs16->szTitle); |
| 1076 | cs->szClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->szClass); |
| 1077 | *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */ |
| 1078 | *plparam = (LPARAM)cs; |
| 1079 | } |
| 1080 | return 1; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1081 | case WM_MDIGETACTIVE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1082 | *plparam = (LPARAM)HeapAlloc( SystemHeap, 0, sizeof(BOOL) ); |
| 1083 | *(BOOL*)(*plparam) = 0; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1084 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1085 | case WM_MDISETMENU: |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1086 | if(wParam16==TRUE) |
| 1087 | *pmsg32=WM_MDIREFRESHMENU; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1088 | *pwparam32 = (WPARAM)(HMENU)LOWORD(*plparam); |
| 1089 | *plparam = (LPARAM)(HMENU)HIWORD(*plparam); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1090 | return 0; |
| 1091 | case WM_MENUCHAR: |
| 1092 | case WM_MENUSELECT: |
| 1093 | *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1094 | *plparam = (LPARAM)(HMENU)HIWORD(*plparam); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1095 | return 0; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1096 | case WM_MDIACTIVATE: |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1097 | if( *plparam ) |
| 1098 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1099 | *pwparam32 = (WPARAM)(HWND)HIWORD(*plparam); |
| 1100 | *plparam = (LPARAM)(HWND)LOWORD(*plparam); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1101 | } |
| 1102 | else /* message sent to MDI client */ |
| 1103 | *pwparam32 = wParam16; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1104 | return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1105 | case WM_NCCALCSIZE: |
| 1106 | { |
| 1107 | NCCALCSIZE_PARAMS16 *nc16; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1108 | NCCALCSIZE_PARAMS *nc; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1109 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1110 | nc = (NCCALCSIZE_PARAMS *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1111 | sizeof(*nc) + sizeof(LPARAM) ); |
| 1112 | if (!nc) return -1; |
| 1113 | nc16 = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(*plparam); |
| 1114 | CONV_RECT16TO32( &nc16->rgrc[0], &nc->rgrc[0] ); |
| 1115 | if (wParam16) |
| 1116 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1117 | nc->lppos = (WINDOWPOS *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1118 | sizeof(*nc->lppos) ); |
| 1119 | CONV_RECT16TO32( &nc16->rgrc[1], &nc->rgrc[1] ); |
| 1120 | CONV_RECT16TO32( &nc16->rgrc[2], &nc->rgrc[2] ); |
| 1121 | if (nc->lppos) STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc16->lppos), nc->lppos ); |
| 1122 | } |
| 1123 | *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */ |
| 1124 | *plparam = (LPARAM)nc; |
| 1125 | } |
| 1126 | return 1; |
| 1127 | case WM_NCCREATE: |
| 1128 | case WM_CREATE: |
| 1129 | { |
| 1130 | CREATESTRUCT16 *cs16 = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1131 | CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1132 | sizeof(*cs) + sizeof(LPARAM) ); |
| 1133 | if (!cs) return -1; |
| 1134 | STRUCT32_CREATESTRUCT16to32A( cs16, cs ); |
| 1135 | cs->lpszName = (LPCSTR)PTR_SEG_TO_LIN(cs16->lpszName); |
| 1136 | cs->lpszClass = (LPCSTR)PTR_SEG_TO_LIN(cs16->lpszClass); |
| 1137 | *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */ |
| 1138 | *plparam = (LPARAM)cs; |
| 1139 | } |
| 1140 | return 1; |
| 1141 | case WM_PARENTNOTIFY: |
| 1142 | if ((wParam16 == WM_CREATE) || (wParam16 == WM_DESTROY)) |
| 1143 | { |
| 1144 | *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1145 | *plparam = (LPARAM)(HWND)LOWORD(*plparam); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1146 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1147 | return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1148 | case WM_WINDOWPOSCHANGING: |
| 1149 | case WM_WINDOWPOSCHANGED: |
| 1150 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1151 | WINDOWPOS *wp = (WINDOWPOS *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1152 | sizeof(*wp) + sizeof(LPARAM) ); |
| 1153 | if (!wp) return -1; |
| 1154 | STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(*plparam), |
| 1155 | wp ); |
| 1156 | *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */ |
| 1157 | *plparam = (LPARAM)wp; |
| 1158 | } |
| 1159 | return 1; |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1160 | case WM_GETDLGCODE: |
Alexandre Julliard | 463b713 | 1998-11-01 16:23:54 +0000 | [diff] [blame] | 1161 | if (*plparam) |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1162 | { |
| 1163 | LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1164 | LPMSG msg32 = (LPMSG)HeapAlloc( SystemHeap, 0, sizeof(MSG) ); |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1165 | |
| 1166 | if (!msg32) return -1; |
| 1167 | msg32->hwnd = msg16->hwnd; |
| 1168 | msg32->lParam = msg16->lParam; |
| 1169 | msg32->time = msg16->time; |
| 1170 | CONV_POINT16TO32(&msg16->pt,&msg32->pt); |
| 1171 | /* this is right, right? */ |
| 1172 | if (WINPROC_MapMsg16To32A(msg16->message,msg16->wParam, |
| 1173 | &msg32->message,&msg32->wParam, |
| 1174 | &msg32->lParam)<0) { |
| 1175 | HeapFree( SystemHeap, 0, msg32 ); |
| 1176 | return -1; |
| 1177 | } |
| 1178 | *plparam = (LPARAM)msg32; |
Alexandre Julliard | 463b713 | 1998-11-01 16:23:54 +0000 | [diff] [blame] | 1179 | return 1; |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1180 | } |
Alexandre Julliard | 463b713 | 1998-11-01 16:23:54 +0000 | [diff] [blame] | 1181 | else return 0; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1182 | case WM_NOTIFY: |
| 1183 | *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam); |
| 1184 | return 1; |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 1185 | case WM_ACTIVATEAPP: |
| 1186 | if (*plparam) |
| 1187 | { /* We need this when SetActiveWindow sends a Sendmessage16() to |
| 1188 | a 32bit window. Might be superflous with 32bit interprocess |
| 1189 | message queues. |
| 1190 | */ |
| 1191 | HTASK16 htask = (HTASK16) *plparam; |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 1192 | DWORD idThread = (DWORD)((TDB*)GlobalLock16(htask))->teb->tid; |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 1193 | *plparam = (LPARAM) idThread; |
| 1194 | } |
| 1195 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1196 | case WM_ASKCBFORMATNAME: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1197 | case WM_DEVMODECHANGE: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1198 | case WM_PAINTCLIPBOARD: |
| 1199 | case WM_SIZECLIPBOARD: |
| 1200 | case WM_WININICHANGE: |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 1201 | FIXME_(msg)("message %04x needs translation\n",msg16 ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1202 | return -1; |
| 1203 | |
| 1204 | default: /* No translation needed */ |
| 1205 | return 0; |
| 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | |
| 1210 | /********************************************************************** |
| 1211 | * WINPROC_UnmapMsg16To32A |
| 1212 | * |
| 1213 | * Unmap a message that was mapped from 16- to 32-bit Ansi. |
| 1214 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1215 | LRESULT WINPROC_UnmapMsg16To32A( HWND16 hwnd, UINT msg, WPARAM wParam, LPARAM lParam, |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1216 | LRESULT result ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1217 | { |
| 1218 | switch(msg) |
| 1219 | { |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1220 | case WM_COMPAREITEM: |
| 1221 | case WM_DELETEITEM: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1222 | case WM_DRAWITEM: |
| 1223 | HeapFree( SystemHeap, 0, (LPVOID)lParam ); |
| 1224 | break; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1225 | case WM_MEASUREITEM: |
| 1226 | { |
| 1227 | MEASUREITEMSTRUCT16 *mis16; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1228 | MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1229 | lParam = *(LPARAM *)(mis + 1); |
| 1230 | mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(lParam); |
| 1231 | mis16->itemWidth = (UINT16)mis->itemWidth; |
| 1232 | mis16->itemHeight = (UINT16)mis->itemHeight; |
| 1233 | HeapFree( SystemHeap, 0, mis ); |
| 1234 | } |
| 1235 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1236 | case WM_GETMINMAXINFO: |
| 1237 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1238 | MINMAXINFO *mmi = (MINMAXINFO *)lParam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1239 | lParam = *(LPARAM *)(mmi + 1); |
| 1240 | STRUCT32_MINMAXINFO32to16( mmi, |
| 1241 | (MINMAXINFO16 *)PTR_SEG_TO_LIN(lParam)); |
| 1242 | HeapFree( SystemHeap, 0, mmi ); |
| 1243 | } |
| 1244 | break; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1245 | case WM_MDICREATE: |
| 1246 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1247 | MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1248 | lParam = *(LPARAM *)(cs + 1); |
| 1249 | STRUCT32_MDICREATESTRUCT32Ato16( cs, |
| 1250 | (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) ); |
| 1251 | HeapFree( SystemHeap, 0, cs ); |
| 1252 | } |
| 1253 | break; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1254 | case WM_MDIGETACTIVE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1255 | result = MAKELONG( LOWORD(result), (BOOL16)(*(BOOL *)lParam) ); |
| 1256 | HeapFree( SystemHeap, 0, (BOOL *)lParam ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1257 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1258 | case WM_NCCALCSIZE: |
| 1259 | { |
| 1260 | NCCALCSIZE_PARAMS16 *nc16; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1261 | NCCALCSIZE_PARAMS *nc = (NCCALCSIZE_PARAMS *)lParam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1262 | lParam = *(LPARAM *)(nc + 1); |
| 1263 | nc16 = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(lParam); |
| 1264 | CONV_RECT32TO16( &nc->rgrc[0], &nc16->rgrc[0] ); |
| 1265 | if (wParam) |
| 1266 | { |
| 1267 | CONV_RECT32TO16( &nc->rgrc[1], &nc16->rgrc[1] ); |
| 1268 | CONV_RECT32TO16( &nc->rgrc[2], &nc16->rgrc[2] ); |
| 1269 | if (nc->lppos) |
| 1270 | { |
| 1271 | STRUCT32_WINDOWPOS32to16( nc->lppos, |
| 1272 | (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc16->lppos)); |
| 1273 | HeapFree( SystemHeap, 0, nc->lppos ); |
| 1274 | } |
| 1275 | } |
| 1276 | HeapFree( SystemHeap, 0, nc ); |
| 1277 | } |
| 1278 | break; |
| 1279 | case WM_NCCREATE: |
| 1280 | case WM_CREATE: |
| 1281 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1282 | CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1283 | lParam = *(LPARAM *)(cs + 1); |
| 1284 | STRUCT32_CREATESTRUCT32Ato16( cs, |
| 1285 | (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) ); |
| 1286 | HeapFree( SystemHeap, 0, cs ); |
| 1287 | } |
| 1288 | break; |
| 1289 | case WM_WINDOWPOSCHANGING: |
| 1290 | case WM_WINDOWPOSCHANGED: |
| 1291 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1292 | WINDOWPOS *wp = (WINDOWPOS *)lParam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1293 | lParam = *(LPARAM *)(wp + 1); |
| 1294 | STRUCT32_WINDOWPOS32to16(wp,(WINDOWPOS16 *)PTR_SEG_TO_LIN(lParam)); |
| 1295 | HeapFree( SystemHeap, 0, wp ); |
| 1296 | } |
| 1297 | break; |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1298 | case WM_GETDLGCODE: |
Alexandre Julliard | 463b713 | 1998-11-01 16:23:54 +0000 | [diff] [blame] | 1299 | if (lParam) |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1300 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1301 | LPMSG msg32 = (LPMSG)lParam; |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1302 | |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 1303 | WINPROC_UnmapMsg16To32A( hwnd, msg32->message, msg32->wParam, msg32->lParam, |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1304 | result); |
| 1305 | HeapFree( SystemHeap, 0, msg32 ); |
| 1306 | } |
| 1307 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1308 | } |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1309 | return result; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1310 | } |
| 1311 | |
| 1312 | |
| 1313 | /********************************************************************** |
| 1314 | * WINPROC_MapMsg16To32W |
| 1315 | * |
| 1316 | * Map a message from 16- to 32-bit Unicode. |
| 1317 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. |
| 1318 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1319 | INT WINPROC_MapMsg16To32W( HWND16 hwnd, UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32, |
| 1320 | WPARAM *pwparam32, LPARAM *plparam ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1321 | { |
| 1322 | switch(msg16) |
| 1323 | { |
| 1324 | case WM_GETTEXT: |
| 1325 | case WM_SETTEXT: |
| 1326 | *plparam = (LPARAM)PTR_SEG_TO_LIN(*plparam); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 1327 | return WINPROC_MapMsg32ATo32W( hwnd, *pmsg32, *pwparam32, plparam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1328 | case WM_NCCREATE: |
| 1329 | case WM_CREATE: |
| 1330 | { |
| 1331 | CREATESTRUCT16 *cs16 = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1332 | CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1333 | sizeof(*cs) + sizeof(LPARAM) ); |
| 1334 | if (!cs) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1335 | STRUCT32_CREATESTRUCT16to32A( cs16, (CREATESTRUCTA *)cs ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1336 | cs->lpszName = (LPCWSTR)PTR_SEG_TO_LIN(cs16->lpszName); |
| 1337 | cs->lpszClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->lpszClass); |
| 1338 | if (HIWORD(cs->lpszName)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1339 | cs->lpszName = HEAP_strdupAtoW( SystemHeap, 0, |
| 1340 | (LPCSTR)cs->lpszName ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1341 | if (HIWORD(cs->lpszClass)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1342 | cs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0, |
| 1343 | (LPCSTR)cs->lpszClass ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1344 | *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */ |
| 1345 | *plparam = (LPARAM)cs; |
| 1346 | } |
| 1347 | return 1; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1348 | case WM_MDICREATE: |
| 1349 | { |
| 1350 | MDICREATESTRUCT16 *cs16 = |
| 1351 | (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1352 | MDICREATESTRUCTW *cs = |
| 1353 | (MDICREATESTRUCTW *)HeapAlloc( SystemHeap, 0, |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1354 | sizeof(*cs) + sizeof(LPARAM) ); |
| 1355 | if (!cs) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1356 | STRUCT32_MDICREATESTRUCT16to32A( cs16, (MDICREATESTRUCTA *)cs ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1357 | cs->szTitle = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szTitle); |
| 1358 | cs->szClass = (LPCWSTR)PTR_SEG_TO_LIN(cs16->szClass); |
| 1359 | if (HIWORD(cs->szTitle)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1360 | cs->szTitle = HEAP_strdupAtoW( SystemHeap, 0, |
| 1361 | (LPCSTR)cs->szTitle ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1362 | if (HIWORD(cs->szClass)) |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1363 | cs->szClass = HEAP_strdupAtoW( SystemHeap, 0, |
| 1364 | (LPCSTR)cs->szClass ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1365 | *(LPARAM *)(cs + 1) = *plparam; /* Store the previous lParam */ |
| 1366 | *plparam = (LPARAM)cs; |
| 1367 | } |
| 1368 | return 1; |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1369 | case WM_GETDLGCODE: |
Alexandre Julliard | 463b713 | 1998-11-01 16:23:54 +0000 | [diff] [blame] | 1370 | if (*plparam) |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1371 | { |
| 1372 | LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(*plparam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1373 | LPMSG msg32 = (LPMSG)HeapAlloc( SystemHeap, 0, sizeof(MSG) ); |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1374 | |
| 1375 | if (!msg32) return -1; |
| 1376 | msg32->hwnd = msg16->hwnd; |
| 1377 | msg32->lParam = msg16->lParam; |
| 1378 | msg32->time = msg16->time; |
| 1379 | CONV_POINT16TO32(&msg16->pt,&msg32->pt); |
| 1380 | /* this is right, right? */ |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 1381 | if (WINPROC_MapMsg16To32W(hwnd, msg16->message,msg16->wParam, |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1382 | &msg32->message,&msg32->wParam, |
| 1383 | &msg32->lParam)<0) { |
| 1384 | HeapFree( SystemHeap, 0, msg32 ); |
| 1385 | return -1; |
| 1386 | } |
| 1387 | *plparam = (LPARAM)msg32; |
Alexandre Julliard | 463b713 | 1998-11-01 16:23:54 +0000 | [diff] [blame] | 1388 | return 1; |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1389 | } |
Alexandre Julliard | 463b713 | 1998-11-01 16:23:54 +0000 | [diff] [blame] | 1390 | else return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1391 | default: /* No Unicode translation needed */ |
| 1392 | return WINPROC_MapMsg16To32A( msg16, wParam16, pmsg32, |
| 1393 | pwparam32, plparam ); |
| 1394 | } |
| 1395 | } |
| 1396 | |
| 1397 | |
| 1398 | /********************************************************************** |
| 1399 | * WINPROC_UnmapMsg16To32W |
| 1400 | * |
| 1401 | * Unmap a message that was mapped from 16- to 32-bit Unicode. |
| 1402 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1403 | LRESULT WINPROC_UnmapMsg16To32W( HWND16 hwnd, UINT msg, WPARAM wParam, LPARAM lParam, |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1404 | LRESULT result ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1405 | { |
| 1406 | switch(msg) |
| 1407 | { |
| 1408 | case WM_GETTEXT: |
| 1409 | case WM_SETTEXT: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 1410 | WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1411 | break; |
| 1412 | case WM_NCCREATE: |
| 1413 | case WM_CREATE: |
| 1414 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1415 | CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1416 | lParam = *(LPARAM *)(cs + 1); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1417 | STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA *)cs, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1418 | (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1419 | if (HIWORD(cs->lpszName)) |
| 1420 | HeapFree( SystemHeap, 0, (LPVOID)cs->lpszName ); |
| 1421 | if (HIWORD(cs->lpszClass)) |
| 1422 | HeapFree( SystemHeap, 0, (LPVOID)cs->lpszClass ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1423 | HeapFree( SystemHeap, 0, cs ); |
| 1424 | } |
| 1425 | break; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1426 | case WM_MDICREATE: |
| 1427 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1428 | MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1429 | lParam = *(LPARAM *)(cs + 1); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1430 | STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA *)cs, |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1431 | (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam) ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1432 | if (HIWORD(cs->szTitle)) |
| 1433 | HeapFree( SystemHeap, 0, (LPVOID)cs->szTitle ); |
| 1434 | if (HIWORD(cs->szClass)) |
| 1435 | HeapFree( SystemHeap, 0, (LPVOID)cs->szClass ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1436 | HeapFree( SystemHeap, 0, cs ); |
| 1437 | } |
| 1438 | break; |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1439 | case WM_GETDLGCODE: |
Alexandre Julliard | 463b713 | 1998-11-01 16:23:54 +0000 | [diff] [blame] | 1440 | if (lParam) |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1441 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1442 | LPMSG msg32 = (LPMSG)lParam; |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1443 | |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 1444 | WINPROC_UnmapMsg16To32W( hwnd, msg32->message, msg32->wParam, msg32->lParam, |
Ove Kaaven | 748acbb | 1998-11-01 15:27:12 +0000 | [diff] [blame] | 1445 | result); |
| 1446 | HeapFree( SystemHeap, 0, msg32 ); |
| 1447 | } |
| 1448 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1449 | default: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 1450 | return WINPROC_UnmapMsg16To32A( hwnd, msg, wParam, lParam, result ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1451 | } |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1452 | return result; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1453 | } |
| 1454 | |
| 1455 | |
| 1456 | /********************************************************************** |
| 1457 | * WINPROC_MapMsg32ATo16 |
| 1458 | * |
| 1459 | * Map a message from 32-bit Ansi to 16-bit. |
| 1460 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. |
| 1461 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1462 | INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32, WPARAM wParam32, |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1463 | UINT16 *pmsg16, WPARAM16 *pwparam16, |
| 1464 | LPARAM *plparam ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1465 | { |
| 1466 | *pmsg16 = (UINT16)msg32; |
| 1467 | *pwparam16 = (WPARAM16)LOWORD(wParam32); |
| 1468 | switch(msg32) |
| 1469 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1470 | case BM_GETCHECK: |
| 1471 | case BM_SETCHECK: |
| 1472 | case BM_GETSTATE: |
| 1473 | case BM_SETSTATE: |
| 1474 | case BM_SETSTYLE: |
| 1475 | *pmsg16 = (UINT16)msg32 + (BM_GETCHECK16 - BM_GETCHECK); |
Alexandre Julliard | 8cc3a5e | 1996-08-11 15:49:51 +0000 | [diff] [blame] | 1476 | return 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1477 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1478 | case EM_GETSEL: |
| 1479 | case EM_GETRECT: |
| 1480 | case EM_SETRECT: |
| 1481 | case EM_SETRECTNP: |
| 1482 | case EM_SCROLL: |
| 1483 | case EM_LINESCROLL: |
| 1484 | case EM_SCROLLCARET: |
| 1485 | case EM_GETMODIFY: |
| 1486 | case EM_SETMODIFY: |
| 1487 | case EM_GETLINECOUNT: |
| 1488 | case EM_LINEINDEX: |
| 1489 | case EM_SETHANDLE: |
| 1490 | case EM_GETHANDLE: |
| 1491 | case EM_GETTHUMB: |
| 1492 | case EM_LINELENGTH: |
| 1493 | case EM_REPLACESEL: |
| 1494 | case EM_GETLINE: |
| 1495 | case EM_LIMITTEXT: |
| 1496 | case EM_CANUNDO: |
| 1497 | case EM_UNDO: |
| 1498 | case EM_FMTLINES: |
| 1499 | case EM_LINEFROMCHAR: |
| 1500 | case EM_SETTABSTOPS: |
| 1501 | case EM_SETPASSWORDCHAR: |
| 1502 | case EM_EMPTYUNDOBUFFER: |
| 1503 | case EM_GETFIRSTVISIBLELINE: |
| 1504 | case EM_SETREADONLY: |
| 1505 | case EM_SETWORDBREAKPROC: |
| 1506 | case EM_GETWORDBREAKPROC: |
| 1507 | case EM_GETPASSWORDCHAR: |
| 1508 | *pmsg16 = (UINT16)msg32 + (EM_GETSEL16 - EM_GETSEL); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1509 | return 0; |
| 1510 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1511 | case LB_CARETOFF: |
| 1512 | case LB_CARETON: |
| 1513 | case LB_DELETESTRING: |
| 1514 | case LB_GETANCHORINDEX: |
| 1515 | case LB_GETCARETINDEX: |
| 1516 | case LB_GETCOUNT: |
| 1517 | case LB_GETCURSEL: |
| 1518 | case LB_GETHORIZONTALEXTENT: |
| 1519 | case LB_GETITEMDATA: |
| 1520 | case LB_GETITEMHEIGHT: |
| 1521 | case LB_GETSEL: |
| 1522 | case LB_GETSELCOUNT: |
| 1523 | case LB_GETTEXTLEN: |
| 1524 | case LB_GETTOPINDEX: |
| 1525 | case LB_RESETCONTENT: |
| 1526 | case LB_SELITEMRANGE: |
| 1527 | case LB_SELITEMRANGEEX: |
| 1528 | case LB_SETANCHORINDEX: |
| 1529 | case LB_SETCARETINDEX: |
| 1530 | case LB_SETCOLUMNWIDTH: |
| 1531 | case LB_SETCURSEL: |
| 1532 | case LB_SETHORIZONTALEXTENT: |
| 1533 | case LB_SETITEMDATA: |
| 1534 | case LB_SETITEMHEIGHT: |
| 1535 | case LB_SETSEL: |
| 1536 | case LB_SETTOPINDEX: |
| 1537 | *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1538 | return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1539 | case CB_DELETESTRING: |
| 1540 | case CB_GETCOUNT: |
| 1541 | case CB_GETLBTEXTLEN: |
| 1542 | case CB_LIMITTEXT: |
| 1543 | case CB_RESETCONTENT: |
| 1544 | case CB_SETEDITSEL: |
| 1545 | case CB_GETCURSEL: |
| 1546 | case CB_SETCURSEL: |
| 1547 | case CB_SHOWDROPDOWN: |
| 1548 | case CB_SETITEMDATA: |
| 1549 | case CB_SETITEMHEIGHT: |
| 1550 | case CB_GETITEMHEIGHT: |
| 1551 | case CB_SETEXTENDEDUI: |
| 1552 | case CB_GETEXTENDEDUI: |
| 1553 | case CB_GETDROPPEDSTATE: |
| 1554 | *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1555 | return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1556 | case CB_GETEDITSEL: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1557 | *pmsg16 = CB_GETEDITSEL16; |
| 1558 | return 1; |
| 1559 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1560 | case LB_ADDSTRING: |
| 1561 | case LB_FINDSTRING: |
| 1562 | case LB_FINDSTRINGEXACT: |
| 1563 | case LB_INSERTSTRING: |
| 1564 | case LB_SELECTSTRING: |
| 1565 | case LB_DIR: |
| 1566 | case LB_ADDFILE: |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1567 | { |
| 1568 | LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam ); |
| 1569 | if (!str) return -1; |
| 1570 | *plparam = (LPARAM)SEGPTR_GET(str); |
| 1571 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1572 | *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1573 | return 1; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1574 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1575 | case CB_ADDSTRING: |
| 1576 | case CB_FINDSTRING: |
| 1577 | case CB_FINDSTRINGEXACT: |
| 1578 | case CB_INSERTSTRING: |
| 1579 | case CB_SELECTSTRING: |
| 1580 | case CB_DIR: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1581 | { |
| 1582 | LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam ); |
| 1583 | if (!str) return -1; |
| 1584 | *plparam = (LPARAM)SEGPTR_GET(str); |
| 1585 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1586 | *pmsg16 = (UINT16)msg32 + (CB_GETEDITSEL16 - CB_GETEDITSEL); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1587 | return 1; |
| 1588 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1589 | case LB_GETITEMRECT: |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1590 | { |
| 1591 | RECT16 *rect; |
| 1592 | rect = (RECT16 *)SEGPTR_ALLOC( sizeof(RECT16) + sizeof(LPARAM) ); |
| 1593 | if (!rect) return -1; |
| 1594 | *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */ |
| 1595 | *plparam = (LPARAM)SEGPTR_GET(rect); |
| 1596 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1597 | *pmsg16 = LB_GETITEMRECT16; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1598 | return 1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1599 | case LB_GETSELITEMS: |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1600 | { |
| 1601 | LPINT16 items; |
| 1602 | *pwparam16 = (WPARAM16)MIN( wParam32, 0x7f80 ); /* Must be < 64K */ |
| 1603 | if (!(items = SEGPTR_ALLOC( *pwparam16 * sizeof(INT16) |
| 1604 | + sizeof(LPARAM)))) return -1; |
| 1605 | *((LPARAM *)items)++ = *plparam; /* Store the previous lParam */ |
| 1606 | *plparam = (LPARAM)SEGPTR_GET(items); |
| 1607 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1608 | *pmsg16 = LB_GETSELITEMS16; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1609 | return 1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1610 | case LB_SETTABSTOPS: |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1611 | if (wParam32) |
| 1612 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1613 | INT i; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1614 | LPINT16 stops; |
| 1615 | *pwparam16 = (WPARAM16)MIN( wParam32, 0x7f80 ); /* Must be < 64K */ |
| 1616 | if (!(stops = SEGPTR_ALLOC( *pwparam16 * sizeof(INT16) |
| 1617 | + sizeof(LPARAM)))) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1618 | for (i = 0; i < *pwparam16; i++) stops[i] = *((LPINT)*plparam+i); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1619 | *plparam = (LPARAM)SEGPTR_GET(stops); |
| 1620 | return 1; |
| 1621 | } |
| 1622 | *pmsg16 = LB_SETTABSTOPS16; |
| 1623 | return 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1624 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1625 | case CB_GETDROPPEDCONTROLRECT: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1626 | { |
| 1627 | RECT16 *rect; |
| 1628 | rect = (RECT16 *)SEGPTR_ALLOC( sizeof(RECT16) + sizeof(LPARAM) ); |
| 1629 | if (!rect) return -1; |
| 1630 | *(LPARAM *)(rect + 1) = *plparam; /* Store the previous lParam */ |
| 1631 | *plparam = (LPARAM)SEGPTR_GET(rect); |
| 1632 | } |
| 1633 | *pmsg16 = CB_GETDROPPEDCONTROLRECT16; |
| 1634 | return 1; |
| 1635 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1636 | case LB_GETTEXT: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1637 | *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) ); |
| 1638 | *pmsg16 = LB_GETTEXT16; |
| 1639 | return 1; |
| 1640 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1641 | case CB_GETLBTEXT: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1642 | *plparam = (LPARAM)MapLS( (LPVOID)(*plparam) ); |
| 1643 | *pmsg16 = CB_GETLBTEXT16; |
| 1644 | return 1; |
| 1645 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1646 | case EM_SETSEL: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1647 | *pwparam16 = 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1648 | *plparam = MAKELONG( (INT16)(INT)wParam32, (INT16)*plparam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1649 | *pmsg16 = EM_SETSEL16; |
| 1650 | return 0; |
| 1651 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1652 | case WM_ACTIVATE: |
| 1653 | case WM_CHARTOITEM: |
| 1654 | case WM_COMMAND: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1655 | case WM_VKEYTOITEM: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1656 | *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32) ); |
| 1657 | return 0; |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 1658 | case WM_HSCROLL: |
| 1659 | case WM_VSCROLL: |
| 1660 | *plparam = MAKELPARAM( HIWORD(wParam32), (HWND16)*plparam ); |
| 1661 | return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1662 | case WM_CTLCOLORMSGBOX: |
| 1663 | case WM_CTLCOLOREDIT: |
| 1664 | case WM_CTLCOLORLISTBOX: |
| 1665 | case WM_CTLCOLORBTN: |
| 1666 | case WM_CTLCOLORDLG: |
| 1667 | case WM_CTLCOLORSCROLLBAR: |
| 1668 | case WM_CTLCOLORSTATIC: |
| 1669 | *pmsg16 = WM_CTLCOLOR; |
| 1670 | *plparam = MAKELPARAM( (HWND16)*plparam, |
| 1671 | (WORD)msg32 - WM_CTLCOLORMSGBOX ); |
| 1672 | return 0; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1673 | case WM_COMPAREITEM: |
| 1674 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1675 | COMPAREITEMSTRUCT *cis32 = (COMPAREITEMSTRUCT *)*plparam; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1676 | COMPAREITEMSTRUCT16 *cis = SEGPTR_NEW(COMPAREITEMSTRUCT16); |
| 1677 | if (!cis) return -1; |
| 1678 | cis->CtlType = (UINT16)cis32->CtlType; |
| 1679 | cis->CtlID = (UINT16)cis32->CtlID; |
| 1680 | cis->hwndItem = (HWND16)cis32->hwndItem; |
| 1681 | cis->itemID1 = (UINT16)cis32->itemID1; |
| 1682 | cis->itemData1 = cis32->itemData1; |
| 1683 | cis->itemID2 = (UINT16)cis32->itemID2; |
| 1684 | cis->itemData2 = cis32->itemData2; |
| 1685 | *plparam = (LPARAM)SEGPTR_GET(cis); |
| 1686 | } |
| 1687 | return 1; |
| 1688 | case WM_DELETEITEM: |
| 1689 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1690 | DELETEITEMSTRUCT *dis32 = (DELETEITEMSTRUCT *)*plparam; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1691 | DELETEITEMSTRUCT16 *dis = SEGPTR_NEW(DELETEITEMSTRUCT16); |
| 1692 | if (!dis) return -1; |
| 1693 | dis->CtlType = (UINT16)dis32->CtlType; |
| 1694 | dis->CtlID = (UINT16)dis32->CtlID; |
| 1695 | dis->itemID = (UINT16)dis32->itemID; |
| 1696 | dis->hwndItem = (HWND16)dis32->hwndItem; |
| 1697 | dis->itemData = dis32->itemData; |
| 1698 | *plparam = (LPARAM)SEGPTR_GET(dis); |
| 1699 | } |
| 1700 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1701 | case WM_DRAWITEM: |
| 1702 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1703 | DRAWITEMSTRUCT *dis32 = (DRAWITEMSTRUCT *)*plparam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1704 | DRAWITEMSTRUCT16 *dis = SEGPTR_NEW(DRAWITEMSTRUCT16); |
| 1705 | if (!dis) return -1; |
| 1706 | dis->CtlType = (UINT16)dis32->CtlType; |
| 1707 | dis->CtlID = (UINT16)dis32->CtlID; |
| 1708 | dis->itemID = (UINT16)dis32->itemID; |
| 1709 | dis->itemAction = (UINT16)dis32->itemAction; |
| 1710 | dis->itemState = (UINT16)dis32->itemState; |
| 1711 | dis->hwndItem = (HWND16)dis32->hwndItem; |
| 1712 | dis->hDC = (HDC16)dis32->hDC; |
| 1713 | dis->itemData = dis32->itemData; |
| 1714 | CONV_RECT32TO16( &dis32->rcItem, &dis->rcItem ); |
| 1715 | *plparam = (LPARAM)SEGPTR_GET(dis); |
| 1716 | } |
| 1717 | return 1; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1718 | case WM_MEASUREITEM: |
| 1719 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1720 | MEASUREITEMSTRUCT *mis32 = (MEASUREITEMSTRUCT *)*plparam; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1721 | MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *) |
| 1722 | SEGPTR_ALLOC(sizeof(*mis)+sizeof(LPARAM)); |
| 1723 | if (!mis) return -1; |
| 1724 | mis->CtlType = (UINT16)mis32->CtlType; |
| 1725 | mis->CtlID = (UINT16)mis32->CtlID; |
| 1726 | mis->itemID = (UINT16)mis32->itemID; |
| 1727 | mis->itemWidth = (UINT16)mis32->itemWidth; |
| 1728 | mis->itemHeight = (UINT16)mis32->itemHeight; |
| 1729 | mis->itemData = mis32->itemData; |
| 1730 | *(LPARAM *)(mis + 1) = *plparam; /* Store the previous lParam */ |
| 1731 | *plparam = (LPARAM)SEGPTR_GET(mis); |
| 1732 | } |
| 1733 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1734 | case WM_GETMINMAXINFO: |
| 1735 | { |
| 1736 | MINMAXINFO16 *mmi = (MINMAXINFO16 *)SEGPTR_ALLOC( sizeof(*mmi) + |
| 1737 | sizeof(LPARAM) ); |
| 1738 | if (!mmi) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1739 | STRUCT32_MINMAXINFO32to16( (MINMAXINFO *)*plparam, mmi ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1740 | *(LPARAM *)(mmi + 1) = *plparam; /* Store the previous lParam */ |
| 1741 | *plparam = (LPARAM)SEGPTR_GET(mmi); |
| 1742 | } |
| 1743 | return 1; |
| 1744 | case WM_GETTEXT: |
| 1745 | { |
| 1746 | LPSTR str; |
| 1747 | *pwparam16 = (WPARAM16)MIN( wParam32, 0xff80 ); /* Must be < 64K */ |
| 1748 | if (!(str = SEGPTR_ALLOC(*pwparam16 + sizeof(LPARAM)))) return -1; |
| 1749 | *((LPARAM *)str)++ = *plparam; /* Store the previous lParam */ |
| 1750 | *plparam = (LPARAM)SEGPTR_GET(str); |
| 1751 | } |
| 1752 | return 1; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1753 | case WM_MDICREATE: |
| 1754 | { |
| 1755 | MDICREATESTRUCT16 *cs; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1756 | MDICREATESTRUCTA *cs32 = (MDICREATESTRUCTA *)*plparam; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1757 | LPSTR name, cls; |
| 1758 | |
| 1759 | if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1; |
| 1760 | STRUCT32_MDICREATESTRUCT32Ato16( cs32, cs ); |
| 1761 | name = SEGPTR_STRDUP( cs32->szTitle ); |
| 1762 | cls = SEGPTR_STRDUP( cs32->szClass ); |
| 1763 | cs->szTitle = SEGPTR_GET(name); |
| 1764 | cs->szClass = SEGPTR_GET(cls); |
| 1765 | *plparam = (LPARAM)SEGPTR_GET(cs); |
| 1766 | } |
| 1767 | return 1; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1768 | case WM_MDIGETACTIVE: |
| 1769 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1770 | case WM_MDISETMENU: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1771 | *plparam = MAKELPARAM( (HMENU16)LOWORD(wParam32), |
| 1772 | (HMENU16)LOWORD(*plparam) ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1773 | *pwparam16 = (*plparam == 0); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1774 | return 0; |
| 1775 | case WM_MENUCHAR: |
| 1776 | case WM_MENUSELECT: |
| 1777 | *plparam = MAKELPARAM( HIWORD(wParam32), (HMENU16)*plparam ); |
| 1778 | return 0; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1779 | case WM_MDIACTIVATE: |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1780 | { |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1781 | WND *tempWnd = WIN_FindWndPtr(hwnd); |
| 1782 | if( WIDGETS_IsControl(tempWnd, BIC32_MDICLIENT) ) |
| 1783 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1784 | *pwparam16 = (HWND)wParam32; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1785 | *plparam = 0; |
| 1786 | } |
| 1787 | else |
| 1788 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1789 | *pwparam16 = ((HWND)*plparam == hwnd); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1790 | *plparam = MAKELPARAM( (HWND16)LOWORD(*plparam), |
| 1791 | (HWND16)LOWORD(wParam32) ); |
| 1792 | } |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1793 | WIN_ReleaseWndPtr(tempWnd); |
| 1794 | } |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1795 | return 0; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1796 | case WM_NCCALCSIZE: |
| 1797 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1798 | NCCALCSIZE_PARAMS *nc32 = (NCCALCSIZE_PARAMS *)*plparam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1799 | NCCALCSIZE_PARAMS16 *nc = (NCCALCSIZE_PARAMS16 *)SEGPTR_ALLOC( sizeof(*nc) + sizeof(LPARAM) ); |
| 1800 | if (!nc) return -1; |
| 1801 | |
| 1802 | CONV_RECT32TO16( &nc32->rgrc[0], &nc->rgrc[0] ); |
| 1803 | if (wParam32) |
| 1804 | { |
| 1805 | WINDOWPOS16 *wp; |
| 1806 | CONV_RECT32TO16( &nc32->rgrc[1], &nc->rgrc[1] ); |
| 1807 | CONV_RECT32TO16( &nc32->rgrc[2], &nc->rgrc[2] ); |
| 1808 | if (!(wp = SEGPTR_NEW(WINDOWPOS16))) |
| 1809 | { |
| 1810 | SEGPTR_FREE(nc); |
| 1811 | return -1; |
| 1812 | } |
| 1813 | STRUCT32_WINDOWPOS32to16( nc32->lppos, wp ); |
| 1814 | nc->lppos = SEGPTR_GET(wp); |
| 1815 | } |
| 1816 | *(LPARAM *)(nc + 1) = *plparam; /* Store the previous lParam */ |
| 1817 | *plparam = (LPARAM)SEGPTR_GET(nc); |
| 1818 | } |
| 1819 | return 1; |
| 1820 | case WM_NCCREATE: |
| 1821 | case WM_CREATE: |
| 1822 | { |
| 1823 | CREATESTRUCT16 *cs; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1824 | CREATESTRUCTA *cs32 = (CREATESTRUCTA *)*plparam; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1825 | LPSTR name, cls; |
| 1826 | |
| 1827 | if (!(cs = SEGPTR_NEW(CREATESTRUCT16))) return -1; |
| 1828 | STRUCT32_CREATESTRUCT32Ato16( cs32, cs ); |
| 1829 | name = SEGPTR_STRDUP( cs32->lpszName ); |
| 1830 | cls = SEGPTR_STRDUP( cs32->lpszClass ); |
| 1831 | cs->lpszName = SEGPTR_GET(name); |
| 1832 | cs->lpszClass = SEGPTR_GET(cls); |
| 1833 | *plparam = (LPARAM)SEGPTR_GET(cs); |
| 1834 | } |
| 1835 | return 1; |
| 1836 | case WM_PARENTNOTIFY: |
| 1837 | if ((LOWORD(wParam32)==WM_CREATE) || (LOWORD(wParam32)==WM_DESTROY)) |
| 1838 | *plparam = MAKELPARAM( (HWND16)*plparam, HIWORD(wParam32)); |
| 1839 | /* else nothing to do */ |
| 1840 | return 0; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1841 | case WM_NOTIFY: |
| 1842 | *plparam = MapLS( (NMHDR *)*plparam ); /* NMHDR is already 32-bit */ |
| 1843 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1844 | case WM_SETTEXT: |
| 1845 | { |
| 1846 | LPSTR str = SEGPTR_STRDUP( (LPSTR)*plparam ); |
| 1847 | if (!str) return -1; |
| 1848 | *plparam = (LPARAM)SEGPTR_GET(str); |
| 1849 | } |
| 1850 | return 1; |
| 1851 | case WM_WINDOWPOSCHANGING: |
| 1852 | case WM_WINDOWPOSCHANGED: |
| 1853 | { |
| 1854 | WINDOWPOS16 *wp = (WINDOWPOS16 *)SEGPTR_ALLOC( sizeof(*wp) + |
| 1855 | sizeof(LPARAM) ); |
| 1856 | if (!wp) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1857 | STRUCT32_WINDOWPOS32to16( (WINDOWPOS *)*plparam, wp ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1858 | *(LPARAM *)(wp + 1) = *plparam; /* Store the previous lParam */ |
| 1859 | *plparam = (LPARAM)SEGPTR_GET(wp); |
| 1860 | } |
| 1861 | return 1; |
Rein Klazes | cb50562 | 1998-11-07 12:24:21 +0000 | [diff] [blame] | 1862 | case WM_GETDLGCODE: |
| 1863 | if (*plparam) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1864 | LPMSG msg32 = (LPMSG) *plparam; |
Rein Klazes | cb50562 | 1998-11-07 12:24:21 +0000 | [diff] [blame] | 1865 | LPMSG16 msg16 = (LPMSG16) SEGPTR_NEW( MSG16 ); |
| 1866 | |
| 1867 | if (!msg16) return -1; |
| 1868 | msg16->hwnd = msg32->hwnd; |
| 1869 | msg16->lParam = msg32->lParam; |
| 1870 | msg16->time = msg32->time; |
| 1871 | CONV_POINT32TO16(&msg32->pt,&msg16->pt); |
| 1872 | /* this is right, right? */ |
| 1873 | if (WINPROC_MapMsg32ATo16(msg32->hwnd,msg32->message,msg32->wParam, |
| 1874 | &msg16->message,&msg16->wParam, &msg16->lParam)<0) { |
| 1875 | SEGPTR_FREE( msg16 ); |
| 1876 | return -1; |
| 1877 | } |
| 1878 | *plparam = (LPARAM)SEGPTR_GET(msg16); |
| 1879 | return 1; |
| 1880 | } |
| 1881 | return 0; |
| 1882 | |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 1883 | case WM_ACTIVATEAPP: |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 1884 | if (*plparam) { |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 1885 | *plparam = (LPARAM)THREAD_IdToTEB((DWORD) *plparam)->htask16; |
Alexandre Julliard | 8da12c4 | 1999-01-17 16:55:11 +0000 | [diff] [blame] | 1886 | } |
| 1887 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1888 | case WM_ASKCBFORMATNAME: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1889 | case WM_DEVMODECHANGE: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1890 | case WM_PAINTCLIPBOARD: |
| 1891 | case WM_SIZECLIPBOARD: |
| 1892 | case WM_WININICHANGE: |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 1893 | FIXME_(msg)("message %04x needs translation\n", msg32 ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1894 | return -1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1895 | default: /* No translation needed */ |
| 1896 | return 0; |
| 1897 | } |
| 1898 | } |
| 1899 | |
| 1900 | |
| 1901 | /********************************************************************** |
| 1902 | * WINPROC_UnmapMsg32ATo16 |
| 1903 | * |
| 1904 | * Unmap a message that was mapped from 32-bit Ansi to 16-bit. |
| 1905 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1906 | void WINPROC_UnmapMsg32ATo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1907 | MSGPARAM16* p16 ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1908 | { |
| 1909 | switch(msg) |
| 1910 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1911 | case LB_ADDFILE: |
| 1912 | case LB_ADDSTRING: |
| 1913 | case LB_DIR: |
| 1914 | case LB_FINDSTRING: |
| 1915 | case LB_FINDSTRINGEXACT: |
| 1916 | case LB_INSERTSTRING: |
| 1917 | case LB_SELECTSTRING: |
| 1918 | case LB_SETTABSTOPS: |
| 1919 | case CB_ADDSTRING: |
| 1920 | case CB_FINDSTRING: |
| 1921 | case CB_FINDSTRINGEXACT: |
| 1922 | case CB_INSERTSTRING: |
| 1923 | case CB_SELECTSTRING: |
| 1924 | case CB_DIR: |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1925 | case WM_COMPAREITEM: |
| 1926 | case WM_DELETEITEM: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1927 | case WM_DRAWITEM: |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1928 | case WM_SETTEXT: |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 1929 | SEGPTR_FREE( PTR_SEG_TO_LIN(p16->lParam) ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1930 | break; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1931 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1932 | case CB_GETDROPPEDCONTROLRECT: |
| 1933 | case LB_GETITEMRECT: |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1934 | { |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 1935 | RECT16 *rect = (RECT16 *)PTR_SEG_TO_LIN(p16->lParam); |
| 1936 | p16->lParam = *(LPARAM *)(rect + 1); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1937 | CONV_RECT16TO32( rect, (RECT *)(p16->lParam)); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1938 | SEGPTR_FREE( rect ); |
| 1939 | } |
| 1940 | break; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1941 | case LB_GETSELITEMS: |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1942 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1943 | INT i; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1944 | LPINT16 items = (LPINT16)PTR_SEG_TO_LIN(lParam); |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 1945 | p16->lParam = *((LPARAM *)items - 1); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1946 | for (i = 0; i < p16->wParam; i++) *((LPINT)(p16->lParam) + i) = items[i]; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1947 | SEGPTR_FREE( (LPARAM *)items - 1 ); |
| 1948 | } |
| 1949 | break; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1950 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1951 | case CB_GETEDITSEL: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1952 | if( wParam ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1953 | *((LPUINT)(wParam)) = LOWORD(p16->lResult); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1954 | if( lParam ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1955 | *((LPUINT)(lParam)) = HIWORD(p16->lResult); /* FIXME: substract 1? */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1956 | break; |
| 1957 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1958 | case LB_GETTEXT: |
| 1959 | case CB_GETLBTEXT: |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 1960 | UnMapLS( (SEGPTR)(p16->lParam) ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1961 | break; |
| 1962 | |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1963 | case WM_MEASUREITEM: |
| 1964 | { |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 1965 | MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(p16->lParam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1966 | MEASUREITEMSTRUCT *mis32 = *(MEASUREITEMSTRUCT **)(mis + 1); |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1967 | mis32->itemWidth = mis->itemWidth; |
| 1968 | mis32->itemHeight = mis->itemHeight; |
| 1969 | SEGPTR_FREE(mis); |
| 1970 | } |
| 1971 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1972 | case WM_GETMINMAXINFO: |
| 1973 | { |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 1974 | MINMAXINFO16 *mmi = (MINMAXINFO16 *)PTR_SEG_TO_LIN(p16->lParam); |
| 1975 | p16->lParam = *(LPARAM *)(mmi + 1); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1976 | STRUCT32_MINMAXINFO16to32( mmi, (MINMAXINFO *)(p16->lParam) ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1977 | SEGPTR_FREE(mmi); |
| 1978 | } |
| 1979 | break; |
| 1980 | case WM_GETTEXT: |
| 1981 | { |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 1982 | LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam); |
| 1983 | p16->lParam = *((LPARAM *)str - 1); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1984 | lstrcpynA( (LPSTR)(p16->lParam), str, p16->wParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 1985 | SEGPTR_FREE( (LPARAM *)str - 1 ); |
| 1986 | } |
| 1987 | break; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1988 | case WM_MDICREATE: |
| 1989 | { |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 1990 | MDICREATESTRUCT16 *cs = (MDICREATESTRUCT16*)PTR_SEG_TO_LIN(p16->lParam); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 1991 | SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szTitle) ); |
| 1992 | SEGPTR_FREE( PTR_SEG_TO_LIN(cs->szClass) ); |
| 1993 | SEGPTR_FREE( cs ); |
| 1994 | } |
| 1995 | break; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1996 | case WM_MDIGETACTIVE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1997 | if (lParam) *(BOOL *)lParam = (BOOL16)HIWORD(p16->lResult); |
| 1998 | p16->lResult = (HWND)LOWORD(p16->lResult); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1999 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2000 | case WM_NCCALCSIZE: |
| 2001 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2002 | NCCALCSIZE_PARAMS *nc32; |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2003 | NCCALCSIZE_PARAMS16 *nc = (NCCALCSIZE_PARAMS16 *)PTR_SEG_TO_LIN(p16->lParam); |
| 2004 | p16->lParam = *(LPARAM *)(nc + 1); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2005 | nc32 = (NCCALCSIZE_PARAMS *)(p16->lParam); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2006 | CONV_RECT16TO32( &nc->rgrc[0], &nc32->rgrc[0] ); |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2007 | if (p16->wParam) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2008 | { |
| 2009 | CONV_RECT16TO32( &nc->rgrc[1], &nc32->rgrc[1] ); |
| 2010 | CONV_RECT16TO32( &nc->rgrc[2], &nc32->rgrc[2] ); |
| 2011 | STRUCT32_WINDOWPOS16to32( (WINDOWPOS16 *)PTR_SEG_TO_LIN(nc->lppos), |
| 2012 | nc32->lppos ); |
| 2013 | SEGPTR_FREE( PTR_SEG_TO_LIN(nc->lppos) ); |
| 2014 | } |
| 2015 | SEGPTR_FREE(nc); |
| 2016 | } |
| 2017 | break; |
| 2018 | case WM_NCCREATE: |
| 2019 | case WM_CREATE: |
| 2020 | { |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2021 | CREATESTRUCT16 *cs = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(p16->lParam); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2022 | SEGPTR_FREE( PTR_SEG_TO_LIN(cs->lpszName) ); |
| 2023 | SEGPTR_FREE( PTR_SEG_TO_LIN(cs->lpszClass) ); |
| 2024 | SEGPTR_FREE( cs ); |
| 2025 | } |
| 2026 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2027 | case WM_WINDOWPOSCHANGING: |
| 2028 | case WM_WINDOWPOSCHANGED: |
| 2029 | { |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2030 | WINDOWPOS16 *wp = (WINDOWPOS16 *)PTR_SEG_TO_LIN(p16->lParam); |
| 2031 | p16->lParam = *(LPARAM *)(wp + 1); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2032 | STRUCT32_WINDOWPOS16to32( wp, (WINDOWPOS *)p16->lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2033 | SEGPTR_FREE(wp); |
| 2034 | } |
| 2035 | break; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2036 | case WM_NOTIFY: |
| 2037 | UnMapLS(p16->lParam); |
| 2038 | break; |
Rein Klazes | cb50562 | 1998-11-07 12:24:21 +0000 | [diff] [blame] | 2039 | case WM_GETDLGCODE: |
| 2040 | if (p16->lParam) |
| 2041 | { |
| 2042 | LPMSG16 msg16 = (LPMSG16)PTR_SEG_TO_LIN(p16->lParam); |
| 2043 | MSGPARAM16 msgp16; |
| 2044 | msgp16.wParam=msg16->wParam; |
| 2045 | msgp16.lParam=msg16->lParam; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2046 | WINPROC_UnmapMsg32ATo16(((LPMSG)lParam)->hwnd, ((LPMSG)lParam)->message, |
| 2047 | ((LPMSG)lParam)->wParam, ((LPMSG)lParam)->lParam, |
Rein Klazes | cb50562 | 1998-11-07 12:24:21 +0000 | [diff] [blame] | 2048 | &msgp16 ); |
| 2049 | SEGPTR_FREE(msg16); |
| 2050 | } |
| 2051 | break; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2052 | } |
| 2053 | } |
| 2054 | |
| 2055 | |
| 2056 | /********************************************************************** |
| 2057 | * WINPROC_MapMsg32WTo16 |
| 2058 | * |
| 2059 | * Map a message from 32-bit Unicode to 16-bit. |
| 2060 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed. |
| 2061 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2062 | INT WINPROC_MapMsg32WTo16( HWND hwnd, UINT msg32, WPARAM wParam32, |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 2063 | UINT16 *pmsg16, WPARAM16 *pwparam16, |
| 2064 | LPARAM *plparam ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2065 | { |
| 2066 | switch(msg32) |
| 2067 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2068 | case LB_ADDSTRING: |
| 2069 | case LB_FINDSTRING: |
| 2070 | case LB_FINDSTRINGEXACT: |
| 2071 | case LB_INSERTSTRING: |
| 2072 | case LB_SELECTSTRING: |
| 2073 | case LB_DIR: |
| 2074 | case LB_ADDFILE: |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2075 | { |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 2076 | LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2077 | if (!str) return -1; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2078 | *pwparam16 = (WPARAM16)LOWORD(wParam32); |
| 2079 | *plparam = (LPARAM)SEGPTR_GET(str); |
| 2080 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2081 | *pmsg16 = (UINT16)msg32 + (LB_ADDSTRING16 - LB_ADDSTRING); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2082 | return 1; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2083 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2084 | case CB_ADDSTRING: |
| 2085 | case CB_FINDSTRING: |
| 2086 | case CB_FINDSTRINGEXACT: |
| 2087 | case CB_INSERTSTRING: |
| 2088 | case CB_SELECTSTRING: |
| 2089 | case CB_DIR: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2090 | { |
| 2091 | LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam ); |
| 2092 | if (!str) return -1; |
| 2093 | *pwparam16 = (WPARAM16)LOWORD(wParam32); |
| 2094 | *plparam = (LPARAM)SEGPTR_GET(str); |
| 2095 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2096 | *pmsg16 = (UINT16)msg32 + (CB_ADDSTRING16 - CB_ADDSTRING); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2097 | return 1; |
| 2098 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2099 | case WM_NCCREATE: |
| 2100 | case WM_CREATE: |
| 2101 | { |
| 2102 | CREATESTRUCT16 *cs; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2103 | CREATESTRUCTW *cs32 = (CREATESTRUCTW *)*plparam; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 2104 | LPSTR name, cls; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2105 | |
| 2106 | if (!(cs = SEGPTR_NEW(CREATESTRUCT16))) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2107 | STRUCT32_CREATESTRUCT32Ato16( (CREATESTRUCTA *)cs32, cs ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 2108 | name = SEGPTR_STRDUP_WtoA( cs32->lpszName ); |
| 2109 | cls = SEGPTR_STRDUP_WtoA( cs32->lpszClass ); |
| 2110 | cs->lpszName = SEGPTR_GET(name); |
| 2111 | cs->lpszClass = SEGPTR_GET(cls); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2112 | *pmsg16 = (UINT16)msg32; |
| 2113 | *pwparam16 = (WPARAM16)LOWORD(wParam32); |
| 2114 | *plparam = (LPARAM)SEGPTR_GET(cs); |
| 2115 | } |
| 2116 | return 1; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 2117 | case WM_MDICREATE: |
| 2118 | { |
| 2119 | MDICREATESTRUCT16 *cs; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2120 | MDICREATESTRUCTW *cs32 = (MDICREATESTRUCTW *)*plparam; |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 2121 | LPSTR name, cls; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 2122 | |
| 2123 | if (!(cs = SEGPTR_NEW(MDICREATESTRUCT16))) return -1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2124 | STRUCT32_MDICREATESTRUCT32Ato16( (MDICREATESTRUCTA *)cs32, cs ); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 2125 | name = SEGPTR_STRDUP_WtoA( cs32->szTitle ); |
| 2126 | cls = SEGPTR_STRDUP_WtoA( cs32->szClass ); |
| 2127 | cs->szTitle = SEGPTR_GET(name); |
| 2128 | cs->szClass = SEGPTR_GET(cls); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 2129 | *pmsg16 = (UINT16)msg32; |
| 2130 | *pwparam16 = (WPARAM16)LOWORD(wParam32); |
| 2131 | *plparam = (LPARAM)SEGPTR_GET(cs); |
| 2132 | } |
| 2133 | return 1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2134 | case WM_SETTEXT: |
| 2135 | { |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 2136 | LPSTR str = SEGPTR_STRDUP_WtoA( (LPWSTR)*plparam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2137 | if (!str) return -1; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2138 | *pmsg16 = (UINT16)msg32; |
| 2139 | *pwparam16 = (WPARAM16)LOWORD(wParam32); |
| 2140 | *plparam = (LPARAM)SEGPTR_GET(str); |
| 2141 | } |
| 2142 | return 1; |
| 2143 | default: /* No Unicode translation needed */ |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 2144 | return WINPROC_MapMsg32ATo16( hwnd, msg32, wParam32, pmsg16, |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2145 | pwparam16, plparam ); |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | |
| 2150 | /********************************************************************** |
| 2151 | * WINPROC_UnmapMsg32WTo16 |
| 2152 | * |
| 2153 | * Unmap a message that was mapped from 32-bit Unicode to 16-bit. |
| 2154 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2155 | void WINPROC_UnmapMsg32WTo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 2156 | MSGPARAM16* p16 ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2157 | { |
| 2158 | switch(msg) |
| 2159 | { |
| 2160 | case WM_GETTEXT: |
| 2161 | { |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2162 | LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam); |
| 2163 | p16->lParam = *((LPARAM *)str - 1); |
| 2164 | lstrcpyAtoW( (LPWSTR)(p16->lParam), str ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2165 | SEGPTR_FREE( (LPARAM *)str - 1 ); |
| 2166 | } |
| 2167 | break; |
| 2168 | default: |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2169 | WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, p16 ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2170 | break; |
| 2171 | } |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2172 | } |
| 2173 | |
| 2174 | |
| 2175 | /********************************************************************** |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2176 | * WINPROC_CallProc32ATo32W |
| 2177 | * |
| 2178 | * Call a window procedure, translating args from Ansi to Unicode. |
| 2179 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2180 | static LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd, |
| 2181 | UINT msg, WPARAM wParam, |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2182 | LPARAM lParam ) |
| 2183 | { |
| 2184 | LRESULT result; |
| 2185 | |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2186 | if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2187 | result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2188 | WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2189 | return result; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2190 | } |
| 2191 | |
| 2192 | |
| 2193 | /********************************************************************** |
| 2194 | * WINPROC_CallProc32WTo32A |
| 2195 | * |
| 2196 | * Call a window procedure, translating args from Unicode to Ansi. |
| 2197 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2198 | static LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd, |
| 2199 | UINT msg, WPARAM wParam, |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2200 | LPARAM lParam ) |
| 2201 | { |
| 2202 | LRESULT result; |
| 2203 | |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2204 | if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2205 | result = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2206 | WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2207 | return result; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2208 | } |
| 2209 | |
| 2210 | |
| 2211 | /********************************************************************** |
| 2212 | * WINPROC_CallProc16To32A |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2213 | * |
| 2214 | * Call a 32-bit window procedure, translating the 16-bit args. |
| 2215 | */ |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2216 | static LRESULT WINPROC_CallProc16To32A( WNDPROC func, HWND16 hwnd, |
| 2217 | UINT16 msg, WPARAM16 wParam, |
| 2218 | LPARAM lParam ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2219 | { |
| 2220 | LRESULT result; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2221 | UINT msg32; |
| 2222 | WPARAM wParam32; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2223 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2224 | if (WINPROC_MapMsg16To32A( msg, wParam, &msg32, &wParam32, &lParam ) == -1) |
| 2225 | return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2226 | result = WINPROC_CallWndProc( func, hwnd, msg32, wParam32, lParam ); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2227 | return WINPROC_UnmapMsg16To32A( hwnd, msg32, wParam32, lParam, result ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2228 | } |
| 2229 | |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2230 | /********************************************************************** |
| 2231 | * WINPROC_Thunk16To32A |
| 2232 | */ |
| 2233 | static LRESULT WINAPI WINPROC_Thunk16To32A( WNDPROC func, LPBYTE args ) |
| 2234 | { |
| 2235 | HWND16 hwnd = *(HWND16 *)( args+8 ); |
| 2236 | UINT16 msg = *(HWND16 *)( args+6 ); |
| 2237 | WPARAM16 wParam = *(HWND16 *)( args+4 ); |
| 2238 | LPARAM lParam = *(LPARAM *)( args+0 ); |
| 2239 | |
| 2240 | return WINPROC_CallProc16To32A( func, hwnd, msg, wParam, lParam ); |
| 2241 | } |
| 2242 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2243 | |
| 2244 | /********************************************************************** |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2245 | * WINPROC_CallProc16To32W |
| 2246 | * |
| 2247 | * Call a 32-bit window procedure, translating the 16-bit args. |
| 2248 | */ |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2249 | static LRESULT WINPROC_CallProc16To32W( WNDPROC func, HWND16 hwnd, |
| 2250 | UINT16 msg, WPARAM16 wParam, |
| 2251 | LPARAM lParam ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2252 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2253 | LRESULT result; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2254 | UINT msg32; |
| 2255 | WPARAM wParam32; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2256 | |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2257 | if (WINPROC_MapMsg16To32W( hwnd, msg, wParam, &msg32, &wParam32, &lParam ) == -1) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2258 | return 0; |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2259 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2260 | result = WINPROC_CallWndProc( func, hwnd, msg32, wParam32, lParam ); |
Francois Boisvert | d96bc15 | 1999-04-02 10:34:43 +0000 | [diff] [blame] | 2261 | |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2262 | return WINPROC_UnmapMsg16To32W( hwnd, msg32, wParam32, lParam, result ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2263 | } |
| 2264 | |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2265 | /********************************************************************** |
| 2266 | * WINPROC_Thunk16To32W |
| 2267 | */ |
| 2268 | static LRESULT WINAPI WINPROC_Thunk16To32W( WNDPROC func, LPBYTE args ) |
| 2269 | { |
| 2270 | HWND16 hwnd = *(HWND16 *)( args+8 ); |
| 2271 | UINT16 msg = *(HWND16 *)( args+6 ); |
| 2272 | WPARAM16 wParam = *(HWND16 *)( args+4 ); |
| 2273 | LPARAM lParam = *(LPARAM *)( args+0 ); |
| 2274 | |
| 2275 | return WINPROC_CallProc16To32W( func, hwnd, msg, wParam, lParam ); |
| 2276 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2277 | |
| 2278 | /********************************************************************** |
| 2279 | * WINPROC_CallProc32ATo16 |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2280 | * |
| 2281 | * Call a 16-bit window procedure, translating the 32-bit args. |
| 2282 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2283 | static LRESULT WINAPI WINPROC_CallProc32ATo16( WNDPROC16 func, HWND hwnd, |
| 2284 | UINT msg, WPARAM wParam, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 2285 | LPARAM lParam ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2286 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2287 | UINT16 msg16; |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2288 | MSGPARAM16 mp16; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2289 | |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2290 | mp16.lParam = lParam; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 2291 | if (WINPROC_MapMsg32ATo16( hwnd, msg, wParam, |
| 2292 | &msg16, &mp16.wParam, &mp16.lParam ) == -1) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2293 | return 0; |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2294 | mp16.lResult = WINPROC_CallWndProc16( func, hwnd, msg16, |
| 2295 | mp16.wParam, mp16.lParam ); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2296 | WINPROC_UnmapMsg32ATo16( hwnd, msg, wParam, lParam, &mp16 ); |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2297 | return mp16.lResult; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | |
| 2301 | /********************************************************************** |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2302 | * WINPROC_CallProc32WTo16 |
| 2303 | * |
| 2304 | * Call a 16-bit window procedure, translating the 32-bit args. |
| 2305 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2306 | static LRESULT WINAPI WINPROC_CallProc32WTo16( WNDPROC16 func, HWND hwnd, |
| 2307 | UINT msg, WPARAM wParam, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 2308 | LPARAM lParam ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2309 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2310 | UINT16 msg16; |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2311 | MSGPARAM16 mp16; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2312 | |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2313 | mp16.lParam = lParam; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 2314 | if (WINPROC_MapMsg32WTo16( hwnd, msg, wParam, &msg16, &mp16.wParam, |
| 2315 | &mp16.lParam ) == -1) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2316 | return 0; |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2317 | mp16.lResult = WINPROC_CallWndProc16( func, hwnd, msg16, |
| 2318 | mp16.wParam, mp16.lParam ); |
Juergen Schmied | fdf6aa4 | 1998-11-08 16:28:49 +0000 | [diff] [blame] | 2319 | WINPROC_UnmapMsg32WTo16( hwnd, msg, wParam, lParam, &mp16 ); |
Alexandre Julliard | 889f742 | 1997-04-15 17:19:52 +0000 | [diff] [blame] | 2320 | return mp16.lResult; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2321 | } |
| 2322 | |
| 2323 | |
| 2324 | /********************************************************************** |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2325 | * CallWindowProc16 (USER.122) |
| 2326 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2327 | LRESULT WINAPI CallWindowProc16( WNDPROC16 func, HWND16 hwnd, UINT16 msg, |
| 2328 | WPARAM16 wParam, LPARAM lParam ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2329 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2330 | WINDOWPROC *proc = WINPROC_GetPtr( func ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2331 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2332 | if (!proc) |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2333 | return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 2334 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2335 | #if testing |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 2336 | func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_16 ); |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2337 | return WINPROC_CallWndProc16( func, hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2338 | #endif |
| 2339 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2340 | switch(proc->type) |
| 2341 | { |
| 2342 | case WIN_PROC_16: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2343 | if (!proc->thunk.t_from32.proc) return 0; |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2344 | return WINPROC_CallWndProc16( proc->thunk.t_from32.proc, |
| 2345 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2346 | case WIN_PROC_32A: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2347 | if (!proc->thunk.t_from16.proc) return 0; |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2348 | return WINPROC_CallProc16To32A( proc->thunk.t_from16.proc, |
| 2349 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2350 | case WIN_PROC_32W: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2351 | if (!proc->thunk.t_from16.proc) return 0; |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 2352 | return WINPROC_CallProc16To32W( proc->thunk.t_from16.proc, |
| 2353 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2354 | default: |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 2355 | WARN_(relay)("Invalid proc %p\n", proc ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2356 | return 0; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2357 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2358 | } |
| 2359 | |
| 2360 | |
| 2361 | /********************************************************************** |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2362 | * CallWindowProc32A (USER32.18) |
| 2363 | * |
| 2364 | * The CallWindowProc() function invokes the windows procedure _func_, |
| 2365 | * with _hwnd_ as the target window, the message specified by _msg_, and |
| 2366 | * the message parameters _wParam_ and _lParam_. |
| 2367 | * |
| 2368 | * Some kinds of argument conversion may be done, I'm not sure what. |
| 2369 | * |
| 2370 | * CallWindowProc() may be used for windows subclassing. Use |
| 2371 | * SetWindowLong() to set a new windows procedure for windows of the |
| 2372 | * subclass, and handle subclassed messages in the new windows |
| 2373 | * procedure. The new windows procedure may then use CallWindowProc() |
| 2374 | * with _func_ set to the parent class's windows procedure to dispatch |
| 2375 | * the message to the superclass. |
| 2376 | * |
| 2377 | * RETURNS |
| 2378 | * |
| 2379 | * The return value is message dependent. |
| 2380 | * |
| 2381 | * CONFORMANCE |
| 2382 | * |
| 2383 | * ECMA-234, Win32 |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2384 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2385 | LRESULT WINAPI CallWindowProcA( |
| 2386 | WNDPROC func, /* window procedure */ |
| 2387 | HWND hwnd, /* target window */ |
| 2388 | UINT msg, /* message */ |
| 2389 | WPARAM wParam, /* message dependent parameter */ |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2390 | LPARAM lParam /* message dependent parameter */ |
| 2391 | ) { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2392 | WINDOWPROC *proc = WINPROC_GetPtr( (WNDPROC16)func ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2393 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2394 | if (!proc) return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2395 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2396 | #if testing |
| 2397 | func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_32A ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2398 | return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2399 | #endif |
| 2400 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2401 | switch(proc->type) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2402 | { |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2403 | case WIN_PROC_16: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2404 | if (!proc->thunk.t_from32.proc) return 0; |
| 2405 | return WINPROC_CallProc32ATo16( proc->thunk.t_from32.proc, |
| 2406 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2407 | case WIN_PROC_32A: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2408 | if (!proc->thunk.t_from16.proc) return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2409 | return WINPROC_CallWndProc( proc->thunk.t_from16.proc, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 2410 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2411 | case WIN_PROC_32W: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2412 | if (!proc->thunk.t_from16.proc) return 0; |
| 2413 | return WINPROC_CallProc32ATo32W( proc->thunk.t_from16.proc, |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2414 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2415 | default: |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 2416 | WARN_(relay)("Invalid proc %p\n", proc ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2417 | return 0; |
| 2418 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2419 | } |
| 2420 | |
| 2421 | |
| 2422 | /********************************************************************** |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 2423 | * CallWindowProc32W (USER32.19) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2424 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2425 | LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg, |
| 2426 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2427 | { |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2428 | WINDOWPROC *proc = WINPROC_GetPtr( (WNDPROC16)func ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2429 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2430 | if (!proc) return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2431 | |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2432 | #if testing |
| 2433 | func = WINPROC_GetProc( (HWINDOWPROC)proc, WIN_PROC_32W ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2434 | return WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2435 | #endif |
| 2436 | |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2437 | switch(proc->type) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2438 | { |
| 2439 | case WIN_PROC_16: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2440 | if (!proc->thunk.t_from32.proc) return 0; |
| 2441 | return WINPROC_CallProc32WTo16( proc->thunk.t_from32.proc, |
| 2442 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2443 | case WIN_PROC_32A: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2444 | if (!proc->thunk.t_from16.proc) return 0; |
| 2445 | return WINPROC_CallProc32WTo32A( proc->thunk.t_from16.proc, |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 2446 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2447 | case WIN_PROC_32W: |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2448 | if (!proc->thunk.t_from16.proc) return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2449 | return WINPROC_CallWndProc( proc->thunk.t_from16.proc, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 2450 | hwnd, msg, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2451 | default: |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 2452 | WARN_(relay)("Invalid proc %p\n", proc ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2453 | return 0; |
| 2454 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2455 | } |