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