1 | /* $Id: windowmsg.cpp,v 1.2 1999-10-30 09:19:47 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 window message APIs for OS/2
|
---|
4 | *
|
---|
5 | * Copyright 1999 Sander van Leeuwen
|
---|
6 | *
|
---|
7 | * Parts based on Wine Windows code (windows\message.c) 990508
|
---|
8 | *
|
---|
9 | * Copyright 1993, 1994 Alexandre Julliard
|
---|
10 | *
|
---|
11 | *
|
---|
12 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
13 | *
|
---|
14 | */
|
---|
15 | #include <os2win.h>
|
---|
16 | #include <misc.h>
|
---|
17 | #include <win32wbase.h>
|
---|
18 | #include <win.h>
|
---|
19 | #include <hooks.h>
|
---|
20 | #include <heapstring.h>
|
---|
21 | #include "oslibwin.h"
|
---|
22 | #include "oslibmsg.h"
|
---|
23 |
|
---|
24 | //******************************************************************************
|
---|
25 | //******************************************************************************
|
---|
26 | VOID WIN32API PostQuitMessage( int nExitCode)
|
---|
27 | {
|
---|
28 | dprintf(("USER32: PostQuitMessage\n"));
|
---|
29 | OSLibWinPostQuitMessage(nExitCode);
|
---|
30 | }
|
---|
31 | //******************************************************************************
|
---|
32 | //******************************************************************************
|
---|
33 | LONG WIN32API DispatchMessageA(const MSG * msg)
|
---|
34 | {
|
---|
35 | return OSLibWinDispatchMsg((MSG *)msg);
|
---|
36 | }
|
---|
37 | //******************************************************************************
|
---|
38 | //******************************************************************************
|
---|
39 | LONG WIN32API DispatchMessageW( const MSG * msg)
|
---|
40 | {
|
---|
41 | return OSLibWinDispatchMsg((MSG *)msg, TRUE);
|
---|
42 | }
|
---|
43 | //******************************************************************************
|
---|
44 | //******************************************************************************
|
---|
45 | BOOL WIN32API TranslateMessage( const MSG * arg1)
|
---|
46 | {
|
---|
47 | // return O32_TranslateMessage(arg1);
|
---|
48 | return TRUE;
|
---|
49 | }
|
---|
50 | //******************************************************************************
|
---|
51 | //******************************************************************************
|
---|
52 | BOOL WIN32API GetMessageA( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax)
|
---|
53 | {
|
---|
54 | return OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax);
|
---|
55 | }
|
---|
56 | //******************************************************************************
|
---|
57 | //******************************************************************************
|
---|
58 | BOOL WIN32API GetMessageW( LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax)
|
---|
59 | {
|
---|
60 | return OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, TRUE);
|
---|
61 | }
|
---|
62 | //******************************************************************************
|
---|
63 | //******************************************************************************
|
---|
64 | BOOL WIN32API PeekMessageA(LPMSG msg, HWND hwndOwner, UINT uMsgFilterMin,
|
---|
65 | UINT uMsgFilterMax, UINT fuRemoveMsg)
|
---|
66 | {
|
---|
67 | BOOL fFoundMsg;
|
---|
68 |
|
---|
69 | fFoundMsg = OSLibWinPeekMsg(msg, 0, uMsgFilterMin, uMsgFilterMax,
|
---|
70 | (fuRemoveMsg & PM_REMOVE) ? 1 : 0, FALSE);
|
---|
71 | if(fFoundMsg) {
|
---|
72 | if (msg->message == WM_QUIT && (fuRemoveMsg & (PM_REMOVE))) {
|
---|
73 | //TODO: Post WM_QUERYENDSESSION message when WM_QUIT received and system is shutting down
|
---|
74 | }
|
---|
75 | }
|
---|
76 | return fFoundMsg;
|
---|
77 | }
|
---|
78 | //******************************************************************************
|
---|
79 | //******************************************************************************
|
---|
80 | BOOL WIN32API PeekMessageW(LPMSG msg, HWND hwndOwner, UINT uMsgFilterMin,
|
---|
81 | UINT uMsgFilterMax, UINT fuRemoveMsg)
|
---|
82 | {
|
---|
83 | BOOL fFoundMsg;
|
---|
84 |
|
---|
85 | fFoundMsg = OSLibWinPeekMsg(msg, 0, uMsgFilterMin, uMsgFilterMax,
|
---|
86 | (fuRemoveMsg & PM_REMOVE) ? 1 : 0, FALSE);
|
---|
87 | if(fFoundMsg) {
|
---|
88 | if (msg->message == WM_QUIT && (fuRemoveMsg & (PM_REMOVE))) {
|
---|
89 | //TODO: Post WM_QUERYENDSESSION message when WM_QUIT received and system is shutting down
|
---|
90 | }
|
---|
91 | }
|
---|
92 | return fFoundMsg;
|
---|
93 | }
|
---|
94 | //******************************************************************************
|
---|
95 | //******************************************************************************
|
---|
96 | LONG WIN32API GetMessageExtraInfo(void)
|
---|
97 | {
|
---|
98 | dprintf(("USER32: GetMessageExtraInfo\n"));
|
---|
99 | return O32_GetMessageExtraInfo();
|
---|
100 | }
|
---|
101 | //******************************************************************************
|
---|
102 | //******************************************************************************
|
---|
103 | DWORD WIN32API GetMessagePos(void)
|
---|
104 | {
|
---|
105 | dprintf(("USER32: GetMessagePos\n"));
|
---|
106 | return O32_GetMessagePos();
|
---|
107 | }
|
---|
108 | //******************************************************************************
|
---|
109 | //******************************************************************************
|
---|
110 | LONG WIN32API GetMessageTime(void)
|
---|
111 | {
|
---|
112 | dprintf(("USER32: GetMessageTime\n"));
|
---|
113 | return O32_GetMessageTime();
|
---|
114 | }
|
---|
115 | //******************************************************************************
|
---|
116 | //TODO: hwnd == HWND_BROADCAST
|
---|
117 | //******************************************************************************
|
---|
118 | LRESULT WIN32API SendMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
119 | {
|
---|
120 | Win32BaseWindow *window;
|
---|
121 |
|
---|
122 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
123 | if(!window) {
|
---|
124 | dprintf(("SendMessageA, window %x not found", hwnd));
|
---|
125 | return 0;
|
---|
126 | }
|
---|
127 | return window->SendMessageA(msg, wParam, lParam);
|
---|
128 | }
|
---|
129 | //******************************************************************************
|
---|
130 | //TODO: hwnd == HWND_BROADCAST
|
---|
131 | //******************************************************************************
|
---|
132 | LRESULT WIN32API SendMessageW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
133 | {
|
---|
134 | Win32BaseWindow *window;
|
---|
135 |
|
---|
136 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
137 | if(!window) {
|
---|
138 | dprintf(("SendMessageW, window %x not found", hwnd));
|
---|
139 | return 0;
|
---|
140 | }
|
---|
141 | return window->SendMessageW(msg, wParam, lParam);
|
---|
142 | }
|
---|
143 | //******************************************************************************
|
---|
144 | //TODO: hwnd == HWND_BROADCAST
|
---|
145 | //******************************************************************************
|
---|
146 | BOOL WIN32API PostMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
147 | {
|
---|
148 | Win32BaseWindow *window;
|
---|
149 |
|
---|
150 | if(hwnd == NULL)
|
---|
151 | return PostThreadMessageA(GetCurrentThreadId(), msg, wParam, lParam);
|
---|
152 |
|
---|
153 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
154 | if(!window) {
|
---|
155 | dprintf(("PostMessageA, window %x not found", hwnd));
|
---|
156 | return 0;
|
---|
157 | }
|
---|
158 | dprintf(("PostMessageA, %x %x %x %x", hwnd, msg, wParam, lParam));
|
---|
159 | return window->PostMessageA(msg, wParam, lParam);
|
---|
160 | }
|
---|
161 | //******************************************************************************
|
---|
162 | //TODO: hwnd == HWND_BROADCAST
|
---|
163 | //******************************************************************************
|
---|
164 | BOOL WIN32API PostMessageW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
165 | {
|
---|
166 | Win32BaseWindow *window;
|
---|
167 |
|
---|
168 | if(hwnd == NULL)
|
---|
169 | return PostThreadMessageW(GetCurrentThreadId(), msg, wParam, lParam);
|
---|
170 |
|
---|
171 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
172 | if(!window) {
|
---|
173 | dprintf(("PostMessageW, window %x not found", hwnd));
|
---|
174 | return 0;
|
---|
175 | }
|
---|
176 | dprintf(("PostMessageW, %x %x %x %x", hwnd, msg, wParam, lParam));
|
---|
177 | return window->PostMessageW(msg, wParam, lParam);
|
---|
178 | }
|
---|
179 | //******************************************************************************
|
---|
180 | //******************************************************************************
|
---|
181 | BOOL WIN32API WaitMessage(void)
|
---|
182 | {
|
---|
183 | #ifdef DEBUG
|
---|
184 | WriteLog("USER32: WaitMessage\n");
|
---|
185 | #endif
|
---|
186 | return O32_WaitMessage();
|
---|
187 | }
|
---|
188 | //******************************************************************************
|
---|
189 | //******************************************************************************
|
---|
190 | BOOL WIN32API InSendMessage(void)
|
---|
191 | {
|
---|
192 | #ifdef DEBUG
|
---|
193 | WriteLog("USER32: InSendMessage\n");
|
---|
194 | #endif
|
---|
195 | return O32_InSendMessage();
|
---|
196 | }
|
---|
197 | //******************************************************************************
|
---|
198 | //******************************************************************************
|
---|
199 | //******************************************************************************
|
---|
200 | BOOL WIN32API ReplyMessage( LRESULT arg1)
|
---|
201 | {
|
---|
202 | #ifdef DEBUG
|
---|
203 | WriteLog("USER32: ReplyMessage\n");
|
---|
204 | #endif
|
---|
205 | return O32_ReplyMessage(arg1);
|
---|
206 | }
|
---|
207 | //******************************************************************************
|
---|
208 | //******************************************************************************
|
---|
209 | BOOL WIN32API PostThreadMessageA( DWORD arg1, UINT arg2, WPARAM arg3, LPARAM arg4)
|
---|
210 | {
|
---|
211 | #ifdef DEBUG
|
---|
212 | WriteLog("USER32: PostThreadMessageA\n");
|
---|
213 | #endif
|
---|
214 | return O32_PostThreadMessage(arg1, arg2, arg3, arg4);
|
---|
215 | }
|
---|
216 | //******************************************************************************
|
---|
217 | //******************************************************************************
|
---|
218 | BOOL WIN32API PostThreadMessageW( DWORD arg1, UINT arg2, WPARAM arg3, LPARAM arg4)
|
---|
219 | {
|
---|
220 | #ifdef DEBUG
|
---|
221 | WriteLog("USER32: PostThreadMessageW\n");
|
---|
222 | #endif
|
---|
223 | // NOTE: This will not work as is (needs UNICODE support)
|
---|
224 | return O32_PostThreadMessage(arg1, arg2, arg3, arg4);
|
---|
225 | }
|
---|
226 | //******************************************************************************
|
---|
227 | //SvL: 24-6-'97 - Added
|
---|
228 | //******************************************************************************
|
---|
229 | UINT WIN32API RegisterWindowMessageA(LPCSTR arg1)
|
---|
230 | {
|
---|
231 | UINT rc;
|
---|
232 |
|
---|
233 | rc = O32_RegisterWindowMessage(arg1);
|
---|
234 | #ifdef DEBUG
|
---|
235 | WriteLog("USER32: RegisterWindowMessageA %s returned %X\n", arg1, rc);
|
---|
236 | #endif
|
---|
237 | return(rc);
|
---|
238 | }
|
---|
239 | //******************************************************************************
|
---|
240 | //******************************************************************************
|
---|
241 | UINT WIN32API RegisterWindowMessageW( LPCWSTR arg1)
|
---|
242 | {
|
---|
243 | char *astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
244 | UINT rc;
|
---|
245 |
|
---|
246 | #ifdef DEBUG
|
---|
247 | WriteLog("USER32: RegisterWindowMessageW\n");
|
---|
248 | #endif
|
---|
249 | rc = O32_RegisterWindowMessage(astring);
|
---|
250 | FreeAsciiString(astring);
|
---|
251 | return rc;
|
---|
252 | }
|
---|
253 | //******************************************************************************
|
---|
254 | //No need to support this
|
---|
255 | //******************************************************************************
|
---|
256 | BOOL WIN32API SetMessageQueue(int cMessagesMax)
|
---|
257 | {
|
---|
258 | #ifdef DEBUG
|
---|
259 | WriteLog("USER32: SetMessageQueue\n");
|
---|
260 | #endif
|
---|
261 | return(TRUE);
|
---|
262 | }
|
---|
263 | //******************************************************************************
|
---|
264 | //******************************************************************************
|
---|
265 | LRESULT WIN32API SendMessageTimeoutA(HWND hwnd, UINT Msg, WPARAM wParam,
|
---|
266 | LPARAM lParam, UINT fuFlags, UINT uTimeOut,
|
---|
267 | LPDWORD lpdwResult)
|
---|
268 | {
|
---|
269 | #ifdef DEBUG
|
---|
270 | WriteLog("USER32: SendMessageTimeoutA, partially implemented\n");
|
---|
271 | #endif
|
---|
272 | //ignore fuFlags & wTimeOut
|
---|
273 | *lpdwResult = SendMessageA(hwnd, Msg, wParam, lParam);
|
---|
274 | return(TRUE);
|
---|
275 | }
|
---|
276 | //******************************************************************************
|
---|
277 | //******************************************************************************
|
---|
278 | LRESULT WIN32API SendMessageTimeoutW(HWND hwnd, UINT Msg, WPARAM wParam,
|
---|
279 | LPARAM lParam, UINT fuFlags, UINT uTimeOut,
|
---|
280 | LPDWORD lpdwResult)
|
---|
281 | {
|
---|
282 | #ifdef DEBUG
|
---|
283 | WriteLog("USER32: SendMessageTimeoutW, partially implemented\n");
|
---|
284 | #endif
|
---|
285 | return(SendMessageTimeoutA(hwnd, Msg, wParam, lParam, fuFlags, uTimeOut, lpdwResult));
|
---|
286 | }
|
---|
287 | //******************************************************************************
|
---|
288 | //******************************************************************************
|
---|
289 | BOOL WIN32API SendNotifyMessageA(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
290 | {
|
---|
291 | #ifdef DEBUG
|
---|
292 | WriteLog("USER32: SendNotifyMessageA, not completely implemented\n");
|
---|
293 | #endif
|
---|
294 | return(SendMessageA(hwnd, Msg, wParam, lParam));
|
---|
295 | }
|
---|
296 | //******************************************************************************
|
---|
297 | //******************************************************************************
|
---|
298 | BOOL WIN32API SendNotifyMessageW(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
299 | {
|
---|
300 | #ifdef DEBUG
|
---|
301 | WriteLog("USER32: SendNotifyMessageW, not completely implemented\n");
|
---|
302 | #endif
|
---|
303 | return(SendMessageA(hwnd, Msg, wParam, lParam));
|
---|
304 | }
|
---|
305 | //******************************************************************************
|
---|
306 | //******************************************************************************
|
---|
307 | LPARAM WIN32API SetMessageExtraInfo(LPARAM lParam)
|
---|
308 | {
|
---|
309 | #ifdef DEBUG
|
---|
310 | WriteLog("USER32: SetMessageExtraInfo, not implemented\n");
|
---|
311 | #endif
|
---|
312 | return(0);
|
---|
313 | }
|
---|
314 | /*****************************************************************************
|
---|
315 | * Name : BOOL WIN32API SendMessageCallbackA
|
---|
316 | * Purpose : The SendMessageCallback function sends the specified message to
|
---|
317 | * a window or windows. The function calls the window procedure for
|
---|
318 | * the specified window and returns immediately. After the window
|
---|
319 | * procedure processes the message, the system calls the specified
|
---|
320 | * callback function, passing the result of the message processing
|
---|
321 | * and an application-defined value to the callback function.
|
---|
322 | * Parameters: HWND hwnd handle of destination window
|
---|
323 | * UINT uMsg message to send
|
---|
324 | * WPARAM wParam first message parameter
|
---|
325 | * LPARAM lParam second message parameter
|
---|
326 | * SENDASYNCPROC lpResultCallBack function to receive message value
|
---|
327 | * DWORD dwData value to pass to callback function
|
---|
328 | * Variables :
|
---|
329 | * Result : If the function succeeds, the return value is TRUE.
|
---|
330 | * If the function fails, the return value is FALSE. To get extended
|
---|
331 | * error information, call GetLastError.
|
---|
332 | * Remark :
|
---|
333 | * Status : UNTESTED STUB
|
---|
334 | *
|
---|
335 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
336 | *****************************************************************************/
|
---|
337 |
|
---|
338 | BOOL WIN32API SendMessageCallbackA(HWND hWnd,
|
---|
339 | UINT uMsg,
|
---|
340 | WPARAM wParam,
|
---|
341 | LPARAM lParam,
|
---|
342 | SENDASYNCPROC lpResultCallBack,
|
---|
343 | DWORD dwData)
|
---|
344 | {
|
---|
345 | dprintf(("USER32:SendMessageCallBackA (%08xh,%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n",
|
---|
346 | hWnd,
|
---|
347 | uMsg,
|
---|
348 | wParam,
|
---|
349 | lParam,
|
---|
350 | lpResultCallBack,
|
---|
351 | dwData));
|
---|
352 |
|
---|
353 | return (FALSE);
|
---|
354 | }
|
---|
355 |
|
---|
356 |
|
---|
357 | /*****************************************************************************
|
---|
358 | * Name : BOOL WIN32API SendMessageCallbackW
|
---|
359 | * Purpose : The SendMessageCallback function sends the specified message to
|
---|
360 | * a window or windows. The function calls the window procedure for
|
---|
361 | * the specified window and returns immediately. After the window
|
---|
362 | * procedure processes the message, the system calls the specified
|
---|
363 | * callback function, passing the result of the message processing
|
---|
364 | * and an application-defined value to the callback function.
|
---|
365 | * Parameters: HWND hwnd handle of destination window
|
---|
366 | * UINT uMsg message to send
|
---|
367 | * WPARAM wParam first message parameter
|
---|
368 | * LPARAM lParam second message parameter
|
---|
369 | * SENDASYNCPROC lpResultCallBack function to receive message value
|
---|
370 | * DWORD dwData value to pass to callback function
|
---|
371 | * Variables :
|
---|
372 | * Result : If the function succeeds, the return value is TRUE.
|
---|
373 | * If the function fails, the return value is FALSE. To get extended
|
---|
374 | * error information, call GetLastError.
|
---|
375 | * Remark :
|
---|
376 | * Status : UNTESTED STUB
|
---|
377 | *
|
---|
378 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
379 | *****************************************************************************/
|
---|
380 |
|
---|
381 | BOOL WIN32API SendMessageCallbackW(HWND hWnd,
|
---|
382 | UINT uMsg,
|
---|
383 | WPARAM wParam,
|
---|
384 | LPARAM lParam,
|
---|
385 | SENDASYNCPROC lpResultCallBack,
|
---|
386 | DWORD dwData)
|
---|
387 | {
|
---|
388 | dprintf(("USER32:SendMessageCallBackW (%08xh,%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n",
|
---|
389 | hWnd,
|
---|
390 | uMsg,
|
---|
391 | wParam,
|
---|
392 | lParam,
|
---|
393 | lpResultCallBack,
|
---|
394 | dwData));
|
---|
395 |
|
---|
396 | return (FALSE);
|
---|
397 | }
|
---|
398 | /*****************************************************************************
|
---|
399 | * Name : long WIN32API BroadcastSystemMessage
|
---|
400 | * Purpose : The BroadcastSystemMessage function sends a message to the given
|
---|
401 | * recipients. The recipients can be applications, installable
|
---|
402 | * drivers, Windows-based network drivers, system-level device
|
---|
403 | * drivers, or any combination of these system components.
|
---|
404 | * Parameters: DWORD dwFlags,
|
---|
405 | LPDWORD lpdwRecipients,
|
---|
406 | UINT uiMessage,
|
---|
407 | WPARAM wParam,
|
---|
408 | LPARAM lParam
|
---|
409 | * Variables :
|
---|
410 | * Result : If the function succeeds, the return value is a positive value.
|
---|
411 | * If the function is unable to broadcast the message, the return value is -1.
|
---|
412 | * If the dwFlags parameter is BSF_QUERY and at least one recipient returned FALSE to the corresponding message, the return value is zero.
|
---|
413 | * Remark :
|
---|
414 | * Status : UNTESTED STUB
|
---|
415 | *
|
---|
416 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
417 | *****************************************************************************/
|
---|
418 |
|
---|
419 | long WIN32API BroadcastSystemMessage(DWORD dwFlags,
|
---|
420 | LPDWORD lpdwRecipients,
|
---|
421 | UINT uiMessage,
|
---|
422 | WPARAM wParam,
|
---|
423 | LPARAM lParam)
|
---|
424 | {
|
---|
425 | dprintf(("USER32:BroadcastSystemMessage(%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n",
|
---|
426 | dwFlags,
|
---|
427 | lpdwRecipients,
|
---|
428 | uiMessage,
|
---|
429 | wParam,
|
---|
430 | lParam));
|
---|
431 |
|
---|
432 | return (-1);
|
---|
433 | }
|
---|
434 | //******************************************************************************
|
---|
435 | //******************************************************************************
|
---|
436 | /**********************************************************************
|
---|
437 | * WINPROC_TestCBForStr
|
---|
438 | *
|
---|
439 | * Return TRUE if the lparam is a string
|
---|
440 | */
|
---|
441 | BOOL WINPROC_TestCBForStr ( HWND hwnd )
|
---|
442 | {
|
---|
443 | BOOL retvalue;
|
---|
444 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
445 | retvalue = ( !(LOWORD(dwStyle) & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ||
|
---|
446 | (LOWORD(dwStyle) & CBS_HASSTRINGS) );
|
---|
447 | return retvalue;
|
---|
448 | }
|
---|
449 | /**********************************************************************
|
---|
450 | * WINPROC_TestLBForStr
|
---|
451 | *
|
---|
452 | * Return TRUE if the lparam is a string
|
---|
453 | */
|
---|
454 | BOOL WINPROC_TestLBForStr ( HWND hwnd )
|
---|
455 | {
|
---|
456 | BOOL retvalue;
|
---|
457 | DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
|
---|
458 | retvalue = ( !(LOWORD(dwStyle) & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) ||
|
---|
459 | (LOWORD(dwStyle) & LBS_HASSTRINGS) );
|
---|
460 | return retvalue;
|
---|
461 | }
|
---|
462 |
|
---|
463 | /**********************************************************************
|
---|
464 | * WINPROC_MapMsg32ATo32W
|
---|
465 | *
|
---|
466 | * Map a message from Ansi to Unicode.
|
---|
467 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
|
---|
468 | *
|
---|
469 | * FIXME:
|
---|
470 | * WM_CHAR, WM_CHARTOITEM, WM_DEADCHAR, WM_MENUCHAR, WM_SYSCHAR, WM_SYSDEADCHAR
|
---|
471 | *
|
---|
472 | * FIXME:
|
---|
473 | * WM_GETTEXT/WM_SETTEXT and static control with SS_ICON style:
|
---|
474 | * the first four bytes are the handle of the icon
|
---|
475 | * when the WM_SETTEXT message has been used to set the icon
|
---|
476 | */
|
---|
477 | INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam )
|
---|
478 | {
|
---|
479 | switch(msg)
|
---|
480 | {
|
---|
481 | case WM_GETTEXT:
|
---|
482 | {
|
---|
483 | LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
|
---|
484 | wParam * sizeof(WCHAR) + sizeof(LPARAM) );
|
---|
485 | if (!ptr) return -1;
|
---|
486 | *ptr++ = *plparam; /* Store previous lParam */
|
---|
487 | *plparam = (LPARAM)ptr;
|
---|
488 | }
|
---|
489 | return 1;
|
---|
490 | /* lparam is string (0-terminated) */
|
---|
491 | case WM_SETTEXT:
|
---|
492 | case WM_WININICHANGE:
|
---|
493 | case CB_DIR:
|
---|
494 | case CB_FINDSTRING:
|
---|
495 | case CB_FINDSTRINGEXACT:
|
---|
496 | case CB_SELECTSTRING:
|
---|
497 | case LB_DIR:
|
---|
498 | case LB_ADDFILE:
|
---|
499 | case LB_FINDSTRING:
|
---|
500 | case LB_SELECTSTRING:
|
---|
501 | case EM_REPLACESEL:
|
---|
502 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
|
---|
503 | return (*plparam ? 1 : -1);
|
---|
504 |
|
---|
505 | case WM_NCCREATE:
|
---|
506 | case WM_CREATE:
|
---|
507 | {
|
---|
508 | CREATESTRUCTW *cs = (CREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0,
|
---|
509 | sizeof(*cs) );
|
---|
510 | if (!cs) return -1;
|
---|
511 | *cs = *(CREATESTRUCTW *)*plparam;
|
---|
512 | if (HIWORD(cs->lpszName))
|
---|
513 | cs->lpszName = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
---|
514 | (LPCSTR)cs->lpszName );
|
---|
515 | if (HIWORD(cs->lpszClass))
|
---|
516 | cs->lpszClass = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
---|
517 | (LPCSTR)cs->lpszClass );
|
---|
518 | *plparam = (LPARAM)cs;
|
---|
519 | }
|
---|
520 | return 1;
|
---|
521 | case WM_MDICREATE:
|
---|
522 | {
|
---|
523 | MDICREATESTRUCTW *cs =
|
---|
524 | (MDICREATESTRUCTW *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) );
|
---|
525 | if (!cs) return -1;
|
---|
526 | *cs = *(MDICREATESTRUCTW *)*plparam;
|
---|
527 | if (HIWORD(cs->szClass))
|
---|
528 | cs->szClass = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
---|
529 | (LPCSTR)cs->szClass );
|
---|
530 | if (HIWORD(cs->szTitle))
|
---|
531 | cs->szTitle = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
---|
532 | (LPCSTR)cs->szTitle );
|
---|
533 | *plparam = (LPARAM)cs;
|
---|
534 | }
|
---|
535 | return 1;
|
---|
536 |
|
---|
537 | /* Listbox */
|
---|
538 | case LB_ADDSTRING:
|
---|
539 | case LB_INSERTSTRING:
|
---|
540 | if ( WINPROC_TestLBForStr( hwnd ))
|
---|
541 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
|
---|
542 | return (*plparam ? 1 : -1);
|
---|
543 |
|
---|
544 | case LB_GETTEXT: /* fixme: fixed sized buffer */
|
---|
545 | { if ( WINPROC_TestLBForStr( hwnd ))
|
---|
546 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
|
---|
547 | if (!ptr) return -1;
|
---|
548 | *ptr++ = *plparam; /* Store previous lParam */
|
---|
549 | *plparam = (LPARAM)ptr;
|
---|
550 | }
|
---|
551 | }
|
---|
552 | return 1;
|
---|
553 |
|
---|
554 | /* Combobox */
|
---|
555 | case CB_ADDSTRING:
|
---|
556 | case CB_INSERTSTRING:
|
---|
557 | if ( WINPROC_TestCBForStr( hwnd ))
|
---|
558 | *plparam = (LPARAM)HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)*plparam );
|
---|
559 | return (*plparam ? 1 : -1);
|
---|
560 |
|
---|
561 | case CB_GETLBTEXT: /* fixme: fixed sized buffer */
|
---|
562 | { if ( WINPROC_TestCBForStr( hwnd ))
|
---|
563 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(WCHAR) + sizeof(LPARAM) );
|
---|
564 | if (!ptr) return -1;
|
---|
565 | *ptr++ = *plparam; /* Store previous lParam */
|
---|
566 | *plparam = (LPARAM)ptr;
|
---|
567 | }
|
---|
568 | }
|
---|
569 | return 1;
|
---|
570 |
|
---|
571 | /* Multiline edit */
|
---|
572 | case EM_GETLINE:
|
---|
573 | { WORD len = (WORD)*plparam;
|
---|
574 | LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(WCHAR) );
|
---|
575 | if (!ptr) return -1;
|
---|
576 | *ptr++ = *plparam; /* Store previous lParam */
|
---|
577 | *((WORD *) ptr) = len; /* Store the length */
|
---|
578 | *plparam = (LPARAM)ptr;
|
---|
579 | }
|
---|
580 | return 1;
|
---|
581 |
|
---|
582 | case WM_ASKCBFORMATNAME:
|
---|
583 | case WM_DEVMODECHANGE:
|
---|
584 | case WM_PAINTCLIPBOARD:
|
---|
585 | case WM_SIZECLIPBOARD:
|
---|
586 | case EM_SETPASSWORDCHAR:
|
---|
587 | // FIXME_(msg)("message %s (0x%x) needs translation, please report\n", SPY_GetMsgName(msg), msg );
|
---|
588 | return -1;
|
---|
589 | default: /* No translation needed */
|
---|
590 | return 0;
|
---|
591 | }
|
---|
592 | }
|
---|
593 |
|
---|
594 |
|
---|
595 | /**********************************************************************
|
---|
596 | * WINPROC_UnmapMsg32ATo32W
|
---|
597 | *
|
---|
598 | * Unmap a message that was mapped from Ansi to Unicode.
|
---|
599 | */
|
---|
600 | void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
---|
601 | {
|
---|
602 | switch(msg)
|
---|
603 | {
|
---|
604 | case WM_GETTEXT:
|
---|
605 | {
|
---|
606 | LPARAM *ptr = (LPARAM *)lParam - 1;
|
---|
607 | lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam );
|
---|
608 | HeapFree( GetProcessHeap(), 0, ptr );
|
---|
609 | }
|
---|
610 | break;
|
---|
611 |
|
---|
612 | case WM_NCCREATE:
|
---|
613 | case WM_CREATE:
|
---|
614 | {
|
---|
615 | CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
|
---|
616 | if (HIWORD(cs->lpszName))
|
---|
617 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName );
|
---|
618 | if (HIWORD(cs->lpszClass))
|
---|
619 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass );
|
---|
620 | HeapFree( GetProcessHeap(), 0, cs );
|
---|
621 | }
|
---|
622 | break;
|
---|
623 |
|
---|
624 | case WM_MDICREATE:
|
---|
625 | {
|
---|
626 | MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lParam;
|
---|
627 | if (HIWORD(cs->szTitle))
|
---|
628 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle );
|
---|
629 | if (HIWORD(cs->szClass))
|
---|
630 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass );
|
---|
631 | HeapFree( GetProcessHeap(), 0, cs );
|
---|
632 | }
|
---|
633 | break;
|
---|
634 |
|
---|
635 | case WM_SETTEXT:
|
---|
636 | case WM_WININICHANGE:
|
---|
637 | case CB_DIR:
|
---|
638 | case CB_FINDSTRING:
|
---|
639 | case CB_FINDSTRINGEXACT:
|
---|
640 | case CB_SELECTSTRING:
|
---|
641 | case LB_DIR:
|
---|
642 | case LB_ADDFILE:
|
---|
643 | case LB_FINDSTRING:
|
---|
644 | case LB_SELECTSTRING:
|
---|
645 | case EM_REPLACESEL:
|
---|
646 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
---|
647 | break;
|
---|
648 |
|
---|
649 | /* Listbox */
|
---|
650 | case LB_ADDSTRING:
|
---|
651 | case LB_INSERTSTRING:
|
---|
652 | if ( WINPROC_TestLBForStr( hwnd ))
|
---|
653 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
---|
654 | break;
|
---|
655 |
|
---|
656 | case LB_GETTEXT:
|
---|
657 | { if ( WINPROC_TestLBForStr( hwnd ))
|
---|
658 | { LPARAM *ptr = (LPARAM *)lParam - 1;
|
---|
659 | lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
|
---|
660 | HeapFree( GetProcessHeap(), 0, ptr );
|
---|
661 | }
|
---|
662 | }
|
---|
663 | break;
|
---|
664 |
|
---|
665 | /* Combobox */
|
---|
666 | case CB_ADDSTRING:
|
---|
667 | case CB_INSERTSTRING:
|
---|
668 | if ( WINPROC_TestCBForStr( hwnd ))
|
---|
669 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
---|
670 | break;
|
---|
671 |
|
---|
672 | case CB_GETLBTEXT:
|
---|
673 | { if ( WINPROC_TestCBForStr( hwnd ))
|
---|
674 | { LPARAM *ptr = (LPARAM *)lParam - 1;
|
---|
675 | lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) );
|
---|
676 | HeapFree( GetProcessHeap(), 0, ptr );
|
---|
677 | }
|
---|
678 | }
|
---|
679 | break;
|
---|
680 |
|
---|
681 | /* Multiline edit */
|
---|
682 | case EM_GETLINE:
|
---|
683 | { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lParam */
|
---|
684 | WORD len = *(WORD *) lParam;
|
---|
685 | lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len );
|
---|
686 | HeapFree( GetProcessHeap(), 0, ptr );
|
---|
687 | }
|
---|
688 | break;
|
---|
689 | }
|
---|
690 | }
|
---|
691 |
|
---|
692 |
|
---|
693 | /**********************************************************************
|
---|
694 | * WINPROC_MapMsg32WTo32A
|
---|
695 | *
|
---|
696 | * Map a message from Unicode to Ansi.
|
---|
697 | * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
|
---|
698 | */
|
---|
699 | INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam)
|
---|
700 | { switch(msg)
|
---|
701 | {
|
---|
702 | case WM_GETTEXT:
|
---|
703 | {
|
---|
704 | LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
|
---|
705 | wParam + sizeof(LPARAM) );
|
---|
706 | if (!ptr) return -1;
|
---|
707 | *ptr++ = *plparam; /* Store previous lParam */
|
---|
708 | *plparam = (LPARAM)ptr;
|
---|
709 | }
|
---|
710 | return 1;
|
---|
711 |
|
---|
712 | case WM_SETTEXT:
|
---|
713 | case WM_WININICHANGE:
|
---|
714 | case CB_DIR:
|
---|
715 | case CB_FINDSTRING:
|
---|
716 | case CB_FINDSTRINGEXACT:
|
---|
717 | case CB_SELECTSTRING:
|
---|
718 | case LB_DIR:
|
---|
719 | case LB_ADDFILE:
|
---|
720 | case LB_FINDSTRING:
|
---|
721 | case LB_SELECTSTRING:
|
---|
722 | case EM_REPLACESEL:
|
---|
723 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
|
---|
724 | return (*plparam ? 1 : -1);
|
---|
725 |
|
---|
726 | case WM_NCCREATE:
|
---|
727 | case WM_CREATE:
|
---|
728 | {
|
---|
729 | CREATESTRUCTA *cs = (CREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0,
|
---|
730 | sizeof(*cs) );
|
---|
731 | if (!cs) return -1;
|
---|
732 | *cs = *(CREATESTRUCTA *)*plparam;
|
---|
733 | if (HIWORD(cs->lpszName))
|
---|
734 | cs->lpszName = HEAP_strdupWtoA( GetProcessHeap(), 0,
|
---|
735 | (LPCWSTR)cs->lpszName );
|
---|
736 | if (HIWORD(cs->lpszClass))
|
---|
737 | cs->lpszClass = HEAP_strdupWtoA( GetProcessHeap(), 0,
|
---|
738 | (LPCWSTR)cs->lpszClass);
|
---|
739 | *plparam = (LPARAM)cs;
|
---|
740 | }
|
---|
741 | return 1;
|
---|
742 | case WM_MDICREATE:
|
---|
743 | {
|
---|
744 | MDICREATESTRUCTA *cs =
|
---|
745 | (MDICREATESTRUCTA *)HeapAlloc( GetProcessHeap(), 0, sizeof(*cs) );
|
---|
746 |
|
---|
747 | if (!cs) return -1;
|
---|
748 | *cs = *(MDICREATESTRUCTA *)*plparam;
|
---|
749 | if (HIWORD(cs->szTitle))
|
---|
750 | cs->szTitle = HEAP_strdupWtoA( GetProcessHeap(), 0,
|
---|
751 | (LPCWSTR)cs->szTitle );
|
---|
752 | if (HIWORD(cs->szClass))
|
---|
753 | cs->szClass = HEAP_strdupWtoA( GetProcessHeap(), 0,
|
---|
754 | (LPCWSTR)cs->szClass );
|
---|
755 | *plparam = (LPARAM)cs;
|
---|
756 | }
|
---|
757 | return 1;
|
---|
758 |
|
---|
759 | /* Listbox */
|
---|
760 | case LB_ADDSTRING:
|
---|
761 | case LB_INSERTSTRING:
|
---|
762 | if ( WINPROC_TestLBForStr( hwnd ))
|
---|
763 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
|
---|
764 | return (*plparam ? 1 : -1);
|
---|
765 |
|
---|
766 | case LB_GETTEXT: /* fixme: fixed sized buffer */
|
---|
767 | { if ( WINPROC_TestLBForStr( hwnd ))
|
---|
768 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
|
---|
769 | if (!ptr) return -1;
|
---|
770 | *ptr++ = *plparam; /* Store previous lParam */
|
---|
771 | *plparam = (LPARAM)ptr;
|
---|
772 | }
|
---|
773 | }
|
---|
774 | return 1;
|
---|
775 |
|
---|
776 | /* Combobox */
|
---|
777 | case CB_ADDSTRING:
|
---|
778 | case CB_INSERTSTRING:
|
---|
779 | if ( WINPROC_TestCBForStr( hwnd ))
|
---|
780 | *plparam = (LPARAM)HEAP_strdupWtoA( GetProcessHeap(), 0, (LPCWSTR)*plparam );
|
---|
781 | return (*plparam ? 1 : -1);
|
---|
782 |
|
---|
783 | case CB_GETLBTEXT: /* fixme: fixed sized buffer */
|
---|
784 | { if ( WINPROC_TestCBForStr( hwnd ))
|
---|
785 | { LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0, 256 + sizeof(LPARAM) );
|
---|
786 | if (!ptr) return -1;
|
---|
787 | *ptr++ = *plparam; /* Store previous lParam */
|
---|
788 | *plparam = (LPARAM)ptr;
|
---|
789 | }
|
---|
790 | }
|
---|
791 | return 1;
|
---|
792 |
|
---|
793 | /* Multiline edit */
|
---|
794 | case EM_GETLINE:
|
---|
795 | { WORD len = (WORD)*plparam;
|
---|
796 | LPARAM *ptr = (LPARAM *) HEAP_xalloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
|
---|
797 | if (!ptr) return -1;
|
---|
798 | *ptr++ = *plparam; /* Store previous lParam */
|
---|
799 | *((WORD *) ptr) = len; /* Store the length */
|
---|
800 | *plparam = (LPARAM)ptr;
|
---|
801 | }
|
---|
802 | return 1;
|
---|
803 |
|
---|
804 | case WM_ASKCBFORMATNAME:
|
---|
805 | case WM_DEVMODECHANGE:
|
---|
806 | case WM_PAINTCLIPBOARD:
|
---|
807 | case WM_SIZECLIPBOARD:
|
---|
808 | case EM_SETPASSWORDCHAR:
|
---|
809 | // FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg );
|
---|
810 | return -1;
|
---|
811 | default: /* No translation needed */
|
---|
812 | return 0;
|
---|
813 | }
|
---|
814 | }
|
---|
815 |
|
---|
816 |
|
---|
817 | /**********************************************************************
|
---|
818 | * WINPROC_UnmapMsg32WTo32A
|
---|
819 | *
|
---|
820 | * Unmap a message that was mapped from Unicode to Ansi.
|
---|
821 | */
|
---|
822 | void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
---|
823 | {
|
---|
824 | switch(msg)
|
---|
825 | {
|
---|
826 | case WM_GETTEXT:
|
---|
827 | {
|
---|
828 | LPARAM *ptr = (LPARAM *)lParam - 1;
|
---|
829 | lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam );
|
---|
830 | HeapFree( GetProcessHeap(), 0, ptr );
|
---|
831 | }
|
---|
832 | break;
|
---|
833 |
|
---|
834 | case WM_SETTEXT:
|
---|
835 | case WM_WININICHANGE:
|
---|
836 | case CB_DIR:
|
---|
837 | case CB_FINDSTRING:
|
---|
838 | case CB_FINDSTRINGEXACT:
|
---|
839 | case CB_SELECTSTRING:
|
---|
840 | case LB_DIR:
|
---|
841 | case LB_ADDFILE:
|
---|
842 | case LB_FINDSTRING:
|
---|
843 | case LB_SELECTSTRING:
|
---|
844 | case EM_REPLACESEL:
|
---|
845 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
---|
846 | break;
|
---|
847 |
|
---|
848 | case WM_NCCREATE:
|
---|
849 | case WM_CREATE:
|
---|
850 | {
|
---|
851 | CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
|
---|
852 | if (HIWORD(cs->lpszName))
|
---|
853 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszName );
|
---|
854 | if (HIWORD(cs->lpszClass))
|
---|
855 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->lpszClass );
|
---|
856 | HeapFree( GetProcessHeap(), 0, cs );
|
---|
857 | }
|
---|
858 | break;
|
---|
859 |
|
---|
860 | case WM_MDICREATE:
|
---|
861 | {
|
---|
862 | MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)lParam;
|
---|
863 | if (HIWORD(cs->szTitle))
|
---|
864 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szTitle );
|
---|
865 | if (HIWORD(cs->szClass))
|
---|
866 | HeapFree( GetProcessHeap(), 0, (LPVOID)cs->szClass );
|
---|
867 | HeapFree( GetProcessHeap(), 0, cs );
|
---|
868 | }
|
---|
869 | break;
|
---|
870 |
|
---|
871 | /* Listbox */
|
---|
872 | case LB_ADDSTRING:
|
---|
873 | case LB_INSERTSTRING:
|
---|
874 | if ( WINPROC_TestLBForStr( hwnd ))
|
---|
875 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
---|
876 | break;
|
---|
877 |
|
---|
878 | case LB_GETTEXT:
|
---|
879 | { if ( WINPROC_TestLBForStr( hwnd ))
|
---|
880 | { LPARAM *ptr = (LPARAM *)lParam - 1;
|
---|
881 | lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
|
---|
882 | HeapFree(GetProcessHeap(), 0, ptr );
|
---|
883 | }
|
---|
884 | }
|
---|
885 | break;
|
---|
886 |
|
---|
887 | /* Combobox */
|
---|
888 | case CB_ADDSTRING:
|
---|
889 | case CB_INSERTSTRING:
|
---|
890 | if ( WINPROC_TestCBForStr( hwnd ))
|
---|
891 | HeapFree( GetProcessHeap(), 0, (void *)lParam );
|
---|
892 | break;
|
---|
893 |
|
---|
894 | case CB_GETLBTEXT:
|
---|
895 | { if ( WINPROC_TestCBForStr( hwnd ))
|
---|
896 | { LPARAM *ptr = (LPARAM *)lParam - 1;
|
---|
897 | lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) );
|
---|
898 | HeapFree( GetProcessHeap(), 0, ptr );
|
---|
899 | }
|
---|
900 | }
|
---|
901 | break;
|
---|
902 |
|
---|
903 | /* Multiline edit */
|
---|
904 | case EM_GETLINE:
|
---|
905 | { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lparam */
|
---|
906 | WORD len = *(WORD *)ptr;
|
---|
907 | lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
|
---|
908 | HeapFree( GetProcessHeap(), 0, ptr );
|
---|
909 | }
|
---|
910 | break;
|
---|
911 | }
|
---|
912 | }
|
---|
913 |
|
---|
914 | /**********************************************************************
|
---|
915 | * WINPROC_CallProc32ATo32W
|
---|
916 | *
|
---|
917 | * Call a window procedure, translating args from Ansi to Unicode.
|
---|
918 | */
|
---|
919 | static LRESULT WINPROC_CallProc32ATo32W( WNDPROC func, HWND hwnd,
|
---|
920 | UINT msg, WPARAM wParam,
|
---|
921 | LPARAM lParam )
|
---|
922 | {
|
---|
923 | LRESULT result;
|
---|
924 |
|
---|
925 | if (WINPROC_MapMsg32ATo32W( hwnd, msg, wParam, &lParam ) == -1) return 0;
|
---|
926 | result = func( hwnd, msg, wParam, lParam );
|
---|
927 | WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
|
---|
928 | return result;
|
---|
929 | }
|
---|
930 |
|
---|
931 | /**********************************************************************
|
---|
932 | * WINPROC_CallProc32WTo32A
|
---|
933 | *
|
---|
934 | * Call a window procedure, translating args from Unicode to Ansi.
|
---|
935 | */
|
---|
936 | static LRESULT WINPROC_CallProc32WTo32A( WNDPROC func, HWND hwnd,
|
---|
937 | UINT msg, WPARAM wParam,
|
---|
938 | LPARAM lParam )
|
---|
939 | {
|
---|
940 | LRESULT result;
|
---|
941 |
|
---|
942 | if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0;
|
---|
943 |
|
---|
944 | result = func( hwnd, msg, wParam, lParam );
|
---|
945 | WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
|
---|
946 | return result;
|
---|
947 | }
|
---|
948 | /**********************************************************************
|
---|
949 | * CallWindowProc32A
|
---|
950 | */
|
---|
951 | LRESULT WIN32API CallWindowProcA(
|
---|
952 | WNDPROC func, /* window procedure */
|
---|
953 | HWND hwnd, /* target window */
|
---|
954 | UINT msg, /* message */
|
---|
955 | WPARAM wParam, /* message dependent parameter */
|
---|
956 | LPARAM lParam /* message dependent parameter */
|
---|
957 | )
|
---|
958 | {
|
---|
959 |
|
---|
960 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
961 | if(!window) {
|
---|
962 | dprintf(("CallWindowProcA, window %x not found", hwnd));
|
---|
963 | // return func( hwnd, msg, wParam, lParam );
|
---|
964 | return 0;
|
---|
965 | }
|
---|
966 |
|
---|
967 | dprintf(("CallWindowProcA(wndproc=%p,hwnd=%08x,msg=%08x,wp=%08x,lp=%08lx)",
|
---|
968 | func, hwnd, msg, wParam, lParam ));
|
---|
969 |
|
---|
970 | #if testing
|
---|
971 | return func( hwnd, msg, wParam, lParam );
|
---|
972 | #endif
|
---|
973 |
|
---|
974 | if(window->IsUnicode())
|
---|
975 | return WINPROC_CallProc32ATo32W( func, hwnd, msg, wParam, lParam);
|
---|
976 | else
|
---|
977 | return func( hwnd, msg, wParam, lParam );
|
---|
978 | }
|
---|
979 |
|
---|
980 |
|
---|
981 | /**********************************************************************
|
---|
982 | * CallWindowProc32W (USER32.19)
|
---|
983 | */
|
---|
984 | LRESULT WIN32API CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg,
|
---|
985 | WPARAM wParam, LPARAM lParam )
|
---|
986 | {
|
---|
987 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
988 | if(!window) {
|
---|
989 | dprintf(("CallWindowProcW, window %x not found", hwnd));
|
---|
990 | // return func( hwnd, msg, wParam, lParam );
|
---|
991 | return 0;
|
---|
992 | }
|
---|
993 |
|
---|
994 | dprintf(("CallWindowProcW(wndproc=%p,hwnd=%08x,msg=%08x,wp=%08x,lp=%08lx)",
|
---|
995 | func, hwnd, msg, wParam, lParam ));
|
---|
996 |
|
---|
997 | #if testing
|
---|
998 | return func( hwnd, msg, wParam, lParam );
|
---|
999 | #endif
|
---|
1000 |
|
---|
1001 | if(window->IsUnicode())
|
---|
1002 | return func( hwnd, msg, wParam, lParam );
|
---|
1003 | else
|
---|
1004 | return WINPROC_CallProc32WTo32A( func, hwnd, msg, wParam, lParam);
|
---|
1005 | }
|
---|