1 | /* $Id: windowmsg.cpp,v 1.4 1999-07-15 18:41:46 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)
|
---|
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 <win32wnd.h>
|
---|
18 | #include <handlemanager.h>
|
---|
19 | #include <win.h>
|
---|
20 | #include <hooks.h>
|
---|
21 |
|
---|
22 | //******************************************************************************
|
---|
23 | //******************************************************************************
|
---|
24 | VOID WIN32API PostQuitMessage( int nExitCode)
|
---|
25 | {
|
---|
26 | dprintf(("USER32: PostQuitMessage\n"));
|
---|
27 |
|
---|
28 | O32_PostQuitMessage(nExitCode);
|
---|
29 | }
|
---|
30 | //******************************************************************************
|
---|
31 | //******************************************************************************
|
---|
32 | LONG WIN32API DispatchMessageA( const MSG * msg)
|
---|
33 | {
|
---|
34 | LONG retval;
|
---|
35 | int painting;
|
---|
36 | Win32Window *window;
|
---|
37 |
|
---|
38 | /* Process timer messages */
|
---|
39 | if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
|
---|
40 | {
|
---|
41 | if (msg->lParam)
|
---|
42 | {
|
---|
43 | return SendMessageA(msg->hwnd, msg->message, msg->wParam, GetTickCount());
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | if (!msg->hwnd) return 0;
|
---|
48 |
|
---|
49 | if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
|
---|
50 | dprintf(("DispatchMessageA, window %x not found", msg->hwnd));
|
---|
51 | return 0;
|
---|
52 | }
|
---|
53 |
|
---|
54 | painting = (msg->message == WM_PAINT);
|
---|
55 | if (painting) window->setFlags(window->getFlags() | WIN_NEEDS_BEGINPAINT);
|
---|
56 |
|
---|
57 | retval = window->SendMessageA(msg->message, msg->wParam, msg->lParam );
|
---|
58 |
|
---|
59 | #if 0
|
---|
60 | if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
|
---|
61 | dprintf(("DispatchMessageA, window %x not found", msg->hwnd));
|
---|
62 | return 0;
|
---|
63 | }
|
---|
64 |
|
---|
65 | if (painting && (wndPtr->getFlags() & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
|
---|
66 | {
|
---|
67 | ERR_(msg)("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
|
---|
68 | msg->hwnd);
|
---|
69 | wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
|
---|
70 | /* Validate the update region to avoid infinite WM_PAINT loop */
|
---|
71 | ValidateRect( msg->hwnd, NULL );
|
---|
72 | }
|
---|
73 | #endif
|
---|
74 | return retval;
|
---|
75 | }
|
---|
76 | //******************************************************************************
|
---|
77 | //******************************************************************************
|
---|
78 | LONG WIN32API DispatchMessageW( const MSG * msg)
|
---|
79 | {
|
---|
80 | LONG retval;
|
---|
81 | int painting;
|
---|
82 | Win32Window *window;
|
---|
83 |
|
---|
84 | /* Process timer messages */
|
---|
85 | if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
|
---|
86 | {
|
---|
87 | if (msg->lParam)
|
---|
88 | {
|
---|
89 | return SendMessageW(msg->hwnd, msg->message, msg->wParam, GetTickCount());
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | if (!msg->hwnd) return 0;
|
---|
94 |
|
---|
95 | if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
|
---|
96 | dprintf(("DispatchMessageW, window %x not found", msg->hwnd));
|
---|
97 | return 0;
|
---|
98 | }
|
---|
99 |
|
---|
100 | painting = (msg->message == WM_PAINT);
|
---|
101 | if (painting) window->setFlags(window->getFlags() | WIN_NEEDS_BEGINPAINT);
|
---|
102 |
|
---|
103 | retval = window->SendMessageW(msg->message, msg->wParam, msg->lParam );
|
---|
104 |
|
---|
105 | #if 0
|
---|
106 | if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
|
---|
107 | dprintf(("DispatchMessageW, window %x not found", msg->hwnd));
|
---|
108 | return 0;
|
---|
109 | }
|
---|
110 |
|
---|
111 | if (painting && (wndPtr->getFlags() & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
|
---|
112 | {
|
---|
113 | ERR_(msg)("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
|
---|
114 | msg->hwnd);
|
---|
115 | wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
|
---|
116 | /* Validate the update region to avoid infinite WM_PAINT loop */
|
---|
117 | ValidateRect( msg->hwnd, NULL );
|
---|
118 | }
|
---|
119 | #endif
|
---|
120 | return retval;
|
---|
121 | }
|
---|
122 | //******************************************************************************
|
---|
123 | //******************************************************************************
|
---|
124 | BOOL WIN32API TranslateMessage( const MSG * arg1)
|
---|
125 | {
|
---|
126 | #ifdef DEBUG
|
---|
127 | //// WriteLog("USER32: TranslateMessage\n");
|
---|
128 | #endif
|
---|
129 | return O32_TranslateMessage(arg1);
|
---|
130 | }
|
---|
131 | //******************************************************************************
|
---|
132 | //TODO: hwnd == HWND_BROADCAST
|
---|
133 | //******************************************************************************
|
---|
134 | LRESULT WIN32API SendMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
135 | {
|
---|
136 | Win32Window *window;
|
---|
137 |
|
---|
138 | if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
|
---|
139 | dprintf(("SendMessageA, window %x not found", hwnd));
|
---|
140 | return 0;
|
---|
141 | }
|
---|
142 | return window->SendMessageA(msg, wParam, lParam);
|
---|
143 | }
|
---|
144 | //******************************************************************************
|
---|
145 | //TODO: hwnd == HWND_BROADCAST
|
---|
146 | //******************************************************************************
|
---|
147 | LRESULT WIN32API SendMessageW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
148 | {
|
---|
149 | Win32Window *window;
|
---|
150 |
|
---|
151 | if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
|
---|
152 | dprintf(("SendMessageW, window %x not found", hwnd));
|
---|
153 | return 0;
|
---|
154 | }
|
---|
155 | return window->SendMessageW(msg, wParam, lParam);
|
---|
156 | }
|
---|
157 | //******************************************************************************
|
---|
158 | //TODO: hwnd == HWND_BROADCAST
|
---|
159 | //******************************************************************************
|
---|
160 | BOOL WIN32API PostMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
161 | {
|
---|
162 | Win32Window *window;
|
---|
163 |
|
---|
164 | if(hwnd == NULL)
|
---|
165 | return PostThreadMessageA(GetCurrentThreadId(), msg, wParam, lParam);
|
---|
166 |
|
---|
167 | if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
|
---|
168 | dprintf(("PostMessageA, window %x not found", hwnd));
|
---|
169 | return 0;
|
---|
170 | }
|
---|
171 | return window->PostMessageA(msg, wParam, lParam);
|
---|
172 | }
|
---|
173 | //******************************************************************************
|
---|
174 | //TODO: hwnd == HWND_BROADCAST
|
---|
175 | //******************************************************************************
|
---|
176 | BOOL WIN32API PostMessageW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
177 | {
|
---|
178 | Win32Window *window;
|
---|
179 |
|
---|
180 | if(hwnd == NULL)
|
---|
181 | return PostThreadMessageW(GetCurrentThreadId(), msg, wParam, lParam);
|
---|
182 |
|
---|
183 | if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
|
---|
184 | dprintf(("PostMessageW, window %x not found", hwnd));
|
---|
185 | return 0;
|
---|
186 | }
|
---|
187 | return window->PostMessageW(msg, wParam, lParam);
|
---|
188 | }
|
---|
189 | //******************************************************************************
|
---|
190 | //******************************************************************************
|
---|
191 | BOOL WIN32API WaitMessage(void)
|
---|
192 | {
|
---|
193 | #ifdef DEBUG
|
---|
194 | WriteLog("USER32: WaitMessage\n");
|
---|
195 | #endif
|
---|
196 | return O32_WaitMessage();
|
---|
197 | }
|
---|
198 | //******************************************************************************
|
---|
199 | //******************************************************************************
|
---|
200 | BOOL WIN32API PeekMessageA(LPMSG arg1, HWND arg2, UINT arg3, UINT arg4, UINT arg5)
|
---|
201 | {
|
---|
202 | #ifdef DEBUG
|
---|
203 | // WriteLog("USER32: PeekMessage\n");
|
---|
204 | #endif
|
---|
205 | return O32_PeekMessage(arg1, arg2, arg3, arg4, arg5);
|
---|
206 | }
|
---|
207 | //******************************************************************************
|
---|
208 | //******************************************************************************
|
---|
209 | BOOL WIN32API PeekMessageW( LPMSG arg1, HWND arg2, UINT arg3, UINT arg4, UINT arg5)
|
---|
210 | {
|
---|
211 | #ifdef DEBUG
|
---|
212 | WriteLog("USER32: PeekMessageW\n");
|
---|
213 | #endif
|
---|
214 | // NOTE: This will not work as is (needs UNICODE support)
|
---|
215 | return O32_PeekMessage(arg1, arg2, arg3, arg4, arg5);
|
---|
216 | }
|
---|
217 | //******************************************************************************
|
---|
218 | //******************************************************************************
|
---|
219 | BOOL WIN32API InSendMessage(void)
|
---|
220 | {
|
---|
221 | #ifdef DEBUG
|
---|
222 | WriteLog("USER32: InSendMessage\n");
|
---|
223 | #endif
|
---|
224 | return O32_InSendMessage();
|
---|
225 | }
|
---|
226 | //******************************************************************************
|
---|
227 | //******************************************************************************
|
---|
228 | //******************************************************************************
|
---|
229 | BOOL WIN32API ReplyMessage( LRESULT arg1)
|
---|
230 | {
|
---|
231 | #ifdef DEBUG
|
---|
232 | WriteLog("USER32: ReplyMessage\n");
|
---|
233 | #endif
|
---|
234 | return O32_ReplyMessage(arg1);
|
---|
235 | }
|
---|
236 | //******************************************************************************
|
---|
237 | //******************************************************************************
|
---|
238 | BOOL WIN32API PostThreadMessageA( DWORD arg1, UINT arg2, WPARAM arg3, LPARAM arg4)
|
---|
239 | {
|
---|
240 | #ifdef DEBUG
|
---|
241 | WriteLog("USER32: PostThreadMessageA\n");
|
---|
242 | #endif
|
---|
243 | return O32_PostThreadMessage(arg1, arg2, arg3, arg4);
|
---|
244 | }
|
---|
245 | //******************************************************************************
|
---|
246 | //******************************************************************************
|
---|
247 | BOOL WIN32API PostThreadMessageW( DWORD arg1, UINT arg2, WPARAM arg3, LPARAM arg4)
|
---|
248 | {
|
---|
249 | #ifdef DEBUG
|
---|
250 | WriteLog("USER32: PostThreadMessageW\n");
|
---|
251 | #endif
|
---|
252 | // NOTE: This will not work as is (needs UNICODE support)
|
---|
253 | return O32_PostThreadMessage(arg1, arg2, arg3, arg4);
|
---|
254 | }
|
---|
255 | //******************************************************************************
|
---|
256 | //SvL: 24-6-'97 - Added
|
---|
257 | //******************************************************************************
|
---|
258 | UINT WIN32API RegisterWindowMessageA(LPCSTR arg1)
|
---|
259 | {
|
---|
260 | UINT rc;
|
---|
261 |
|
---|
262 | rc = O32_RegisterWindowMessage(arg1);
|
---|
263 | #ifdef DEBUG
|
---|
264 | WriteLog("USER32: RegisterWindowMessageA %s returned %X\n", arg1, rc);
|
---|
265 | #endif
|
---|
266 | return(rc);
|
---|
267 | }
|
---|
268 | //******************************************************************************
|
---|
269 | //******************************************************************************
|
---|
270 | UINT WIN32API RegisterWindowMessageW( LPCWSTR arg1)
|
---|
271 | {
|
---|
272 | char *astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
273 | UINT rc;
|
---|
274 |
|
---|
275 | #ifdef DEBUG
|
---|
276 | WriteLog("USER32: RegisterWindowMessageW\n");
|
---|
277 | #endif
|
---|
278 | rc = O32_RegisterWindowMessage(astring);
|
---|
279 | FreeAsciiString(astring);
|
---|
280 | return rc;
|
---|
281 | }
|
---|
282 | //******************************************************************************
|
---|
283 | //******************************************************************************
|
---|
284 | LRESULT WIN32API CallWindowProcA(WNDPROC wndprcPrev,
|
---|
285 | HWND arg2,
|
---|
286 | UINT arg3,
|
---|
287 | WPARAM arg4,
|
---|
288 | LPARAM arg5)
|
---|
289 | {
|
---|
290 | #ifdef DEBUG
|
---|
291 | //// WriteLog("USER32: CallWindowProcA %X hwnd=%X, msg = %X\n", wndprcPrev, arg2, arg3);
|
---|
292 | #endif
|
---|
293 |
|
---|
294 | return wndprcPrev(arg2, arg3, arg4, arg5); //win32 callback (__stdcall)
|
---|
295 | }
|
---|
296 | //******************************************************************************
|
---|
297 | //******************************************************************************
|
---|
298 | LRESULT WIN32API CallWindowProcW(WNDPROC arg1,
|
---|
299 | HWND arg2,
|
---|
300 | UINT arg3,
|
---|
301 | WPARAM arg4,
|
---|
302 | LPARAM arg5)
|
---|
303 | {
|
---|
304 | dprintf(("USER32: CallWindowProcW(%08xh,%08xh,%08xh,%08xh,%08xh) not properly implemented.\n",
|
---|
305 | arg1,
|
---|
306 | arg2,
|
---|
307 | arg3,
|
---|
308 | arg4,
|
---|
309 | arg5));
|
---|
310 |
|
---|
311 | return CallWindowProcA(arg1,
|
---|
312 | arg2,
|
---|
313 | arg3,
|
---|
314 | arg4,
|
---|
315 | arg5);
|
---|
316 | }
|
---|
317 | //******************************************************************************
|
---|
318 | //No need to support this
|
---|
319 | //******************************************************************************
|
---|
320 | BOOL WIN32API SetMessageQueue(int cMessagesMax)
|
---|
321 | {
|
---|
322 | #ifdef DEBUG
|
---|
323 | WriteLog("USER32: SetMessageQueue\n");
|
---|
324 | #endif
|
---|
325 | return(TRUE);
|
---|
326 | }
|
---|
327 | //******************************************************************************
|
---|
328 | //******************************************************************************
|
---|
329 | LRESULT WIN32API SendMessageTimeoutA(HWND hwnd, UINT Msg, WPARAM wParam,
|
---|
330 | LPARAM lParam, UINT fuFlags, UINT uTimeOut,
|
---|
331 | LPDWORD lpdwResult)
|
---|
332 | {
|
---|
333 | #ifdef DEBUG
|
---|
334 | WriteLog("USER32: SendMessageTimeoutA, partially implemented\n");
|
---|
335 | #endif
|
---|
336 | //ignore fuFlags & wTimeOut
|
---|
337 | *lpdwResult = SendMessageA(hwnd, Msg, wParam, lParam);
|
---|
338 | return(TRUE);
|
---|
339 | }
|
---|
340 | //******************************************************************************
|
---|
341 | //******************************************************************************
|
---|
342 | LRESULT WIN32API SendMessageTimeoutW(HWND hwnd, UINT Msg, WPARAM wParam,
|
---|
343 | LPARAM lParam, UINT fuFlags, UINT uTimeOut,
|
---|
344 | LPDWORD lpdwResult)
|
---|
345 | {
|
---|
346 | #ifdef DEBUG
|
---|
347 | WriteLog("USER32: SendMessageTimeoutW, partially implemented\n");
|
---|
348 | #endif
|
---|
349 | return(SendMessageTimeoutA(hwnd, Msg, wParam, lParam, fuFlags, uTimeOut, lpdwResult));
|
---|
350 | }
|
---|
351 | //******************************************************************************
|
---|
352 | //******************************************************************************
|
---|
353 | BOOL WIN32API SendNotifyMessageA(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
354 | {
|
---|
355 | #ifdef DEBUG
|
---|
356 | WriteLog("USER32: SendNotifyMessageA, not completely implemented\n");
|
---|
357 | #endif
|
---|
358 | return(SendMessageA(hwnd, Msg, wParam, lParam));
|
---|
359 | }
|
---|
360 | //******************************************************************************
|
---|
361 | //******************************************************************************
|
---|
362 | BOOL WIN32API SendNotifyMessageW(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
363 | {
|
---|
364 | #ifdef DEBUG
|
---|
365 | WriteLog("USER32: SendNotifyMessageW, not completely implemented\n");
|
---|
366 | #endif
|
---|
367 | return(SendMessageA(hwnd, Msg, wParam, lParam));
|
---|
368 | }
|
---|
369 | //******************************************************************************
|
---|
370 | //******************************************************************************
|
---|
371 | LPARAM WIN32API SetMessageExtraInfo(LPARAM lParam)
|
---|
372 | {
|
---|
373 | #ifdef DEBUG
|
---|
374 | WriteLog("USER32: SetMessageExtraInfo, not implemented\n");
|
---|
375 | #endif
|
---|
376 | return(0);
|
---|
377 | }
|
---|
378 | /*****************************************************************************
|
---|
379 | * Name : BOOL WIN32API SendMessageCallbackA
|
---|
380 | * Purpose : The SendMessageCallback function sends the specified message to
|
---|
381 | * a window or windows. The function calls the window procedure for
|
---|
382 | * the specified window and returns immediately. After the window
|
---|
383 | * procedure processes the message, the system calls the specified
|
---|
384 | * callback function, passing the result of the message processing
|
---|
385 | * and an application-defined value to the callback function.
|
---|
386 | * Parameters: HWND hwnd handle of destination window
|
---|
387 | * UINT uMsg message to send
|
---|
388 | * WPARAM wParam first message parameter
|
---|
389 | * LPARAM lParam second message parameter
|
---|
390 | * SENDASYNCPROC lpResultCallBack function to receive message value
|
---|
391 | * DWORD dwData value to pass to callback function
|
---|
392 | * Variables :
|
---|
393 | * Result : If the function succeeds, the return value is TRUE.
|
---|
394 | * If the function fails, the return value is FALSE. To get extended
|
---|
395 | * error information, call GetLastError.
|
---|
396 | * Remark :
|
---|
397 | * Status : UNTESTED STUB
|
---|
398 | *
|
---|
399 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
400 | *****************************************************************************/
|
---|
401 |
|
---|
402 | BOOL WIN32API SendMessageCallbackA(HWND hWnd,
|
---|
403 | UINT uMsg,
|
---|
404 | WPARAM wParam,
|
---|
405 | LPARAM lParam,
|
---|
406 | SENDASYNCPROC lpResultCallBack,
|
---|
407 | DWORD dwData)
|
---|
408 | {
|
---|
409 | dprintf(("USER32:SendMessageCallBackA (%08xh,%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n",
|
---|
410 | hWnd,
|
---|
411 | uMsg,
|
---|
412 | wParam,
|
---|
413 | lParam,
|
---|
414 | lpResultCallBack,
|
---|
415 | dwData));
|
---|
416 |
|
---|
417 | return (FALSE);
|
---|
418 | }
|
---|
419 |
|
---|
420 |
|
---|
421 | /*****************************************************************************
|
---|
422 | * Name : BOOL WIN32API SendMessageCallbackW
|
---|
423 | * Purpose : The SendMessageCallback function sends the specified message to
|
---|
424 | * a window or windows. The function calls the window procedure for
|
---|
425 | * the specified window and returns immediately. After the window
|
---|
426 | * procedure processes the message, the system calls the specified
|
---|
427 | * callback function, passing the result of the message processing
|
---|
428 | * and an application-defined value to the callback function.
|
---|
429 | * Parameters: HWND hwnd handle of destination window
|
---|
430 | * UINT uMsg message to send
|
---|
431 | * WPARAM wParam first message parameter
|
---|
432 | * LPARAM lParam second message parameter
|
---|
433 | * SENDASYNCPROC lpResultCallBack function to receive message value
|
---|
434 | * DWORD dwData value to pass to callback function
|
---|
435 | * Variables :
|
---|
436 | * Result : If the function succeeds, the return value is TRUE.
|
---|
437 | * If the function fails, the return value is FALSE. To get extended
|
---|
438 | * error information, call GetLastError.
|
---|
439 | * Remark :
|
---|
440 | * Status : UNTESTED STUB
|
---|
441 | *
|
---|
442 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
443 | *****************************************************************************/
|
---|
444 |
|
---|
445 | BOOL WIN32API SendMessageCallbackW(HWND hWnd,
|
---|
446 | UINT uMsg,
|
---|
447 | WPARAM wParam,
|
---|
448 | LPARAM lParam,
|
---|
449 | SENDASYNCPROC lpResultCallBack,
|
---|
450 | DWORD dwData)
|
---|
451 | {
|
---|
452 | dprintf(("USER32:SendMessageCallBackW (%08xh,%08xh,%08xh,%08xh,%08xh,%08x) not implemented.\n",
|
---|
453 | hWnd,
|
---|
454 | uMsg,
|
---|
455 | wParam,
|
---|
456 | lParam,
|
---|
457 | lpResultCallBack,
|
---|
458 | dwData));
|
---|
459 |
|
---|
460 | return (FALSE);
|
---|
461 | }
|
---|
462 | //******************************************************************************
|
---|
463 | //******************************************************************************
|
---|