Send a normal mouse message code in WM_PARENTNOTIFY, even if the
[wine.git] / windows / message.c
blobd2c1a67d41b660ea1712a72d84c5880b95f875d6
1 /*
2 * Message queues related functions
4 * Copyright 1993, 1994 Alexandre Julliard
5 */
7 #include <stdlib.h>
8 #include <string.h>
9 #include <ctype.h>
10 #include <sys/time.h>
11 #include <sys/types.h>
13 #include "wine/winbase16.h"
14 #include "message.h"
15 #include "winerror.h"
16 #include "win.h"
17 #include "heap.h"
18 #include "hook.h"
19 #include "input.h"
20 #include "spy.h"
21 #include "winpos.h"
22 #include "dde.h"
23 #include "queue.h"
24 #include "winproc.h"
25 #include "task.h"
26 #include "process.h"
27 #include "selectors.h"
28 #include "thread.h"
29 #include "options.h"
30 #include "menu.h"
31 #include "struct32.h"
32 #include "debugtools.h"
34 DEFAULT_DEBUG_CHANNEL(msg)
35 DECLARE_DEBUG_CHANNEL(key)
36 DECLARE_DEBUG_CHANNEL(sendmsg)
38 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
39 #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
42 typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP,
43 SYSQ_MSG_ACCEPT, SYSQ_MSG_CONTINUE } SYSQ_STATUS;
45 extern HQUEUE16 hCursorQueue; /* queue.c */
47 DWORD MSG_WineStartTicks; /* Ticks at Wine startup */
49 static UINT doubleClickSpeed = 452;
51 /***********************************************************************
52 * MSG_CheckFilter
54 static BOOL MSG_CheckFilter(DWORD uMsg, DWORD first, DWORD last)
56 if( first || last )
57 return (uMsg >= first && uMsg <= last);
58 return TRUE;
61 /***********************************************************************
62 * MSG_SendParentNotify
64 * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
65 * the window has the WS_EX_NOPARENTNOTIFY style.
67 static void MSG_SendParentNotify(WND* wndPtr, WORD event, WORD idChild, LPARAM lValue)
69 #define lppt ((LPPOINT16)&lValue)
71 /* pt has to be in the client coordinates of the parent window */
72 WND *tmpWnd = WIN_LockWndPtr(wndPtr);
74 MapWindowPoints16( 0, tmpWnd->hwndSelf, lppt, 1 );
75 while (tmpWnd)
77 if (!(tmpWnd->dwStyle & WS_CHILD) || (tmpWnd->dwExStyle & WS_EX_NOPARENTNOTIFY))
79 WIN_ReleaseWndPtr(tmpWnd);
80 break;
82 lppt->x += tmpWnd->rectClient.left;
83 lppt->y += tmpWnd->rectClient.top;
84 WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent);
85 SendMessageA( tmpWnd->hwndSelf, WM_PARENTNOTIFY,
86 MAKEWPARAM( event, idChild ), lValue );
89 #undef lppt
93 /***********************************************************************
94 * MSG_TranslateMouseMsg
96 * Translate an mouse hardware event into a real mouse message.
98 * Returns:
100 * SYSQ_MSG_ABANDON - abandon the peek message loop
101 * SYSQ_MSG_CONTINUE - leave the message in the queue and
102 * continue with the translation loop
103 * SYSQ_MSG_ACCEPT - proceed to process the translated message
105 static DWORD MSG_TranslateMouseMsg( HWND hTopWnd, DWORD first, DWORD last,
106 MSG *msg, BOOL remove, WND* pWndScope,
107 INT16 *pHitTest, POINT16 *pScreen_pt, BOOL *pmouseClick )
109 static DWORD dblclk_time_limit = 0;
110 static UINT16 clk_message = 0;
111 static HWND16 clk_hwnd = 0;
112 static POINT16 clk_pos = { 0, 0 };
114 WND *pWnd;
115 HWND hWnd;
116 INT16 ht, hittest;
117 UINT message = msg->message;
118 POINT16 screen_pt, pt;
119 HANDLE16 hQ = GetFastQueue16();
120 MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock(hQ);
121 BOOL mouseClick = ((message == WM_LBUTTONDOWN) ||
122 (message == WM_RBUTTONDOWN) ||
123 (message == WM_MBUTTONDOWN))?1:0;
124 DWORD retvalue;
126 /* Find the window to dispatch this mouse message to */
128 CONV_POINT32TO16( &msg->pt, &pt );
130 hWnd = GetCapture();
132 /* If no capture HWND, find window which contains the mouse position.
133 * Also find the position of the cursor hot spot (hittest) */
134 if( !hWnd )
136 ht = hittest = WINPOS_WindowFromPoint( pWndScope, pt, &pWnd );
137 if( !pWnd ) pWnd = WIN_GetDesktop();
138 else WIN_LockWndPtr(pWnd);
139 hWnd = pWnd->hwndSelf;
141 else
143 ht = hittest = HTCLIENT;
144 pWnd = WIN_FindWndPtr(hWnd);
145 if (queue)
146 ht = PERQDATA_GetCaptureInfo( queue->pQData );
149 /* Save hittest for return */
150 *pHitTest = hittest;
152 /* stop if not the right queue */
154 if (pWnd->hmemTaskQ != hQ)
156 /* Not for the current task */
157 if (queue) QUEUE_ClearWakeBit( queue, QS_MOUSE );
158 /* Wake up the other task */
159 QUEUE_Unlock( queue );
160 queue = (MESSAGEQUEUE *)QUEUE_Lock( pWnd->hmemTaskQ );
161 if (queue) QUEUE_SetWakeBit( queue, QS_MOUSE );
163 QUEUE_Unlock( queue );
164 retvalue = SYSQ_MSG_ABANDON;
165 goto END;
168 /* check if hWnd is within hWndScope */
170 if( hTopWnd && hWnd != hTopWnd )
171 if( !IsChild(hTopWnd, hWnd) )
173 QUEUE_Unlock( queue );
174 retvalue = SYSQ_MSG_CONTINUE;
175 goto END;
178 /* Was it a mouse click message */
179 if( mouseClick )
181 /* translate double clicks -
182 * note that ...MOUSEMOVEs can slip in between
183 * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
185 if(GetClassLongA(hWnd, GCL_STYLE) & CS_DBLCLKS || ht != HTCLIENT )
187 if ((message == clk_message) && (hWnd == clk_hwnd) &&
188 (msg->time - dblclk_time_limit < doubleClickSpeed) &&
189 (abs(msg->pt.x - clk_pos.x) < GetSystemMetrics(SM_CXDOUBLECLK)/2) &&
190 (abs(msg->pt.y - clk_pos.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2))
192 message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
193 mouseClick++; /* == 2 */
197 /* save mouse position */
198 screen_pt = pt;
199 *pScreen_pt = pt;
201 if (hittest != HTCLIENT)
203 message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
204 msg->wParam = hittest;
206 else
207 ScreenToClient16( hWnd, &pt );
209 /* check message filter */
211 if (!MSG_CheckFilter(message, first, last))
213 QUEUE_Unlock(queue);
214 retvalue = SYSQ_MSG_CONTINUE;
215 goto END;
218 /* Update global hCursorQueue */
219 hCursorQueue = queue->self;
221 /* Update static double click conditions */
222 if( remove && mouseClick )
224 if( mouseClick == 1 )
226 /* set conditions */
227 dblclk_time_limit = msg->time;
228 clk_message = msg->message;
229 clk_hwnd = hWnd;
230 clk_pos = screen_pt;
231 } else
232 /* got double click - zero them out */
233 dblclk_time_limit = clk_hwnd = 0;
236 QUEUE_Unlock(queue);
238 /* Update message params */
239 msg->hwnd = hWnd;
240 msg->message = message;
241 msg->lParam = MAKELONG( pt.x, pt.y );
242 retvalue = SYSQ_MSG_ACCEPT;
244 END:
245 WIN_ReleaseWndPtr(pWnd);
247 /* Return mouseclick flag */
248 *pmouseClick = mouseClick;
250 return retvalue;
254 /***********************************************************************
255 * MSG_ProcessMouseMsg
257 * Processes a translated mouse hardware event.
258 * The passed in msg structure should contain the updated hWnd,
259 * lParam, wParam and message fields from MSG_TranslateMouseMsg.
261 * Returns:
263 * SYSQ_MSG_SKIP - Message should be skipped entirely (in this case
264 * HIWORD contains hit test code). Continue translating..
265 * SYSQ_MSG_ACCEPT - the translated message must be passed to the user
266 * MSG_PeekHardwareMsg should return TRUE.
268 static DWORD MSG_ProcessMouseMsg( MSG *msg, BOOL remove, INT16 hittest,
269 POINT16 screen_pt, BOOL mouseClick )
271 WND *pWnd;
272 HWND hWnd = msg->hwnd;
273 INT16 sendSC = (GetCapture() == 0);
274 UINT message = msg->message;
275 BOOL eatMsg = FALSE;
276 DWORD retvalue;
278 pWnd = WIN_FindWndPtr(hWnd);
280 /* call WH_MOUSE */
282 if (HOOK_IsHooked( WH_MOUSE ))
284 SYSQ_STATUS ret = 0;
285 MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
286 if( hook )
288 hook->pt = screen_pt;
289 hook->hwnd = hWnd;
290 hook->wHitTestCode = hittest;
291 hook->dwExtraInfo = 0;
292 ret = HOOK_CallHooks16( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
293 message, (LPARAM)SEGPTR_GET(hook) );
294 SEGPTR_FREE(hook);
296 if( ret )
298 retvalue = MAKELONG((INT16)SYSQ_MSG_SKIP, hittest);
299 goto END;
303 if (message >= WM_NCMOUSEFIRST && message <= WM_NCMOUSELAST)
304 message += WM_MOUSEFIRST - WM_NCMOUSEFIRST;
306 if ((hittest == HTERROR) || (hittest == HTNOWHERE))
307 eatMsg = sendSC = 1;
308 else if( remove && mouseClick )
310 HWND hwndTop = WIN_GetTopParent( hWnd );
312 if( sendSC )
314 /* Send the WM_PARENTNOTIFY,
315 * note that even for double/nonclient clicks
316 * notification message is still WM_L/M/RBUTTONDOWN.
319 MSG_SendParentNotify( pWnd, message, 0, MAKELPARAM(screen_pt.x, screen_pt.y) );
321 /* Activate the window if needed */
323 if (hWnd != GetActiveWindow() && hWnd != GetDesktopWindow())
325 LONG ret = SendMessageA( hWnd, WM_MOUSEACTIVATE, hwndTop,
326 MAKELONG( hittest, message ) );
328 if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
329 eatMsg = TRUE;
331 if (((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
332 && hwndTop != GetForegroundWindow() )
334 if (!WINPOS_SetActiveWindow( hwndTop, TRUE , TRUE ))
335 eatMsg = TRUE;
339 } else sendSC = (remove && sendSC);
341 /* Send the WM_SETCURSOR message */
343 if (sendSC)
345 /* Windows sends the normal mouse message as the message parameter
346 in the WM_SETCURSOR message even if it's non-client mouse message */
347 SendMessageA( hWnd, WM_SETCURSOR, hWnd,
348 MAKELONG( hittest, message ));
350 if (eatMsg)
352 retvalue = MAKELONG( (UINT16)SYSQ_MSG_SKIP, hittest);
353 goto END;
356 retvalue = SYSQ_MSG_ACCEPT;
357 END:
358 WIN_ReleaseWndPtr(pWnd);
360 return retvalue;
364 /***********************************************************************
365 * MSG_TranslateKbdMsg
367 * Translate an keyboard hardware event into a real message.
369 static DWORD MSG_TranslateKbdMsg( HWND hTopWnd, DWORD first, DWORD last,
370 MSG *msg, BOOL remove )
372 WORD message = msg->message;
373 HWND hWnd = GetFocus();
374 WND *pWnd;
376 /* Should check Ctrl-Esc and PrintScreen here */
378 if (!hWnd)
380 /* Send the message to the active window instead, */
381 /* translating messages to their WM_SYS equivalent */
383 hWnd = GetActiveWindow();
385 if( message < WM_SYSKEYDOWN )
386 message += WM_SYSKEYDOWN - WM_KEYDOWN;
388 pWnd = WIN_FindWndPtr( hWnd );
389 if (pWnd && (pWnd->hmemTaskQ != GetFastQueue16()))
391 /* Not for the current task */
392 MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() );
393 if (queue) QUEUE_ClearWakeBit( queue, QS_KEY );
394 QUEUE_Unlock( queue );
396 /* Wake up the other task */
397 queue = (MESSAGEQUEUE *)QUEUE_Lock( pWnd->hmemTaskQ );
398 if (queue) QUEUE_SetWakeBit( queue, QS_KEY );
399 QUEUE_Unlock( queue );
400 WIN_ReleaseWndPtr(pWnd);
401 return SYSQ_MSG_ABANDON;
403 WIN_ReleaseWndPtr(pWnd);
405 if (hTopWnd && hWnd != hTopWnd)
406 if (!IsChild(hTopWnd, hWnd)) return SYSQ_MSG_CONTINUE;
407 if (!MSG_CheckFilter(message, first, last)) return SYSQ_MSG_CONTINUE;
409 msg->hwnd = hWnd;
410 msg->message = message;
412 return SYSQ_MSG_ACCEPT;
416 /***********************************************************************
417 * MSG_ProcessKbdMsg
419 * Processes a translated keyboard message
421 static DWORD MSG_ProcessKbdMsg( MSG *msg, BOOL remove )
423 /* Handle F1 key by sending out WM_HELP message */
424 if ((msg->message == WM_KEYUP) &&
425 (msg->wParam == VK_F1) &&
426 remove &&
427 (msg->hwnd != GetDesktopWindow()) &&
428 !MENU_IsMenuActive())
430 HELPINFO hi;
431 WND *pWnd = WIN_FindWndPtr(msg->hwnd);
433 if (NULL != pWnd)
435 hi.cbSize = sizeof(HELPINFO);
436 hi.iContextType = HELPINFO_WINDOW;
437 hi.iCtrlId = pWnd->wIDmenu;
438 hi.hItemHandle = msg->hwnd;
439 hi.dwContextId = pWnd->helpContext;
440 hi.MousePos = msg->pt;
441 SendMessageA(msg->hwnd, WM_HELP, 0, (LPARAM)&hi);
443 WIN_ReleaseWndPtr(pWnd);
446 return (HOOK_CallHooks16( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE,
447 LOWORD (msg->wParam), msg->lParam )
448 ? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT);
452 /***********************************************************************
453 * MSG_JournalRecordMsg
455 * Build an EVENTMSG structure and call JOURNALRECORD hook
457 static void MSG_JournalRecordMsg( MSG *msg )
459 EVENTMSG *event = (EVENTMSG *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG));
460 if (!event) return;
461 event->message = msg->message;
462 event->time = msg->time;
463 if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
465 event->paramL = (msg->wParam & 0xFF) | (HIWORD(msg->lParam) << 8);
466 event->paramH = msg->lParam & 0x7FFF;
467 if (HIWORD(msg->lParam) & 0x0100)
468 event->paramH |= 0x8000; /* special_key - bit */
469 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
471 else if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
473 event->paramL = LOWORD(msg->lParam); /* X pos */
474 event->paramH = HIWORD(msg->lParam); /* Y pos */
475 ClientToScreen16( msg->hwnd, (LPPOINT16)&event->paramL );
476 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
478 else if ((msg->message >= WM_NCMOUSEFIRST) &&
479 (msg->message <= WM_NCMOUSELAST))
481 event->paramL = LOWORD(msg->lParam); /* X pos */
482 event->paramH = HIWORD(msg->lParam); /* Y pos */
483 event->message += WM_MOUSEMOVE-WM_NCMOUSEMOVE;/* give no info about NC area */
484 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
487 HeapFree(SystemHeap, 0, event);
490 /***********************************************************************
491 * MSG_JournalPlayBackMsg
493 * Get an EVENTMSG struct via call JOURNALPLAYBACK hook function
495 static int MSG_JournalPlayBackMsg(void)
497 EVENTMSG *tmpMsg;
498 long wtime,lParam,wParam;
499 WORD keyDown,i,result=0;
501 if ( HOOK_IsHooked( WH_JOURNALPLAYBACK ) )
503 tmpMsg = (EVENTMSG *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG));
504 if (!tmpMsg) return result;
506 wtime=HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_GETNEXT, 0,
507 (LPARAM) tmpMsg );
508 /* TRACE(msg,"Playback wait time =%ld\n",wtime); */
509 if (wtime<=0)
511 wtime=0;
512 if ((tmpMsg->message>= WM_KEYFIRST) && (tmpMsg->message <= WM_KEYLAST))
514 wParam=tmpMsg->paramL & 0xFF;
515 lParam=MAKELONG(tmpMsg->paramH&0x7ffff,tmpMsg->paramL>>8);
516 if (tmpMsg->message == WM_KEYDOWN || tmpMsg->message == WM_SYSKEYDOWN)
518 for (keyDown=i=0; i<256 && !keyDown; i++)
519 if (InputKeyStateTable[i] & 0x80)
520 keyDown++;
521 if (!keyDown)
522 lParam |= 0x40000000;
523 AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] |= 0x80;
525 else /* WM_KEYUP, WM_SYSKEYUP */
527 lParam |= 0xC0000000;
528 AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] &= ~0x80;
530 if (InputKeyStateTable[VK_MENU] & 0x80)
531 lParam |= 0x20000000;
532 if (tmpMsg->paramH & 0x8000) /*special_key bit*/
533 lParam |= 0x01000000;
534 hardware_event( tmpMsg->message & 0xffff, LOWORD(wParam), lParam,
535 0, 0, tmpMsg->time, 0 );
537 else
539 if ((tmpMsg->message>= WM_MOUSEFIRST) && (tmpMsg->message <= WM_MOUSELAST))
541 switch (tmpMsg->message)
543 case WM_LBUTTONDOWN:
544 MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=TRUE;break;
545 case WM_LBUTTONUP:
546 MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=FALSE;break;
547 case WM_MBUTTONDOWN:
548 MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=TRUE;break;
549 case WM_MBUTTONUP:
550 MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=FALSE;break;
551 case WM_RBUTTONDOWN:
552 MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=TRUE;break;
553 case WM_RBUTTONUP:
554 MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=FALSE;break;
556 AsyncKeyStateTable[VK_LBUTTON]= InputKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0;
557 AsyncKeyStateTable[VK_MBUTTON]= InputKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0;
558 AsyncKeyStateTable[VK_RBUTTON]= InputKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0;
559 SetCursorPos(tmpMsg->paramL,tmpMsg->paramH);
560 lParam=MAKELONG(tmpMsg->paramL,tmpMsg->paramH);
561 wParam=0;
562 if (MouseButtonsStates[0]) wParam |= MK_LBUTTON;
563 if (MouseButtonsStates[1]) wParam |= MK_MBUTTON;
564 if (MouseButtonsStates[2]) wParam |= MK_RBUTTON;
565 hardware_event( tmpMsg->message & 0xffff, LOWORD (wParam), lParam,
566 tmpMsg->paramL, tmpMsg->paramH, tmpMsg->time, 0 );
569 HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_SKIP, 0,
570 (LPARAM) tmpMsg);
572 else
575 if( tmpMsg->message == WM_QUEUESYNC )
576 if (HOOK_IsHooked( WH_CBT ))
577 HOOK_CallHooksA( WH_CBT, HCBT_QS, 0, 0L);
579 result= QS_MOUSE | QS_KEY; /* ? */
581 HeapFree(SystemHeap, 0, tmpMsg);
583 return result;
586 /***********************************************************************
587 * MSG_PeekHardwareMsg
589 * Peek for a hardware message matching the hwnd and message filters.
591 static BOOL MSG_PeekHardwareMsg( MSG *msg, HWND hwnd, DWORD first, DWORD last,
592 BOOL remove )
594 /* FIXME: should deal with MSG32 instead of MSG16 */
596 DWORD status = SYSQ_MSG_ACCEPT;
597 MESSAGEQUEUE *sysMsgQueue = QUEUE_GetSysQueue();
598 enum { MOUSE_MSG = 0, KEYBOARD_MSG, HARDWARE_MSG } msgType;
599 QMSG *nextqmsg, *qmsg = 0;
600 BOOL bRet = FALSE;
602 EnterCriticalSection(&sysMsgQueue->cSection);
604 /* Loop through the Q and translate the message we wish to process
605 * while we own the lock. Based on the translation status (abandon/cont/accept)
606 * we then process the message accordingly
609 for ( qmsg = sysMsgQueue->firstMsg; qmsg; qmsg = nextqmsg )
611 INT16 hittest;
612 POINT16 screen_pt;
613 BOOL mouseClick;
615 *msg = qmsg->msg;
617 nextqmsg = qmsg->nextMsg;
619 /* Translate message */
621 if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
623 HWND hWndScope = (HWND)qmsg->extraInfo;
624 WND *tmpWnd = (Options.managed && IsWindow(hWndScope) )
625 ? WIN_FindWndPtr(hWndScope) : WIN_GetDesktop();
627 status = MSG_TranslateMouseMsg(hwnd, first, last, msg, remove, tmpWnd,
628 &hittest, &screen_pt, &mouseClick );
629 msgType = MOUSE_MSG;
631 WIN_ReleaseWndPtr(tmpWnd);
634 else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
636 status = MSG_TranslateKbdMsg(hwnd, first, last, msg, remove);
637 msgType = KEYBOARD_MSG;
639 else /* Non-standard hardware event */
641 HARDWAREHOOKSTRUCT16 *hook;
642 msgType = HARDWARE_MSG;
643 if ((hook = SEGPTR_NEW(HARDWAREHOOKSTRUCT16)))
645 BOOL ret;
646 hook->hWnd = msg->hwnd;
647 hook->wMessage = msg->message & 0xffff;
648 hook->wParam = LOWORD (msg->wParam);
649 hook->lParam = msg->lParam;
650 ret = HOOK_CallHooks16( WH_HARDWARE,
651 remove ? HC_ACTION : HC_NOREMOVE,
652 0, (LPARAM)SEGPTR_GET(hook) );
653 SEGPTR_FREE(hook);
654 if (ret)
656 QUEUE_RemoveMsg( sysMsgQueue, qmsg );
657 continue;
659 status = SYSQ_MSG_ACCEPT;
664 switch (LOWORD(status))
666 case SYSQ_MSG_ACCEPT:
668 /* Remove the message from the system msg Q while it is still locked,
669 * before accepting it */
670 if (remove)
672 if (HOOK_IsHooked( WH_JOURNALRECORD )) MSG_JournalRecordMsg( msg );
673 QUEUE_RemoveMsg( sysMsgQueue, qmsg );
675 /* Now actually process the message, after we unlock the system msg Q.
676 * We should not hold on to the crst since SendMessage calls during processing
677 * will potentially cause callbacks to PeekMessage from the application.
678 * If we're holding the crst and QUEUE_WaitBits is called with a
679 * QS_SENDMESSAGE mask we will deadlock in hardware_event() when a
680 * message is being posted to the Q.
682 LeaveCriticalSection(&sysMsgQueue->cSection);
683 if( msgType == KEYBOARD_MSG )
684 status = MSG_ProcessKbdMsg( msg, remove );
685 else if ( msgType == MOUSE_MSG )
686 status = MSG_ProcessMouseMsg( msg, remove, hittest, screen_pt, mouseClick );
688 /* Reclaim the sys msg Q crst */
689 EnterCriticalSection(&sysMsgQueue->cSection);
691 /* Pass the translated message to the user if it was accepted */
692 if (status == SYSQ_MSG_ACCEPT)
693 break;
695 /* If not accepted, fall through into the SYSQ_MSG_SKIP case */
698 case SYSQ_MSG_SKIP:
699 if (HOOK_IsHooked( WH_CBT ))
701 if( msgType == KEYBOARD_MSG )
702 HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED,
703 LOWORD (msg->wParam), msg->lParam );
704 else if ( msgType == MOUSE_MSG )
706 MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
707 if (hook)
709 CONV_POINT32TO16( &msg->pt,&hook->pt );
710 hook->hwnd = msg->hwnd;
711 hook->wHitTestCode = HIWORD(status);
712 hook->dwExtraInfo = 0;
713 HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message & 0xffff,
714 (LPARAM)SEGPTR_GET(hook) );
715 SEGPTR_FREE(hook);
720 /* If the message was removed earlier set up nextqmsg so that we start
721 * at the top of the queue again. We need to do this since our next pointer
722 * could be invalid due to us unlocking the system message Q to process the message.
723 * If not removed just refresh nextqmsg to point to the next msg.
725 if (remove)
726 nextqmsg = sysMsgQueue->firstMsg;
727 else
728 nextqmsg = qmsg->nextMsg;
730 continue;
732 case SYSQ_MSG_CONTINUE:
733 continue;
735 case SYSQ_MSG_ABANDON:
736 bRet = FALSE;
737 goto END;
740 bRet = TRUE;
741 goto END;
744 END:
745 LeaveCriticalSection(&sysMsgQueue->cSection);
746 return bRet;
750 /**********************************************************************
751 * SetDoubleClickTime16 (USER.20)
753 void WINAPI SetDoubleClickTime16( UINT16 interval )
755 SetDoubleClickTime( interval );
759 /**********************************************************************
760 * SetDoubleClickTime (USER32.480)
762 BOOL WINAPI SetDoubleClickTime( UINT interval )
764 doubleClickSpeed = interval ? interval : 500;
765 return TRUE;
769 /**********************************************************************
770 * GetDoubleClickTime16 (USER.21)
772 UINT16 WINAPI GetDoubleClickTime16(void)
774 return doubleClickSpeed;
778 /**********************************************************************
779 * GetDoubleClickTime (USER32.239)
781 UINT WINAPI GetDoubleClickTime(void)
783 return doubleClickSpeed;
787 /***********************************************************************
788 * MSG_SendMessageInterThread
790 * Implementation of an inter-task SendMessage.
791 * Return values:
792 * 0 if error or timeout
793 * 1 if successflul
795 static LRESULT MSG_SendMessageInterThread( HQUEUE16 hDestQueue,
796 HWND hwnd, UINT msg,
797 WPARAM wParam, LPARAM lParam,
798 DWORD timeout, WORD flags,
799 LRESULT *pRes)
801 MESSAGEQUEUE *queue, *destQ;
802 SMSG *smsg;
803 LRESULT retVal = 1;
804 int iWndsLocks;
806 *pRes = 0;
808 if (IsTaskLocked16() || !IsWindow(hwnd))
809 return 0;
811 /* create a SMSG structure to hold SendMessage() parameters */
812 if (! (smsg = (SMSG *) HeapAlloc( SystemHeap, 0, sizeof(SMSG) )) )
813 return 0;
814 if (!(queue = (MESSAGEQUEUE*)QUEUE_Lock( GetFastQueue16() ))) return 0;
816 if (!(destQ = (MESSAGEQUEUE*)QUEUE_Lock( hDestQueue )))
818 QUEUE_Unlock( queue );
819 return 0;
822 TRACE_(sendmsg)("SM: %s [%04x] (%04x -> %04x)\n",
823 SPY_GetMsgName(msg), msg, queue->self, hDestQueue );
825 /* fill up SMSG structure */
826 smsg->hWnd = hwnd;
827 smsg->msg = msg;
828 smsg->wParam = wParam;
829 smsg->lParam = lParam;
831 smsg->lResult = 0;
832 smsg->hSrcQueue = GetFastQueue16();
833 smsg->hDstQueue = hDestQueue;
834 smsg->flags = flags;
836 /* add smsg struct in the processing SM list of the source queue */
837 QUEUE_AddSMSG(queue, SM_PROCESSING_LIST, smsg);
839 /* add smsg struct in the pending list of the destination queue */
840 if (QUEUE_AddSMSG(destQ, SM_PENDING_LIST, smsg) == FALSE)
841 return 0;
843 iWndsLocks = WIN_SuspendWndsLock();
845 /* force destination task to run next, if 16 bit threads */
846 if ( THREAD_IsWin16(NtCurrentTeb()) && THREAD_IsWin16(destQ->teb) )
847 DirectedYield16( destQ->teb->htask16 );
849 /* wait for the result, note that 16-bit apps almost always get out of
850 * DirectedYield() with SMSG_HAVE_RESULT flag already set */
852 while ( TRUE )
855 * The sequence is crucial to avoid deadlock situations:
856 * - first, we clear the QS_SMRESULT bit
857 * - then, we check the SMSG_HAVE_RESULT bit
858 * - only if this isn't set, we enter the wait state.
860 * As the receiver first sets the SMSG_HAVE_RESULT and then wakes us,
861 * we are guaranteed that -should we now clear the QS_SMRESULT that
862 * was signalled already by the receiver- we will not start waiting.
865 if ( smsg->flags & SMSG_HAVE_RESULT )
867 got:
868 *pRes = smsg->lResult;
869 TRACE_(sendmsg)("smResult = %08x\n", (unsigned)*pRes );
870 break;
873 QUEUE_ClearWakeBit( queue, QS_SMRESULT );
875 if ( smsg->flags & SMSG_HAVE_RESULT )
876 goto got;
878 if( QUEUE_WaitBits( QS_SMRESULT, timeout ) == 0 )
880 /* return with timeout */
881 SetLastError( 0 );
882 retVal = 0;
883 break;
886 WIN_RestoreWndsLock(iWndsLocks);
888 /* remove the smsg from the processingg list of the source queue */
889 QUEUE_RemoveSMSG( queue, SM_PROCESSING_LIST, smsg );
891 /* Note: the destination thread is in charge of removing the smsg from
892 the pending list */
894 /* In the case of an early reply (or a timeout), sender thread will
895 released the smsg structure if the receiver thread is done
896 (SMSG_RECEIVED set). If the receiver thread isn't done,
897 SMSG_RECEIVER_CLEANS_UP flag is set, and it will be the receiver
898 responsability to released smsg */
899 EnterCriticalSection( &queue->cSection );
901 if (smsg->flags & SMSG_RECEIVED)
902 HeapFree(SystemHeap, 0, smsg);
903 else
904 smsg->flags |= SMSG_RECEIVER_CLEANS;
906 LeaveCriticalSection( &queue->cSection );
909 QUEUE_Unlock( queue );
910 QUEUE_Unlock( destQ );
912 TRACE_(sendmsg)("done!\n");
913 return retVal;
917 /***********************************************************************
918 * ReplyMessage16 (USER.115)
920 void WINAPI ReplyMessage16( LRESULT result )
922 ReplyMessage( result );
925 /***********************************************************************
926 * ReplyMessage (USER.115)
928 BOOL WINAPI ReplyMessage( LRESULT result )
930 MESSAGEQUEUE *senderQ = 0;
931 MESSAGEQUEUE *queue = 0;
932 SMSG *smsg;
933 BOOL ret = FALSE;
935 if (!(queue = (MESSAGEQUEUE*)QUEUE_Lock( GetFastQueue16() )))
936 return FALSE;
938 TRACE_(sendmsg)("ReplyMessage, queue %04x\n", queue->self);
941 if ( !(smsg = queue->smWaiting)
942 || !(senderQ = QUEUE_Lock( smsg->hSrcQueue )) )
943 goto ReplyMessageEnd;
945 if ( !(smsg->flags & SMSG_ALREADY_REPLIED) )
947 /* This is the first reply, so pass result to sender */
949 TRACE_(sendmsg)("\trpm: smResult = %08lx\n", (long) result );
951 EnterCriticalSection(&senderQ->cSection);
953 smsg->lResult = result;
954 smsg->flags |= SMSG_ALREADY_REPLIED;
956 /* check if it's an early reply (called by the application) or
957 a regular reply (called by ReceiveMessage) */
958 if ( !(smsg->flags & SMSG_SENDING_REPLY) )
959 smsg->flags |= SMSG_EARLY_REPLY;
961 smsg->flags |= SMSG_HAVE_RESULT;
963 LeaveCriticalSection(&senderQ->cSection);
965 /* tell the sending task that its reply is ready */
966 QUEUE_SetWakeBit( senderQ, QS_SMRESULT );
968 /* switch directly to sending task (16 bit thread only) */
969 if ( THREAD_IsWin16( NtCurrentTeb() ) && THREAD_IsWin16( senderQ->teb ) )
970 DirectedYield16( senderQ->teb->htask16 );
972 ret = TRUE;
975 if (smsg->flags & SMSG_SENDING_REPLY)
977 /* remove msg from the waiting list, since this is the last
978 ReplyMessage */
979 QUEUE_RemoveSMSG( queue, SM_WAITING_LIST, smsg );
981 EnterCriticalSection(&senderQ->cSection);
983 /* tell the sender we're all done with smsg structure */
984 smsg->flags |= SMSG_RECEIVED;
986 /* sender will set SMSG_RECEIVER_CLEANS_UP if it wants the
987 receiver to clean up smsg, it could only happens when there is
988 an early reply or a timeout */
989 if ( smsg->flags & SMSG_RECEIVER_CLEANS )
991 TRACE_(sendmsg)("Receiver cleans up!\n" );
992 HeapFree( SystemHeap, 0, smsg );
995 LeaveCriticalSection(&senderQ->cSection);
998 ReplyMessageEnd:
999 if ( senderQ )
1000 QUEUE_Unlock( senderQ );
1001 if ( queue )
1002 QUEUE_Unlock( queue );
1004 return ret;
1007 /***********************************************************************
1008 * MSG_ConvertMsg
1010 static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType )
1012 UINT16 msg16;
1013 MSGPARAM16 mp16;
1015 switch ( MAKELONG( srcType, dstType ) )
1017 case MAKELONG( QMSG_WIN16, QMSG_WIN16 ):
1018 case MAKELONG( QMSG_WIN32A, QMSG_WIN32A ):
1019 case MAKELONG( QMSG_WIN32W, QMSG_WIN32W ):
1020 return TRUE;
1022 case MAKELONG( QMSG_WIN16, QMSG_WIN32A ):
1023 switch ( WINPROC_MapMsg16To32A( msg->message, msg->wParam,
1024 &msg->message, &msg->wParam, &msg->lParam ) )
1026 case 0:
1027 return TRUE;
1028 case 1:
1029 /* Pointer messages were mapped --> need to free allocated memory and fail */
1030 WINPROC_UnmapMsg16To32A( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 );
1031 default:
1032 return FALSE;
1035 case MAKELONG( QMSG_WIN16, QMSG_WIN32W ):
1036 switch ( WINPROC_MapMsg16To32W( msg->hwnd, msg->message, msg->wParam,
1037 &msg->message, &msg->wParam, &msg->lParam ) )
1039 case 0:
1040 return TRUE;
1041 case 1:
1042 /* Pointer messages were mapped --> need to free allocated memory and fail */
1043 WINPROC_UnmapMsg16To32W( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 );
1044 default:
1045 return FALSE;
1048 case MAKELONG( QMSG_WIN32A, QMSG_WIN16 ):
1049 mp16.lParam = msg->lParam;
1050 switch ( WINPROC_MapMsg32ATo16( msg->hwnd, msg->message, msg->wParam,
1051 &msg16, &mp16.wParam, &mp16.lParam ) )
1053 case 0:
1054 msg->message = msg16;
1055 msg->wParam = mp16.wParam;
1056 msg->lParam = mp16.lParam;
1057 return TRUE;
1058 case 1:
1059 /* Pointer messages were mapped --> need to free allocated memory and fail */
1060 WINPROC_UnmapMsg32ATo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 );
1061 default:
1062 return FALSE;
1065 case MAKELONG( QMSG_WIN32W, QMSG_WIN16 ):
1066 mp16.lParam = msg->lParam;
1067 switch ( WINPROC_MapMsg32WTo16( msg->hwnd, msg->message, msg->wParam,
1068 &msg16, &mp16.wParam, &mp16.lParam ) )
1070 case 0:
1071 msg->message = msg16;
1072 msg->wParam = mp16.wParam;
1073 msg->lParam = mp16.lParam;
1074 return TRUE;
1075 case 1:
1076 /* Pointer messages were mapped --> need to free allocated memory and fail */
1077 WINPROC_UnmapMsg32WTo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 );
1078 default:
1079 return FALSE;
1082 case MAKELONG( QMSG_WIN32A, QMSG_WIN32W ):
1083 switch ( WINPROC_MapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) )
1085 case 0:
1086 return TRUE;
1087 case 1:
1088 /* Pointer messages were mapped --> need to free allocated memory and fail */
1089 WINPROC_UnmapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, msg->lParam );
1090 default:
1091 return FALSE;
1094 case MAKELONG( QMSG_WIN32W, QMSG_WIN32A ):
1095 switch ( WINPROC_MapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) )
1097 case 0:
1098 return TRUE;
1099 case 1:
1100 /* Pointer messages were mapped --> need to free allocated memory and fail */
1101 WINPROC_UnmapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, msg->lParam );
1102 default:
1103 return FALSE;
1106 default:
1107 FIXME( "Invalid message type(s): %d / %d\n", srcType, dstType );
1108 return FALSE;
1112 /***********************************************************************
1113 * MSG_PeekMessage
1115 static BOOL MSG_PeekMessage( int type, LPMSG msg, HWND hwnd,
1116 DWORD first, DWORD last, WORD flags, BOOL peek )
1118 int mask;
1119 MESSAGEQUEUE *msgQueue;
1120 HQUEUE16 hQueue;
1121 POINT16 pt16;
1122 int iWndsLocks;
1124 mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */
1125 if (first || last)
1127 if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY;
1128 if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) ||
1129 ((first <= WM_NCMOUSELAST) && (last >= WM_NCMOUSEFIRST)) ) mask |= QS_MOUSE;
1130 if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER;
1131 if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER;
1132 if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT;
1134 else mask |= QS_MOUSE | QS_KEY | QS_TIMER | QS_PAINT;
1136 if (IsTaskLocked16()) flags |= PM_NOYIELD;
1138 /* Never yield on Win32 threads */
1139 if (!THREAD_IsWin16(NtCurrentTeb())) flags |= PM_NOYIELD;
1141 iWndsLocks = WIN_SuspendWndsLock();
1143 while(1)
1145 QMSG *qmsg;
1147 hQueue = GetFastQueue16();
1148 msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
1149 if (!msgQueue)
1151 WIN_RestoreWndsLock(iWndsLocks);
1152 return FALSE;
1154 msgQueue->changeBits = 0;
1156 /* First handle a message put by SendMessage() */
1158 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1159 QUEUE_ReceiveMessage( msgQueue );
1161 /* Now handle a WM_QUIT message */
1163 if (msgQueue->wPostQMsg &&
1164 (!first || WM_QUIT >= first) &&
1165 (!last || WM_QUIT <= last) )
1167 msg->hwnd = hwnd;
1168 msg->message = WM_QUIT;
1169 msg->wParam = msgQueue->wExitCode;
1170 msg->lParam = 0;
1171 if (flags & PM_REMOVE) msgQueue->wPostQMsg = 0;
1172 break;
1175 /* Now find a normal message */
1177 retry:
1178 if (((msgQueue->wakeBits & mask) & QS_POSTMESSAGE) &&
1179 ((qmsg = QUEUE_FindMsg( msgQueue, hwnd, first, last )) != 0))
1181 /* Try to convert message to requested type */
1182 MSG tmpMsg = qmsg->msg;
1183 if ( !MSG_ConvertMsg( &tmpMsg, qmsg->type, type ) )
1185 ERR( "Message of wrong type contains pointer parameters. Skipped!\n ");
1186 QUEUE_RemoveMsg( msgQueue, qmsg );
1187 goto retry;
1190 *msg = tmpMsg;
1191 msgQueue->GetMessageTimeVal = msg->time;
1192 CONV_POINT32TO16(&msg->pt, &pt16);
1193 msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
1194 msgQueue->GetMessageExtraInfoVal = qmsg->extraInfo;
1196 if (flags & PM_REMOVE) QUEUE_RemoveMsg( msgQueue, qmsg );
1197 break;
1200 msgQueue->changeBits |= MSG_JournalPlayBackMsg();
1202 /* Now find a hardware event */
1204 if (((msgQueue->wakeBits & mask) & (QS_MOUSE | QS_KEY)) &&
1205 MSG_PeekHardwareMsg( msg, hwnd, first, last, flags & PM_REMOVE ))
1207 /* Got one */
1208 msgQueue->GetMessageTimeVal = msg->time;
1209 CONV_POINT32TO16(&msg->pt, &pt16);
1210 msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
1211 msgQueue->GetMessageExtraInfoVal = 0; /* Always 0 for now */
1212 break;
1215 /* Check again for SendMessage */
1217 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1218 QUEUE_ReceiveMessage( msgQueue );
1220 /* Now find a WM_PAINT message */
1222 if ((msgQueue->wakeBits & mask) & QS_PAINT)
1224 WND* wndPtr;
1225 msg->hwnd = WIN_FindWinToRepaint( hwnd , hQueue );
1226 msg->message = WM_PAINT;
1227 msg->wParam = 0;
1228 msg->lParam = 0;
1230 if ((wndPtr = WIN_FindWndPtr(msg->hwnd)))
1232 if( wndPtr->dwStyle & WS_MINIMIZE &&
1233 (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON) )
1235 msg->message = WM_PAINTICON;
1236 msg->wParam = 1;
1239 if( !hwnd || msg->hwnd == hwnd || IsChild16(hwnd,msg->hwnd) )
1241 if( wndPtr->flags & WIN_INTERNAL_PAINT && !wndPtr->hrgnUpdate)
1243 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
1244 QUEUE_DecPaintCount( hQueue );
1246 WIN_ReleaseWndPtr(wndPtr);
1247 break;
1249 WIN_ReleaseWndPtr(wndPtr);
1253 /* Check for timer messages, but yield first */
1255 if (!(flags & PM_NOYIELD))
1257 UserYield16();
1258 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1259 QUEUE_ReceiveMessage( msgQueue );
1261 if ((msgQueue->wakeBits & mask) & QS_TIMER)
1263 if (TIMER_GetTimerMsg(msg, hwnd, hQueue, flags & PM_REMOVE)) break;
1266 if (peek)
1268 if (!(flags & PM_NOYIELD)) UserYield16();
1270 QUEUE_Unlock( msgQueue );
1271 WIN_RestoreWndsLock(iWndsLocks);
1272 return FALSE;
1274 msgQueue->wakeMask = mask;
1275 QUEUE_WaitBits( mask, INFINITE );
1276 QUEUE_Unlock( msgQueue );
1279 WIN_RestoreWndsLock(iWndsLocks);
1281 /* instead of unlocking queue for every break condition, all break
1282 condition will fall here */
1283 QUEUE_Unlock( msgQueue );
1285 /* We got a message */
1286 if (flags & PM_REMOVE)
1288 WORD message = msg->message;
1290 if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
1292 BYTE *p = &QueueKeyStateTable[msg->wParam & 0xff];
1294 if (!(*p & 0x80))
1295 *p ^= 0x01;
1296 *p |= 0x80;
1298 else if (message == WM_KEYUP || message == WM_SYSKEYUP)
1299 QueueKeyStateTable[msg->wParam & 0xff] &= ~0x80;
1302 if (peek)
1303 return TRUE;
1305 else
1306 return (msg->message != WM_QUIT);
1309 /***********************************************************************
1310 * MSG_InternalGetMessage
1312 * GetMessage() function for internal use. Behave like GetMessage(),
1313 * but also call message filters and optionally send WM_ENTERIDLE messages.
1314 * 'hwnd' must be the handle of the dialog or menu window.
1315 * 'code' is the message filter value (MSGF_??? codes).
1317 BOOL MSG_InternalGetMessage( int type, MSG *msg, HWND hwnd, HWND hwndOwner,
1318 WPARAM code, WORD flags, BOOL sendIdle, BOOL* idleSent )
1320 for (;;)
1322 if (sendIdle)
1324 if (!MSG_PeekMessage( type, msg, 0, 0, 0, flags, TRUE ))
1326 /* No message present -> send ENTERIDLE and wait */
1327 if (IsWindow(hwndOwner))
1329 SendMessageA( hwndOwner, WM_ENTERIDLE,
1330 code, (LPARAM)hwnd );
1332 if (idleSent!=NULL)
1333 *idleSent=TRUE;
1335 MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE );
1338 else /* Always wait for a message */
1339 MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE );
1341 /* Call message filters */
1343 if (HOOK_IsHooked( WH_SYSMSGFILTER ) || HOOK_IsHooked( WH_MSGFILTER ))
1345 MSG *pmsg = HeapAlloc( SystemHeap, 0, sizeof(MSG) );
1346 if (pmsg)
1348 BOOL ret;
1349 *pmsg = *msg;
1350 ret = (HOOK_CallHooksA( WH_SYSMSGFILTER, code, 0,
1351 (LPARAM) pmsg ) ||
1352 HOOK_CallHooksA( WH_MSGFILTER, code, 0,
1353 (LPARAM) pmsg ));
1355 HeapFree( SystemHeap, 0, pmsg );
1356 if (ret)
1358 /* Message filtered -> remove it from the queue */
1359 /* if it's still there. */
1360 if (!(flags & PM_REMOVE))
1361 MSG_PeekMessage( type, msg, 0, 0, 0, PM_REMOVE, TRUE );
1362 continue;
1367 return (msg->message != WM_QUIT);
1372 /***********************************************************************
1373 * PeekMessage32_16 (USER.819)
1375 BOOL16 WINAPI PeekMessage32_16( LPMSG16_32 lpmsg16_32, HWND16 hwnd,
1376 UINT16 first, UINT16 last, UINT16 flags,
1377 BOOL16 wHaveParamHigh )
1379 BOOL ret;
1380 MSG msg;
1382 ret = MSG_PeekMessage( QMSG_WIN16, &msg, hwnd, first, last, flags, TRUE );
1384 lpmsg16_32->msg.hwnd = msg.hwnd;
1385 lpmsg16_32->msg.message = msg.message;
1386 lpmsg16_32->msg.wParam = LOWORD(msg.wParam);
1387 lpmsg16_32->msg.lParam = msg.lParam;
1388 lpmsg16_32->msg.time = msg.time;
1389 lpmsg16_32->msg.pt.x = (INT16)msg.pt.x;
1390 lpmsg16_32->msg.pt.y = (INT16)msg.pt.y;
1392 if ( wHaveParamHigh )
1393 lpmsg16_32->wParamHigh = HIWORD(msg.wParam);
1395 return ret;
1398 /***********************************************************************
1399 * PeekMessage16 (USER.109)
1401 BOOL16 WINAPI PeekMessage16( LPMSG16 lpmsg, HWND16 hwnd,
1402 UINT16 first, UINT16 last, UINT16 flags )
1404 return PeekMessage32_16( (LPMSG16_32)lpmsg, hwnd, first, last, flags, FALSE );
1407 /***********************************************************************
1408 * PeekMessageA
1410 BOOL WINAPI PeekMessageA( LPMSG lpmsg, HWND hwnd,
1411 UINT min, UINT max, UINT wRemoveMsg)
1413 return MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
1416 /***********************************************************************
1417 * PeekMessageW Check queue for messages
1419 * Checks for a message in the thread's queue, filtered as for
1420 * GetMessage(). Returns immediately whether a message is available
1421 * or not.
1423 * Whether a retrieved message is removed from the queue is set by the
1424 * _wRemoveMsg_ flags, which should be one of the following values:
1426 * PM_NOREMOVE Do not remove the message from the queue.
1428 * PM_REMOVE Remove the message from the queue.
1430 * In addition, PM_NOYIELD may be combined into _wRemoveMsg_ to
1431 * request that the system not yield control during PeekMessage();
1432 * however applications may not rely on scheduling behavior.
1434 * RETURNS
1436 * Nonzero if a message is available and is retrieved, zero otherwise.
1438 * CONFORMANCE
1440 * ECMA-234, Win32
1443 BOOL WINAPI PeekMessageW(
1444 LPMSG lpmsg, /* buffer to receive message */
1445 HWND hwnd, /* restrict to messages for hwnd */
1446 UINT min, /* minimum message to receive */
1447 UINT max, /* maximum message to receive */
1448 UINT wRemoveMsg /* removal flags */
1451 return MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
1455 /***********************************************************************
1456 * GetMessage32_16 (USER.820)
1458 BOOL16 WINAPI GetMessage32_16( SEGPTR msg16_32, HWND16 hWnd, UINT16 first,
1459 UINT16 last, BOOL16 wHaveParamHigh )
1461 MSG32_16 *lpmsg16_32 = (MSG32_16 *)PTR_SEG_TO_LIN(msg16_32);
1462 MSG msg;
1464 MSG_PeekMessage( QMSG_WIN16, &msg, hWnd, first, last, PM_REMOVE, FALSE );
1466 lpmsg16_32->msg.hwnd = msg.hwnd;
1467 lpmsg16_32->msg.message = msg.message;
1468 lpmsg16_32->msg.wParam = LOWORD(msg.wParam);
1469 lpmsg16_32->msg.lParam = msg.lParam;
1470 lpmsg16_32->msg.time = msg.time;
1471 lpmsg16_32->msg.pt.x = (INT16)msg.pt.x;
1472 lpmsg16_32->msg.pt.y = (INT16)msg.pt.y;
1474 if ( wHaveParamHigh )
1475 lpmsg16_32->wParamHigh = HIWORD(msg.wParam);
1477 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1478 lpmsg16_32->msg.message, hWnd, first, last );
1480 HOOK_CallHooks16( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)msg16_32 );
1481 return lpmsg16_32->msg.message != WM_QUIT;
1484 /***********************************************************************
1485 * GetMessage16 (USER.108)
1487 BOOL16 WINAPI GetMessage16( SEGPTR msg, HWND16 hwnd, UINT16 first, UINT16 last)
1489 return GetMessage32_16( msg, hwnd, first, last, FALSE );
1492 /***********************************************************************
1493 * GetMessageA (USER32.270)
1495 BOOL WINAPI GetMessageA( MSG *lpmsg, HWND hwnd, UINT min, UINT max )
1497 MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
1499 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1500 lpmsg->message, hwnd, min, max );
1502 HOOK_CallHooksA( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
1503 return lpmsg->message != WM_QUIT;
1506 /***********************************************************************
1507 * GetMessageW (USER32.274) Retrieve next message
1509 * GetMessage retrieves the next event from the calling thread's
1510 * queue and deposits it in *lpmsg.
1512 * If _hwnd_ is not NULL, only messages for window _hwnd_ and its
1513 * children as specified by IsChild() are retrieved. If _hwnd_ is NULL
1514 * all application messages are retrieved.
1516 * _min_ and _max_ specify the range of messages of interest. If
1517 * min==max==0, no filtering is performed. Useful examples are
1518 * WM_KEYFIRST and WM_KEYLAST to retrieve keyboard input, and
1519 * WM_MOUSEFIRST and WM_MOUSELAST to retrieve mouse input.
1521 * WM_PAINT messages are not removed from the queue; they remain until
1522 * processed. Other messages are removed from the queue.
1524 * RETURNS
1526 * -1 on error, 0 if message is WM_QUIT, nonzero otherwise.
1528 * CONFORMANCE
1530 * ECMA-234, Win32
1533 BOOL WINAPI GetMessageW(
1534 MSG* lpmsg, /* buffer to receive message */
1535 HWND hwnd, /* restrict to messages for hwnd */
1536 UINT min, /* minimum message to receive */
1537 UINT max /* maximum message to receive */
1540 MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
1542 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1543 lpmsg->message, hwnd, min, max );
1545 HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
1546 return lpmsg->message != WM_QUIT;
1549 /***********************************************************************
1550 * MSG_PostToQueue
1552 static BOOL MSG_PostToQueue( HQUEUE16 hQueue, int type, HWND hwnd,
1553 UINT message, WPARAM wParam, LPARAM lParam )
1555 MSG msg;
1557 if ( !hQueue ) return FALSE;
1559 msg.hwnd = hwnd;
1560 msg.message = message;
1561 msg.wParam = wParam;
1562 msg.lParam = lParam;
1563 msg.time = GetTickCount();
1564 msg.pt.x = 0;
1565 msg.pt.y = 0;
1567 return QUEUE_AddMsg( hQueue, type, &msg, 0 );
1570 /***********************************************************************
1571 * MSG_PostMessage
1573 static BOOL MSG_PostMessage( int type, HWND hwnd, UINT message,
1574 WPARAM wParam, LPARAM lParam )
1576 HQUEUE16 hQueue;
1577 WND *wndPtr;
1579 if (hwnd == HWND_BROADCAST)
1581 WND *pDesktop = WIN_GetDesktop();
1582 TRACE("HWND_BROADCAST !\n");
1584 for (wndPtr=WIN_LockWndPtr(pDesktop->child); wndPtr; WIN_UpdateWndPtr(&wndPtr,wndPtr->next))
1586 if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
1588 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n",
1589 wndPtr->hwndSelf, message, wParam, lParam);
1590 MSG_PostToQueue( wndPtr->hmemTaskQ, type,
1591 wndPtr->hwndSelf, message, wParam, lParam );
1594 WIN_ReleaseDesktop();
1595 TRACE("End of HWND_BROADCAST !\n");
1596 return TRUE;
1599 wndPtr = WIN_FindWndPtr( hwnd );
1600 hQueue = wndPtr? wndPtr->hmemTaskQ : 0;
1601 WIN_ReleaseWndPtr(wndPtr);
1603 return MSG_PostToQueue( hQueue, type, hwnd, message, wParam, lParam );
1606 /***********************************************************************
1607 * PostMessage16 (USER.110)
1609 BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam,
1610 LPARAM lParam )
1612 return (BOOL16) MSG_PostMessage( QMSG_WIN16, hwnd, message, wParam, lParam );
1615 /***********************************************************************
1616 * PostMessageA (USER32.419)
1618 BOOL WINAPI PostMessageA( HWND hwnd, UINT message, WPARAM wParam,
1619 LPARAM lParam )
1621 return MSG_PostMessage( QMSG_WIN32A, hwnd, message, wParam, lParam );
1624 /***********************************************************************
1625 * PostMessageW (USER32.420)
1627 BOOL WINAPI PostMessageW( HWND hwnd, UINT message, WPARAM wParam,
1628 LPARAM lParam )
1630 return MSG_PostMessage( QMSG_WIN32W, hwnd, message, wParam, lParam );
1633 /***********************************************************************
1634 * PostAppMessage16 (USER.116)
1636 BOOL16 WINAPI PostAppMessage16( HTASK16 hTask, UINT16 message,
1637 WPARAM16 wParam, LPARAM lParam )
1639 return MSG_PostToQueue( GetTaskQueue16(hTask), QMSG_WIN16,
1640 0, message, wParam, lParam );
1643 /**********************************************************************
1644 * PostThreadMessageA (USER32.422)
1646 BOOL WINAPI PostThreadMessageA( DWORD idThread, UINT message,
1647 WPARAM wParam, LPARAM lParam )
1649 return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32A,
1650 0, message, wParam, lParam );
1653 /**********************************************************************
1654 * PostThreadMessageW (USER32.423)
1656 BOOL WINAPI PostThreadMessageW( DWORD idThread, UINT message,
1657 WPARAM wParam, LPARAM lParam )
1659 return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32W,
1660 0, message, wParam, lParam );
1664 /************************************************************************
1665 * MSG_CallWndProcHook32
1667 static void MSG_CallWndProcHook( LPMSG pmsg, BOOL bUnicode )
1669 CWPSTRUCT cwp;
1671 cwp.lParam = pmsg->lParam;
1672 cwp.wParam = pmsg->wParam;
1673 cwp.message = pmsg->message;
1674 cwp.hwnd = pmsg->hwnd;
1676 if (bUnicode) HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1677 else HOOK_CallHooksA( WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp );
1679 pmsg->lParam = cwp.lParam;
1680 pmsg->wParam = cwp.wParam;
1681 pmsg->message = cwp.message;
1682 pmsg->hwnd = cwp.hwnd;
1686 /***********************************************************************
1687 * MSG_SendMessage
1689 * return values: 0 if timeout occurs
1690 * 1 otherwise
1692 static LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam,
1693 LPARAM lParam, DWORD timeout, WORD flags,
1694 LRESULT *pRes)
1696 WND * wndPtr = 0;
1697 WND **list, **ppWnd;
1698 LRESULT ret = 1;
1700 *pRes = 0;
1702 if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
1704 *pRes = 1;
1706 if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1708 WIN_ReleaseDesktop();
1709 return 1;
1711 WIN_ReleaseDesktop();
1713 TRACE("HWND_BROADCAST !\n");
1714 for (ppWnd = list; *ppWnd; ppWnd++)
1716 WIN_UpdateWndPtr(&wndPtr,*ppWnd);
1717 if (!IsWindow(wndPtr->hwndSelf)) continue;
1718 if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
1720 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n",
1721 wndPtr->hwndSelf, msg, (DWORD)wParam, lParam);
1722 MSG_SendMessage( wndPtr->hwndSelf, msg, wParam, lParam,
1723 timeout, flags, pRes);
1726 WIN_ReleaseWndPtr(wndPtr);
1727 WIN_ReleaseWinArray(list);
1728 TRACE("End of HWND_BROADCAST !\n");
1729 return 1;
1732 if (HOOK_IsHooked( WH_CALLWNDPROC ))
1734 if (flags & SMSG_UNICODE)
1735 MSG_CallWndProcHook( (LPMSG)&hwnd, TRUE);
1736 else if (flags & SMSG_WIN32)
1737 MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE);
1738 else
1740 LPCWPSTRUCT16 pmsg;
1742 if ((pmsg = SEGPTR_NEW(CWPSTRUCT16)))
1744 pmsg->hwnd = hwnd & 0xffff;
1745 pmsg->message= msg & 0xffff;
1746 pmsg->wParam = wParam & 0xffff;
1747 pmsg->lParam = lParam;
1748 HOOK_CallHooks16( WH_CALLWNDPROC, HC_ACTION, 1,
1749 (LPARAM)SEGPTR_GET(pmsg) );
1750 hwnd = pmsg->hwnd;
1751 msg = pmsg->message;
1752 wParam = pmsg->wParam;
1753 lParam = pmsg->lParam;
1754 SEGPTR_FREE( pmsg );
1759 if (!(wndPtr = WIN_FindWndPtr( hwnd )))
1761 WARN("invalid hwnd %04x\n", hwnd );
1762 return 0;
1764 if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
1766 ret = 0; /* Don't send anything if the task is dying */
1767 goto END;
1769 if (flags & SMSG_WIN32)
1770 SPY_EnterMessage( SPY_SENDMESSAGE, hwnd, msg, wParam, lParam );
1771 else
1772 SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wParam, lParam );
1774 if (wndPtr->hmemTaskQ != GetFastQueue16())
1775 ret = MSG_SendMessageInterThread( wndPtr->hmemTaskQ, hwnd, msg,
1776 wParam, lParam, timeout, flags, pRes );
1777 else
1779 /* Call the right CallWindowProc flavor */
1780 if (flags & SMSG_UNICODE)
1781 *pRes = CallWindowProcW( (WNDPROC)wndPtr->winproc,
1782 hwnd, msg, wParam, lParam );
1783 else if (flags & SMSG_WIN32)
1784 *pRes = CallWindowProcA( (WNDPROC)wndPtr->winproc,
1785 hwnd, msg, wParam, lParam );
1786 else
1787 *pRes = CallWindowProc16( (WNDPROC16)wndPtr->winproc,
1788 (HWND16) hwnd, (UINT16) msg,
1789 (WPARAM16) wParam, lParam );
1792 if (flags & SMSG_WIN32)
1793 SPY_ExitMessage( SPY_RESULT_OK, hwnd, msg, *pRes );
1794 else
1795 SPY_ExitMessage( SPY_RESULT_OK16, hwnd, msg, *pRes );
1796 END:
1797 WIN_ReleaseWndPtr(wndPtr);
1798 return ret;
1802 /***********************************************************************
1803 * SendMessage16 (USER.111)
1805 LRESULT WINAPI SendMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
1806 LPARAM lParam)
1808 LRESULT res;
1809 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, 0, &res);
1810 return res;
1814 /***********************************************************************
1815 * SendMessageA (USER32.454)
1817 LRESULT WINAPI SendMessageA( HWND hwnd, UINT msg, WPARAM wParam,
1818 LPARAM lParam )
1820 LRESULT res;
1822 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE,
1823 SMSG_WIN32, &res);
1825 return res;
1829 /***********************************************************************
1830 * SendMessageW (USER32.459) Send Window Message
1832 * Sends a message to the window procedure of the specified window.
1833 * SendMessage() will not return until the called window procedure
1834 * either returns or calls ReplyMessage().
1836 * Use PostMessage() to send message and return immediately. A window
1837 * procedure may use InSendMessage() to detect
1838 * SendMessage()-originated messages.
1840 * Applications which communicate via HWND_BROADCAST may use
1841 * RegisterWindowMessage() to obtain a unique message to avoid conflicts
1842 * with other applications.
1844 * CONFORMANCE
1846 * ECMA-234, Win32
1848 LRESULT WINAPI SendMessageW(
1849 HWND hwnd, /* Window to send message to. If HWND_BROADCAST,
1850 the message will be sent to all top-level windows. */
1852 UINT msg, /* message */
1853 WPARAM wParam, /* message parameter */
1854 LPARAM lParam /* additional message parameter */
1856 LRESULT res;
1858 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE,
1859 SMSG_WIN32 | SMSG_UNICODE, &res);
1861 return res;
1865 /***********************************************************************
1866 * SendMessageTimeout16 (not a WINAPI)
1868 LRESULT WINAPI SendMessageTimeout16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
1869 LPARAM lParam, UINT16 flags,
1870 UINT16 timeout, LPWORD resultp)
1872 LRESULT ret;
1873 LRESULT msgRet;
1875 /* FIXME: need support for SMTO_BLOCK */
1877 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, 0, &msgRet);
1878 if (resultp) *resultp = (WORD) msgRet;
1879 return ret;
1883 /***********************************************************************
1884 * SendMessageTimeoutA (USER32.457)
1886 LRESULT WINAPI SendMessageTimeoutA( HWND hwnd, UINT msg, WPARAM wParam,
1887 LPARAM lParam, UINT flags,
1888 UINT timeout, LPDWORD resultp)
1890 LRESULT ret;
1891 LRESULT msgRet;
1893 /* FIXME: need support for SMTO_BLOCK */
1895 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, SMSG_WIN32,
1896 &msgRet);
1898 if (resultp) *resultp = (DWORD) msgRet;
1899 return ret;
1903 /***********************************************************************
1904 * SendMessageTimeoutW (USER32.458)
1906 LRESULT WINAPI SendMessageTimeoutW( HWND hwnd, UINT msg, WPARAM wParam,
1907 LPARAM lParam, UINT flags,
1908 UINT timeout, LPDWORD resultp)
1910 LRESULT ret;
1911 LRESULT msgRet;
1913 /* FIXME: need support for SMTO_BLOCK */
1915 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout,
1916 SMSG_WIN32 | SMSG_UNICODE, &msgRet);
1918 if (resultp) *resultp = (DWORD) msgRet;
1919 return ret;
1923 /***********************************************************************
1924 * WaitMessage (USER.112) (USER32.578) Suspend thread pending messages
1926 * WaitMessage() suspends a thread until events appear in the thread's
1927 * queue.
1929 * BUGS
1931 * Is supposed to return BOOL under Win32.
1933 * Thread-local message queues are not supported.
1935 * CONFORMANCE
1937 * ECMA-234, Win32
1940 void WINAPI WaitMessage( void )
1942 QUEUE_WaitBits( QS_ALLINPUT, INFINITE );
1945 /***********************************************************************
1946 * MsgWaitForMultipleObjects (USER32.400)
1948 DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE *pHandles,
1949 BOOL fWaitAll, DWORD dwMilliseconds,
1950 DWORD dwWakeMask )
1952 DWORD i;
1953 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
1954 DWORD ret;
1955 PDB * pdb = PROCESS_Current();
1957 HQUEUE16 hQueue = GetFastQueue16();
1958 MESSAGEQUEUE *msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
1959 if (!msgQueue) return WAIT_FAILED;
1961 if (nCount > MAXIMUM_WAIT_OBJECTS-1)
1963 SetLastError( ERROR_INVALID_PARAMETER );
1964 QUEUE_Unlock( msgQueue );
1965 return WAIT_FAILED;
1968 msgQueue->changeBits = 0;
1969 msgQueue->wakeMask = dwWakeMask;
1971 if (THREAD_IsWin16(NtCurrentTeb()))
1974 * This is a temporary solution to a big problem.
1975 * You see, the main thread of all Win32 programs is created as a 16 bit
1976 * task. This means that if you want on an event using Win32 synchronization
1977 * methods, the 16 bit scheduler is stopped and things might just stop happening.
1978 * This implements a semi-busy loop that checks the handles to wait on and
1979 * also the message queue. When either one is ready, the wait function returns.
1981 * This will all go away when the real Win32 threads are implemented for all
1982 * the threads of an applications. Including the main thread.
1984 DWORD curTime = GetCurrentTime();
1989 * Check the handles in the list.
1991 SetEvent ( pdb->idle_event );
1992 ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, 5L);
1995 * If the handles have been triggered, return.
1997 if (ret != WAIT_TIMEOUT)
1998 break;
2001 * Then, let the 16 bit scheduler do it's thing.
2003 Yield16();
2006 * If a message matching the wait mask has arrived, return.
2008 if (msgQueue->changeBits & dwWakeMask)
2010 ret = nCount;
2011 break;
2015 * And continue doing this until we hit the timeout.
2017 } while ((dwMilliseconds == INFINITE) || (GetCurrentTime()-curTime < dwMilliseconds) );
2019 else
2021 /* Add the thread event to the handle list */
2022 for (i = 0; i < nCount; i++)
2023 handles[i] = pHandles[i];
2024 handles[nCount] = msgQueue->hEvent;
2026 if ( pdb->main_queue == INVALID_HANDLE_VALUE16 ) pdb->main_queue = hQueue;
2027 if ( pdb->main_queue == hQueue ) SetEvent ( pdb->idle_event );
2028 ret = WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds );
2029 if ( pdb->main_queue == hQueue ) ResetEvent ( pdb->idle_event );
2033 QUEUE_Unlock( msgQueue );
2035 return ret;
2040 struct accent_char
2042 BYTE ac_accent;
2043 BYTE ac_char;
2044 BYTE ac_result;
2047 static const struct accent_char accent_chars[] =
2049 /* A good idea should be to read /usr/X11/lib/X11/locale/iso8859-x/Compose */
2050 {'`', 'A', '\300'}, {'`', 'a', '\340'},
2051 {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
2052 {'^', 'A', '\302'}, {'^', 'a', '\342'},
2053 {'~', 'A', '\303'}, {'~', 'a', '\343'},
2054 {'"', 'A', '\304'}, {'"', 'a', '\344'},
2055 {'O', 'A', '\305'}, {'o', 'a', '\345'},
2056 {'0', 'A', '\305'}, {'0', 'a', '\345'},
2057 {'A', 'A', '\305'}, {'a', 'a', '\345'},
2058 {'A', 'E', '\306'}, {'a', 'e', '\346'},
2059 {',', 'C', '\307'}, {',', 'c', '\347'},
2060 {'`', 'E', '\310'}, {'`', 'e', '\350'},
2061 {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
2062 {'^', 'E', '\312'}, {'^', 'e', '\352'},
2063 {'"', 'E', '\313'}, {'"', 'e', '\353'},
2064 {'`', 'I', '\314'}, {'`', 'i', '\354'},
2065 {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
2066 {'^', 'I', '\316'}, {'^', 'i', '\356'},
2067 {'"', 'I', '\317'}, {'"', 'i', '\357'},
2068 {'-', 'D', '\320'}, {'-', 'd', '\360'},
2069 {'~', 'N', '\321'}, {'~', 'n', '\361'},
2070 {'`', 'O', '\322'}, {'`', 'o', '\362'},
2071 {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
2072 {'^', 'O', '\324'}, {'^', 'o', '\364'},
2073 {'~', 'O', '\325'}, {'~', 'o', '\365'},
2074 {'"', 'O', '\326'}, {'"', 'o', '\366'},
2075 {'/', 'O', '\330'}, {'/', 'o', '\370'},
2076 {'`', 'U', '\331'}, {'`', 'u', '\371'},
2077 {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
2078 {'^', 'U', '\333'}, {'^', 'u', '\373'},
2079 {'"', 'U', '\334'}, {'"', 'u', '\374'},
2080 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
2081 {'T', 'H', '\336'}, {'t', 'h', '\376'},
2082 {'s', 's', '\337'}, {'"', 'y', '\377'},
2083 {'s', 'z', '\337'}, {'i', 'j', '\377'},
2084 /* iso-8859-2 uses this */
2085 {'<', 'L', '\245'}, {'<', 'l', '\265'}, /* caron */
2086 {'<', 'S', '\251'}, {'<', 's', '\271'},
2087 {'<', 'T', '\253'}, {'<', 't', '\273'},
2088 {'<', 'Z', '\256'}, {'<', 'z', '\276'},
2089 {'<', 'C', '\310'}, {'<', 'c', '\350'},
2090 {'<', 'E', '\314'}, {'<', 'e', '\354'},
2091 {'<', 'D', '\317'}, {'<', 'd', '\357'},
2092 {'<', 'N', '\322'}, {'<', 'n', '\362'},
2093 {'<', 'R', '\330'}, {'<', 'r', '\370'},
2094 {';', 'A', '\241'}, {';', 'a', '\261'}, /* ogonek */
2095 {';', 'E', '\312'}, {';', 'e', '\332'},
2096 {'\'', 'Z', '\254'}, {'\'', 'z', '\274'}, /* acute */
2097 {'\'', 'R', '\300'}, {'\'', 'r', '\340'},
2098 {'\'', 'L', '\305'}, {'\'', 'l', '\345'},
2099 {'\'', 'C', '\306'}, {'\'', 'c', '\346'},
2100 {'\'', 'N', '\321'}, {'\'', 'n', '\361'},
2101 /* collision whith S, from iso-8859-9 !!! */
2102 {',', 'S', '\252'}, {',', 's', '\272'}, /* cedilla */
2103 {',', 'T', '\336'}, {',', 't', '\376'},
2104 {'.', 'Z', '\257'}, {'.', 'z', '\277'}, /* dot above */
2105 {'/', 'L', '\243'}, {'/', 'l', '\263'}, /* slash */
2106 {'/', 'D', '\320'}, {'/', 'd', '\360'},
2107 {'(', 'A', '\303'}, {'(', 'a', '\343'}, /* breve */
2108 {'\275', 'O', '\325'}, {'\275', 'o', '\365'}, /* double acute */
2109 {'\275', 'U', '\334'}, {'\275', 'u', '\374'},
2110 {'0', 'U', '\332'}, {'0', 'u', '\372'}, /* ring above */
2111 /* iso-8859-3 uses this */
2112 {'/', 'H', '\241'}, {'/', 'h', '\261'}, /* slash */
2113 {'>', 'H', '\246'}, {'>', 'h', '\266'}, /* circumflex */
2114 {'>', 'J', '\254'}, {'>', 'j', '\274'},
2115 {'>', 'C', '\306'}, {'>', 'c', '\346'},
2116 {'>', 'G', '\330'}, {'>', 'g', '\370'},
2117 {'>', 'S', '\336'}, {'>', 's', '\376'},
2118 /* collision whith G( from iso-8859-9 !!! */
2119 {'(', 'G', '\253'}, {'(', 'g', '\273'}, /* breve */
2120 {'(', 'U', '\335'}, {'(', 'u', '\375'},
2121 /* collision whith I. from iso-8859-3 !!! */
2122 {'.', 'I', '\251'}, {'.', 'i', '\271'}, /* dot above */
2123 {'.', 'C', '\305'}, {'.', 'c', '\345'},
2124 {'.', 'G', '\325'}, {'.', 'g', '\365'},
2125 /* iso-8859-4 uses this */
2126 {',', 'R', '\243'}, {',', 'r', '\263'}, /* cedilla */
2127 {',', 'L', '\246'}, {',', 'l', '\266'},
2128 {',', 'G', '\253'}, {',', 'g', '\273'},
2129 {',', 'N', '\321'}, {',', 'n', '\361'},
2130 {',', 'K', '\323'}, {',', 'k', '\363'},
2131 {'~', 'I', '\245'}, {'~', 'i', '\265'}, /* tilde */
2132 {'-', 'E', '\252'}, {'-', 'e', '\272'}, /* macron */
2133 {'-', 'A', '\300'}, {'-', 'a', '\340'},
2134 {'-', 'I', '\317'}, {'-', 'i', '\357'},
2135 {'-', 'O', '\322'}, {'-', 'o', '\362'},
2136 {'-', 'U', '\336'}, {'-', 'u', '\376'},
2137 {'/', 'T', '\254'}, {'/', 't', '\274'}, /* slash */
2138 {'.', 'E', '\314'}, {'.', 'e', '\344'}, /* dot above */
2139 {';', 'I', '\307'}, {';', 'i', '\347'}, /* ogonek */
2140 {';', 'U', '\331'}, {';', 'u', '\371'},
2141 /* iso-8859-9 uses this */
2142 /* iso-8859-9 has really bad choosen G( S, and I. as they collide
2143 * whith the same letters on other iso-8859-x (that is they are on
2144 * different places :-( ), if you use turkish uncomment these and
2145 * comment out the lines in iso-8859-2 and iso-8859-3 sections
2146 * FIXME: should be dynamic according to chosen language
2147 * if/when Wine has turkish support.
2149 /* collision whith G( from iso-8859-3 !!! */
2150 /* {'(', 'G', '\320'}, {'(', 'g', '\360'}, */ /* breve */
2151 /* collision whith S, from iso-8859-2 !!! */
2152 /* {',', 'S', '\336'}, {',', 's', '\376'}, */ /* cedilla */
2153 /* collision whith I. from iso-8859-3 !!! */
2154 /* {'.', 'I', '\335'}, {'.', 'i', '\375'}, */ /* dot above */
2158 /***********************************************************************
2159 * MSG_DoTranslateMessage
2161 * Implementation of TranslateMessage.
2163 * TranslateMessage translates virtual-key messages into character-messages,
2164 * as follows :
2165 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
2166 * ditto replacing WM_* with WM_SYS*
2167 * This produces WM_CHAR messages only for keys mapped to ASCII characters
2168 * by the keyboard driver.
2170 static BOOL MSG_DoTranslateMessage( UINT message, HWND hwnd,
2171 WPARAM wParam, LPARAM lParam )
2173 static int dead_char;
2174 BYTE wp[2];
2176 if (message != WM_MOUSEMOVE && message != WM_TIMER)
2177 TRACE("(%s, %04X, %08lX)\n",
2178 SPY_GetMsgName(message), wParam, lParam );
2179 if(message >= WM_KEYFIRST && message <= WM_KEYLAST)
2180 TRACE_(key)("(%s, %04X, %08lX)\n",
2181 SPY_GetMsgName(message), wParam, lParam );
2183 if ((message != WM_KEYDOWN) && (message != WM_SYSKEYDOWN)) return FALSE;
2185 TRACE_(key)("Translating key %04X, scancode %04X\n",
2186 wParam, HIWORD(lParam) );
2188 /* FIXME : should handle ToAscii yielding 2 */
2189 switch (ToAscii(wParam, HIWORD(lParam),
2190 QueueKeyStateTable,(LPWORD)wp, 0))
2192 case 1 :
2193 message = (message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
2194 /* Should dead chars handling go in ToAscii ? */
2195 if (dead_char)
2197 int i;
2199 if (wp[0] == ' ') wp[0] = dead_char;
2200 if (dead_char == 0xa2) dead_char = '(';
2201 else if (dead_char == 0xa8) dead_char = '"';
2202 else if (dead_char == 0xb2) dead_char = ';';
2203 else if (dead_char == 0xb4) dead_char = '\'';
2204 else if (dead_char == 0xb7) dead_char = '<';
2205 else if (dead_char == 0xb8) dead_char = ',';
2206 else if (dead_char == 0xff) dead_char = '.';
2207 for (i = 0; i < sizeof(accent_chars)/sizeof(accent_chars[0]); i++)
2208 if ((accent_chars[i].ac_accent == dead_char) &&
2209 (accent_chars[i].ac_char == wp[0]))
2211 wp[0] = accent_chars[i].ac_result;
2212 break;
2214 dead_char = 0;
2216 TRACE_(key)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message));
2217 PostMessage16( hwnd, message, wp[0], lParam );
2218 return TRUE;
2220 case -1 :
2221 message = (message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
2222 dead_char = wp[0];
2223 TRACE_(key)("-1 -> PostMessage(%s)\n",
2224 SPY_GetMsgName(message));
2225 PostMessage16( hwnd, message, wp[0], lParam );
2226 return TRUE;
2228 return FALSE;
2232 /***********************************************************************
2233 * TranslateMessage16 (USER.113)
2235 BOOL16 WINAPI TranslateMessage16( const MSG16 *msg )
2237 return MSG_DoTranslateMessage( msg->message, msg->hwnd,
2238 msg->wParam, msg->lParam );
2242 /***********************************************************************
2243 * TranslateMessage32 (USER.821)
2245 BOOL16 WINAPI TranslateMessage32_16( const MSG32_16 *msg, BOOL16 wHaveParamHigh )
2247 WPARAM wParam;
2249 if (wHaveParamHigh)
2250 wParam = MAKELONG(msg->msg.wParam, msg->wParamHigh);
2251 else
2252 wParam = (WPARAM)msg->msg.wParam;
2254 return MSG_DoTranslateMessage( msg->msg.message, msg->msg.hwnd,
2255 wParam, msg->msg.lParam );
2258 /***********************************************************************
2259 * TranslateMessage (USER32.556)
2261 BOOL WINAPI TranslateMessage( const MSG *msg )
2263 return MSG_DoTranslateMessage( msg->message, msg->hwnd,
2264 msg->wParam, msg->lParam );
2268 /***********************************************************************
2269 * DispatchMessage16 (USER.114)
2271 LONG WINAPI DispatchMessage16( const MSG16* msg )
2273 WND * wndPtr;
2274 LONG retval;
2275 int painting;
2277 /* Process timer messages */
2278 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2280 if (msg->lParam)
2282 return CallWindowProc16( (WNDPROC16)msg->lParam, msg->hwnd,
2283 msg->message, msg->wParam, GetTickCount() );
2287 if (!msg->hwnd) return 0;
2288 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2289 if (!wndPtr->winproc)
2291 retval = 0;
2292 goto END;
2294 painting = (msg->message == WM_PAINT);
2295 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2297 SPY_EnterMessage( SPY_DISPATCHMESSAGE16, msg->hwnd, msg->message,
2298 msg->wParam, msg->lParam );
2299 retval = CallWindowProc16( (WNDPROC16)wndPtr->winproc,
2300 msg->hwnd, msg->message,
2301 msg->wParam, msg->lParam );
2302 SPY_ExitMessage( SPY_RESULT_OK16, msg->hwnd, msg->message, retval );
2304 WIN_ReleaseWndPtr(wndPtr);
2305 wndPtr = WIN_FindWndPtr(msg->hwnd);
2306 if (painting && wndPtr &&
2307 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2309 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2310 msg->hwnd);
2311 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2312 /* Validate the update region to avoid infinite WM_PAINT loop */
2313 ValidateRect( msg->hwnd, NULL );
2315 END:
2316 WIN_ReleaseWndPtr(wndPtr);
2317 return retval;
2321 /***********************************************************************
2322 * DispatchMessage32 (USER.822)
2324 LONG WINAPI DispatchMessage32_16( const MSG32_16* lpmsg16_32, BOOL16 wHaveParamHigh )
2326 if (wHaveParamHigh == FALSE)
2327 return DispatchMessage16(&(lpmsg16_32->msg));
2328 else
2330 MSG msg;
2332 msg.hwnd = lpmsg16_32->msg.hwnd;
2333 msg.message = lpmsg16_32->msg.message;
2334 msg.wParam = MAKELONG(lpmsg16_32->msg.wParam, lpmsg16_32->wParamHigh);
2335 msg.lParam = lpmsg16_32->msg.lParam;
2336 msg.time = lpmsg16_32->msg.time;
2337 msg.pt.x = (INT)lpmsg16_32->msg.pt.x;
2338 msg.pt.y = (INT)lpmsg16_32->msg.pt.y;
2339 return DispatchMessageA(&msg);
2343 /***********************************************************************
2344 * DispatchMessageA (USER32.141)
2346 LONG WINAPI DispatchMessageA( const MSG* msg )
2348 WND * wndPtr;
2349 LONG retval;
2350 int painting;
2352 /* Process timer messages */
2353 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2355 if (msg->lParam)
2357 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2358 return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
2359 msg->message, msg->wParam, GetTickCount() );
2363 if (!msg->hwnd) return 0;
2364 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2365 if (!wndPtr->winproc)
2367 retval = 0;
2368 goto END;
2370 painting = (msg->message == WM_PAINT);
2371 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2372 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2374 SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
2375 msg->wParam, msg->lParam );
2376 retval = CallWindowProcA( (WNDPROC)wndPtr->winproc,
2377 msg->hwnd, msg->message,
2378 msg->wParam, msg->lParam );
2379 SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval );
2381 WIN_ReleaseWndPtr(wndPtr);
2382 wndPtr = WIN_FindWndPtr(msg->hwnd);
2384 if (painting && wndPtr &&
2385 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2387 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2388 msg->hwnd);
2389 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2390 /* Validate the update region to avoid infinite WM_PAINT loop */
2391 ValidateRect( msg->hwnd, NULL );
2393 END:
2394 WIN_ReleaseWndPtr(wndPtr);
2395 return retval;
2399 /***********************************************************************
2400 * DispatchMessageW (USER32.142) Process Message
2402 * Process the message specified in the structure *_msg_.
2404 * If the lpMsg parameter points to a WM_TIMER message and the
2405 * parameter of the WM_TIMER message is not NULL, the lParam parameter
2406 * points to the function that is called instead of the window
2407 * procedure.
2409 * The message must be valid.
2411 * RETURNS
2413 * DispatchMessage() returns the result of the window procedure invoked.
2415 * CONFORMANCE
2417 * ECMA-234, Win32
2420 LONG WINAPI DispatchMessageW( const MSG* msg )
2422 WND * wndPtr;
2423 LONG retval;
2424 int painting;
2426 /* Process timer messages */
2427 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2429 if (msg->lParam)
2431 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2432 return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd,
2433 msg->message, msg->wParam, GetTickCount() );
2437 if (!msg->hwnd) return 0;
2438 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2439 if (!wndPtr->winproc)
2441 retval = 0;
2442 goto END;
2444 painting = (msg->message == WM_PAINT);
2445 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2446 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2448 SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
2449 msg->wParam, msg->lParam );
2450 retval = CallWindowProcW( (WNDPROC)wndPtr->winproc,
2451 msg->hwnd, msg->message,
2452 msg->wParam, msg->lParam );
2453 SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval );
2455 WIN_ReleaseWndPtr(wndPtr);
2456 wndPtr = WIN_FindWndPtr(msg->hwnd);
2458 if (painting && wndPtr &&
2459 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2461 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2462 msg->hwnd);
2463 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2464 /* Validate the update region to avoid infinite WM_PAINT loop */
2465 ValidateRect( msg->hwnd, NULL );
2467 END:
2468 WIN_ReleaseWndPtr(wndPtr);
2469 return retval;
2473 /***********************************************************************
2474 * RegisterWindowMessageA (USER.118) (USER32.437)
2476 WORD WINAPI RegisterWindowMessageA( LPCSTR str )
2478 TRACE("%s\n", str );
2479 return GlobalAddAtomA( str );
2483 /***********************************************************************
2484 * RegisterWindowMessageW (USER32.438)
2486 WORD WINAPI RegisterWindowMessageW( LPCWSTR str )
2488 TRACE("%p\n", str );
2489 return GlobalAddAtomW( str );
2493 /***********************************************************************
2494 * GetCurrentTime16 (USER.15)
2496 * (effectively identical to GetTickCount)
2498 DWORD WINAPI GetCurrentTime16(void)
2500 return GetTickCount();
2504 /***********************************************************************
2505 * InSendMessage16 (USER.192)
2507 BOOL16 WINAPI InSendMessage16(void)
2509 return InSendMessage();
2513 /***********************************************************************
2514 * InSendMessage (USER32.320)
2516 BOOL WINAPI InSendMessage(void)
2518 MESSAGEQUEUE *queue;
2519 BOOL ret;
2521 if (!(queue = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
2522 return 0;
2523 ret = (BOOL)queue->smWaiting;
2525 QUEUE_Unlock( queue );
2526 return ret;
2529 /***********************************************************************
2530 * BroadcastSystemMessage (USER32.12)
2532 LONG WINAPI BroadcastSystemMessage(
2533 DWORD dwFlags,LPDWORD recipients,UINT uMessage,WPARAM wParam,
2534 LPARAM lParam
2536 FIXME_(sendmsg)("(%08lx,%08lx,%08x,%08x,%08lx): stub!\n",
2537 dwFlags,*recipients,uMessage,wParam,lParam
2539 return 0;
2542 /***********************************************************************
2543 * SendNotifyMessageA (USER32.460)
2544 * FIXME
2545 * The message sended with PostMessage has to be put in the queue
2546 * with a higher priority as the other "Posted" messages.
2547 * QUEUE_AddMsg has to be modifyed.
2549 BOOL WINAPI SendNotifyMessageA(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
2550 { BOOL ret = TRUE;
2551 FIXME("(%04x,%08x,%08x,%08lx) not complete\n",
2552 hwnd, msg, wParam, lParam);
2554 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL))
2555 { ret=SendMessageA ( hwnd, msg, wParam, lParam );
2557 else
2558 { PostMessageA ( hwnd, msg, wParam, lParam );
2560 return ret;
2563 /***********************************************************************
2564 * SendNotifyMessageW (USER32.461)
2565 * FIXME
2566 * The message sended with PostMessage has to be put in the queue
2567 * with a higher priority as the other "Posted" messages.
2568 * QUEUE_AddMsg has to be modifyed.
2570 BOOL WINAPI SendNotifyMessageW(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
2571 { BOOL ret = TRUE;
2572 FIXME("(%04x,%08x,%08x,%08lx) not complete\n",
2573 hwnd, msg, wParam, lParam);
2575 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL))
2576 { ret=SendMessageW ( hwnd, msg, wParam, lParam );
2578 else
2579 { PostMessageW ( hwnd, msg, wParam, lParam );
2581 return ret;
2584 /***********************************************************************
2585 * SendMessageCallbackA
2586 * FIXME: It's like PostMessage. The callback gets called when the message
2587 * is processed. We have to modify the message processing for a exact
2588 * implementation...
2590 BOOL WINAPI SendMessageCallbackA(
2591 HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam,
2592 FARPROC lpResultCallBack,DWORD dwData)
2594 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2595 hWnd,Msg,wParam,lParam,lpResultCallBack,dwData);
2596 if ( hWnd == HWND_BROADCAST)
2597 { PostMessageA( hWnd, Msg, wParam, lParam);
2598 FIXME("Broadcast: Callback will not be called!\n");
2599 return TRUE;
2601 (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam ));
2602 return TRUE;
2604 /***********************************************************************
2605 * SendMessageCallbackW
2606 * FIXME: It's like PostMessage. The callback gets called when the message
2607 * is processed. We have to modify the message processing for a exact
2608 * implementation...
2610 BOOL WINAPI SendMessageCallbackW(
2611 HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam,
2612 FARPROC lpResultCallBack,DWORD dwData)
2614 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2615 hWnd,Msg,wParam,lParam,lpResultCallBack,dwData);
2616 if ( hWnd == HWND_BROADCAST)
2617 { PostMessageW( hWnd, Msg, wParam, lParam);
2618 FIXME("Broadcast: Callback will not be called!\n");
2619 return TRUE;
2621 (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam ));
2622 return TRUE;