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

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

More dialog update

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