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