source: trunk/src/user32/new/windowmsg.cpp@ 309

Last change on this file since 309 was 309, checked in by sandervl, 26 years ago

Send/PostMessage changes

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