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