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