- fixed my slightly incorrect EndDialog patch
[wine/wine-kai.git] / windows / message.c
blob78f25783d15520f2a44054b5cf6f3f009bc5d89d
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 "thread.h"
28 #include "options.h"
29 #include "struct32.h"
30 #include "debugtools.h"
32 DEFAULT_DEBUG_CHANNEL(msg)
33 DECLARE_DEBUG_CHANNEL(key)
34 DECLARE_DEBUG_CHANNEL(sendmsg)
36 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
37 #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
40 typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP,
41 SYSQ_MSG_ACCEPT, SYSQ_MSG_CONTINUE } SYSQ_STATUS;
43 extern HQUEUE16 hCursorQueue; /* queue.c */
45 DWORD MSG_WineStartTicks; /* Ticks at Wine startup */
47 static UINT doubleClickSpeed = 452;
49 /***********************************************************************
50 * MSG_CheckFilter
52 static BOOL MSG_CheckFilter(DWORD uMsg, DWORD first, DWORD last)
54 if( first || last )
55 return (uMsg >= first && uMsg <= last);
56 return TRUE;
59 /***********************************************************************
60 * MSG_SendParentNotify
62 * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
63 * the window has the WS_EX_NOPARENTNOTIFY style.
65 static void MSG_SendParentNotify(WND* wndPtr, WORD event, WORD idChild, LPARAM lValue)
67 #define lppt ((LPPOINT16)&lValue)
69 /* pt has to be in the client coordinates of the parent window */
70 WND *tmpWnd = WIN_LockWndPtr(wndPtr);
72 MapWindowPoints16( 0, tmpWnd->hwndSelf, lppt, 1 );
73 while (tmpWnd)
75 if (!(tmpWnd->dwStyle & WS_CHILD) || (tmpWnd->dwExStyle & WS_EX_NOPARENTNOTIFY))
77 WIN_ReleaseWndPtr(tmpWnd);
78 break;
80 lppt->x += tmpWnd->rectClient.left;
81 lppt->y += tmpWnd->rectClient.top;
82 WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent);
83 SendMessageA( tmpWnd->hwndSelf, WM_PARENTNOTIFY,
84 MAKEWPARAM( event, idChild ), lValue );
87 #undef lppt
91 /***********************************************************************
92 * MSG_TranslateMouseMsg
94 * Translate an mouse hardware event into a real mouse message.
96 * Returns:
98 * SYSQ_MSG_ABANDON - abandon the peek message loop
99 * SYSQ_MSG_CONTINUE - leave the message in the queue and
100 * continue with the translation loop
101 * SYSQ_MSG_ACCEPT - proceed to process the translated message
103 static DWORD MSG_TranslateMouseMsg( HWND hTopWnd, DWORD first, DWORD last,
104 MSG *msg, BOOL remove, WND* pWndScope,
105 INT16 *pHitTest, POINT16 *pScreen_pt, BOOL *pmouseClick )
107 static DWORD dblclk_time_limit = 0;
108 static UINT16 clk_message = 0;
109 static HWND16 clk_hwnd = 0;
110 static POINT16 clk_pos = { 0, 0 };
112 WND *pWnd;
113 HWND hWnd;
114 INT16 ht, hittest;
115 UINT message = msg->message;
116 POINT16 screen_pt, pt;
117 HANDLE16 hQ = GetFastQueue16();
118 MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock(hQ);
119 BOOL mouseClick = ((message == WM_LBUTTONDOWN) ||
120 (message == WM_RBUTTONDOWN) ||
121 (message == WM_MBUTTONDOWN))?1:0;
122 DWORD retvalue;
124 /* Find the window to dispatch this mouse message to */
126 CONV_POINT32TO16( &msg->pt, &pt );
128 hWnd = GetCapture();
130 /* If no capture HWND, find window which contains the mouse position.
131 * Also find the position of the cursor hot spot (hittest) */
132 if( !hWnd )
134 ht = hittest = WINPOS_WindowFromPoint( pWndScope, pt, &pWnd );
135 if( !pWnd ) pWnd = WIN_GetDesktop();
136 else WIN_LockWndPtr(pWnd);
137 hWnd = pWnd->hwndSelf;
139 else
141 ht = hittest = HTCLIENT;
142 pWnd = WIN_FindWndPtr(hWnd);
143 if (queue)
144 ht = PERQDATA_GetCaptureInfo( queue->pQData );
147 /* Save hittest for return */
148 *pHitTest = hittest;
150 /* stop if not the right queue */
152 if (pWnd->hmemTaskQ != hQ)
154 /* Not for the current task */
155 if (queue) QUEUE_ClearWakeBit( queue, QS_MOUSE );
156 /* Wake up the other task */
157 QUEUE_Unlock( queue );
158 queue = (MESSAGEQUEUE *)QUEUE_Lock( pWnd->hmemTaskQ );
159 if (queue) QUEUE_SetWakeBit( queue, QS_MOUSE );
161 QUEUE_Unlock( queue );
162 retvalue = SYSQ_MSG_ABANDON;
163 goto END;
166 /* check if hWnd is within hWndScope */
168 if( hTopWnd && hWnd != hTopWnd )
169 if( !IsChild(hTopWnd, hWnd) )
171 QUEUE_Unlock( queue );
172 retvalue = SYSQ_MSG_CONTINUE;
173 goto END;
176 /* Was it a mouse click message */
177 if( mouseClick )
179 /* translate double clicks -
180 * note that ...MOUSEMOVEs can slip in between
181 * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
183 if(GetClassLongA(hWnd, GCL_STYLE) & CS_DBLCLKS || ht != HTCLIENT )
185 if ((message == clk_message) && (hWnd == clk_hwnd) &&
186 (msg->time - dblclk_time_limit < doubleClickSpeed) &&
187 (abs(msg->pt.x - clk_pos.x) < GetSystemMetrics(SM_CXDOUBLECLK)/2) &&
188 (abs(msg->pt.y - clk_pos.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2))
190 message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
191 mouseClick++; /* == 2 */
195 /* save mouse position */
196 screen_pt = pt;
197 *pScreen_pt = pt;
199 if (hittest != HTCLIENT)
201 message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
202 msg->wParam = hittest;
204 else
205 ScreenToClient16( hWnd, &pt );
207 /* check message filter */
209 if (!MSG_CheckFilter(message, first, last))
211 QUEUE_Unlock(queue);
212 retvalue = SYSQ_MSG_CONTINUE;
213 goto END;
216 /* Update global hCursorQueue */
217 hCursorQueue = queue->self;
219 /* Update static double click conditions */
220 if( remove && mouseClick )
222 if( mouseClick == 1 )
224 /* set conditions */
225 dblclk_time_limit = msg->time;
226 clk_message = msg->message;
227 clk_hwnd = hWnd;
228 clk_pos = screen_pt;
229 } else
230 /* got double click - zero them out */
231 dblclk_time_limit = clk_hwnd = 0;
234 QUEUE_Unlock(queue);
236 /* Update message params */
237 msg->hwnd = hWnd;
238 msg->message = message;
239 msg->lParam = MAKELONG( pt.x, pt.y );
240 retvalue = SYSQ_MSG_ACCEPT;
242 END:
243 WIN_ReleaseWndPtr(pWnd);
245 /* Return mouseclick flag */
246 *pmouseClick = mouseClick;
248 return retvalue;
252 /***********************************************************************
253 * MSG_ProcessMouseMsg
255 * Processes a translated mouse hardware event.
256 * The passed in msg structure should contain the updated hWnd,
257 * lParam, wParam and message fields from MSG_TranslateMouseMsg.
259 * Returns:
261 * SYSQ_MSG_SKIP - Message should be skipped entirely (in this case
262 * HIWORD contains hit test code). Continue translating..
263 * SYSQ_MSG_ACCEPT - the translated message must be passed to the user
264 * MSG_PeekHardwareMsg should return TRUE.
266 static DWORD MSG_ProcessMouseMsg( MSG *msg, BOOL remove, INT16 hittest,
267 POINT16 screen_pt, BOOL mouseClick )
269 WND *pWnd;
270 HWND hWnd = msg->hwnd;
271 INT16 sendSC = (GetCapture() == 0);
272 UINT message = msg->message;
273 BOOL eatMsg = FALSE;
274 DWORD retvalue;
276 pWnd = WIN_FindWndPtr(hWnd);
278 /* call WH_MOUSE */
280 if (HOOK_IsHooked( WH_MOUSE ))
282 SYSQ_STATUS ret = 0;
283 MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
284 if( hook )
286 hook->pt = screen_pt;
287 hook->hwnd = hWnd;
288 hook->wHitTestCode = hittest;
289 hook->dwExtraInfo = 0;
290 ret = HOOK_CallHooks16( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
291 message, (LPARAM)SEGPTR_GET(hook) );
292 SEGPTR_FREE(hook);
294 if( ret )
296 retvalue = MAKELONG((INT16)SYSQ_MSG_SKIP, hittest);
297 goto END;
302 if ((hittest == HTERROR) || (hittest == HTNOWHERE))
303 eatMsg = sendSC = 1;
304 else if( remove && mouseClick )
306 HWND hwndTop = WIN_GetTopParent( hWnd );
308 if( sendSC )
310 /* Send the WM_PARENTNOTIFY,
311 * note that even for double/nonclient clicks
312 * notification message is still WM_L/M/RBUTTONDOWN.
315 MSG_SendParentNotify( pWnd, msg->message & 0xffff, 0, MAKELPARAM(screen_pt.x, screen_pt.y) );
317 /* Activate the window if needed */
319 if (hWnd != GetActiveWindow() && hWnd != GetDesktopWindow())
321 LONG ret = SendMessageA( hWnd, WM_MOUSEACTIVATE, hwndTop,
322 MAKELONG( hittest, message ) );
324 if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
325 eatMsg = TRUE;
327 if (((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
328 && hwndTop != GetForegroundWindow() )
330 if (!WINPOS_SetActiveWindow( hwndTop, TRUE , TRUE ))
331 eatMsg = TRUE;
335 } else sendSC = (remove && sendSC);
337 /* Send the WM_SETCURSOR message */
339 if (sendSC)
341 UINT uSCMessage = message;
343 /* Windows sends the normal mouse message as the message parameter
344 in the WM_SETCURSOR message even if it's non-client mouse message */
346 if (uSCMessage >= WM_NCMOUSEFIRST && uSCMessage <= WM_NCMOUSELAST)
347 uSCMessage += WM_MOUSEFIRST - WM_NCMOUSEFIRST;
348 SendMessageA( hWnd, WM_SETCURSOR, hWnd,
349 MAKELONG( hittest, uSCMessage));
351 if (eatMsg)
353 retvalue = MAKELONG( (UINT16)SYSQ_MSG_SKIP, hittest);
354 goto END;
357 retvalue = SYSQ_MSG_ACCEPT;
358 END:
359 WIN_ReleaseWndPtr(pWnd);
361 return retvalue;
365 /***********************************************************************
366 * MSG_TranslateKbdMsg
368 * Translate an keyboard hardware event into a real message.
370 static DWORD MSG_TranslateKbdMsg( HWND hTopWnd, DWORD first, DWORD last,
371 MSG *msg, BOOL remove )
373 WORD message = msg->message;
374 HWND hWnd = GetFocus();
375 WND *pWnd;
377 /* Should check Ctrl-Esc and PrintScreen here */
379 if (!hWnd)
381 /* Send the message to the active window instead, */
382 /* translating messages to their WM_SYS equivalent */
384 hWnd = GetActiveWindow();
386 if( message < WM_SYSKEYDOWN )
387 message += WM_SYSKEYDOWN - WM_KEYDOWN;
389 pWnd = WIN_FindWndPtr( hWnd );
390 if (pWnd && (pWnd->hmemTaskQ != GetFastQueue16()))
392 /* Not for the current task */
393 MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() );
394 if (queue) QUEUE_ClearWakeBit( queue, QS_KEY );
395 QUEUE_Unlock( queue );
397 /* Wake up the other task */
398 queue = (MESSAGEQUEUE *)QUEUE_Lock( pWnd->hmemTaskQ );
399 if (queue) QUEUE_SetWakeBit( queue, QS_KEY );
400 QUEUE_Unlock( queue );
401 WIN_ReleaseWndPtr(pWnd);
402 return SYSQ_MSG_ABANDON;
404 WIN_ReleaseWndPtr(pWnd);
406 if (hTopWnd && hWnd != hTopWnd)
407 if (!IsChild(hTopWnd, hWnd)) return SYSQ_MSG_CONTINUE;
408 if (!MSG_CheckFilter(message, first, last)) return SYSQ_MSG_CONTINUE;
410 msg->hwnd = hWnd;
411 msg->message = message;
413 return SYSQ_MSG_ACCEPT;
417 /***********************************************************************
418 * MSG_ProcessKbdMsg
420 * Processes a translated keyboard message
422 static DWORD MSG_ProcessKbdMsg( MSG *msg, BOOL remove )
424 return (HOOK_CallHooks16( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE,
425 LOWORD (msg->wParam), msg->lParam )
426 ? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT);
430 /***********************************************************************
431 * MSG_JournalRecordMsg
433 * Build an EVENTMSG structure and call JOURNALRECORD hook
435 static void MSG_JournalRecordMsg( MSG *msg )
437 EVENTMSG *event = (EVENTMSG *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG));
438 if (!event) return;
439 event->message = msg->message;
440 event->time = msg->time;
441 if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
443 event->paramL = (msg->wParam & 0xFF) | (HIWORD(msg->lParam) << 8);
444 event->paramH = msg->lParam & 0x7FFF;
445 if (HIWORD(msg->lParam) & 0x0100)
446 event->paramH |= 0x8000; /* special_key - bit */
447 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
449 else if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
451 event->paramL = LOWORD(msg->lParam); /* X pos */
452 event->paramH = HIWORD(msg->lParam); /* Y pos */
453 ClientToScreen16( msg->hwnd, (LPPOINT16)&event->paramL );
454 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
456 else if ((msg->message >= WM_NCMOUSEFIRST) &&
457 (msg->message <= WM_NCMOUSELAST))
459 event->paramL = LOWORD(msg->lParam); /* X pos */
460 event->paramH = HIWORD(msg->lParam); /* Y pos */
461 event->message += WM_MOUSEMOVE-WM_NCMOUSEMOVE;/* give no info about NC area */
462 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
465 HeapFree(SystemHeap, 0, event);
468 /***********************************************************************
469 * MSG_JournalPlayBackMsg
471 * Get an EVENTMSG struct via call JOURNALPLAYBACK hook function
473 static int MSG_JournalPlayBackMsg(void)
475 EVENTMSG *tmpMsg;
476 long wtime,lParam,wParam;
477 WORD keyDown,i,result=0;
479 if ( HOOK_IsHooked( WH_JOURNALPLAYBACK ) )
481 tmpMsg = (EVENTMSG *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG));
482 if (!tmpMsg) return result;
484 wtime=HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_GETNEXT, 0,
485 (LPARAM) tmpMsg );
486 /* TRACE(msg,"Playback wait time =%ld\n",wtime); */
487 if (wtime<=0)
489 wtime=0;
490 if ((tmpMsg->message>= WM_KEYFIRST) && (tmpMsg->message <= WM_KEYLAST))
492 wParam=tmpMsg->paramL & 0xFF;
493 lParam=MAKELONG(tmpMsg->paramH&0x7ffff,tmpMsg->paramL>>8);
494 if (tmpMsg->message == WM_KEYDOWN || tmpMsg->message == WM_SYSKEYDOWN)
496 for (keyDown=i=0; i<256 && !keyDown; i++)
497 if (InputKeyStateTable[i] & 0x80)
498 keyDown++;
499 if (!keyDown)
500 lParam |= 0x40000000;
501 AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] |= 0x80;
503 else /* WM_KEYUP, WM_SYSKEYUP */
505 lParam |= 0xC0000000;
506 AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] &= ~0x80;
508 if (InputKeyStateTable[VK_MENU] & 0x80)
509 lParam |= 0x20000000;
510 if (tmpMsg->paramH & 0x8000) /*special_key bit*/
511 lParam |= 0x01000000;
512 hardware_event( tmpMsg->message & 0xffff, LOWORD(wParam), lParam,
513 0, 0, tmpMsg->time, 0 );
515 else
517 if ((tmpMsg->message>= WM_MOUSEFIRST) && (tmpMsg->message <= WM_MOUSELAST))
519 switch (tmpMsg->message)
521 case WM_LBUTTONDOWN:
522 MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=TRUE;break;
523 case WM_LBUTTONUP:
524 MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=FALSE;break;
525 case WM_MBUTTONDOWN:
526 MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=TRUE;break;
527 case WM_MBUTTONUP:
528 MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=FALSE;break;
529 case WM_RBUTTONDOWN:
530 MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=TRUE;break;
531 case WM_RBUTTONUP:
532 MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=FALSE;break;
534 AsyncKeyStateTable[VK_LBUTTON]= InputKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0;
535 AsyncKeyStateTable[VK_MBUTTON]= InputKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0;
536 AsyncKeyStateTable[VK_RBUTTON]= InputKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0;
537 SetCursorPos(tmpMsg->paramL,tmpMsg->paramH);
538 lParam=MAKELONG(tmpMsg->paramL,tmpMsg->paramH);
539 wParam=0;
540 if (MouseButtonsStates[0]) wParam |= MK_LBUTTON;
541 if (MouseButtonsStates[1]) wParam |= MK_MBUTTON;
542 if (MouseButtonsStates[2]) wParam |= MK_RBUTTON;
543 hardware_event( tmpMsg->message & 0xffff, LOWORD (wParam), lParam,
544 tmpMsg->paramL, tmpMsg->paramH, tmpMsg->time, 0 );
547 HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_SKIP, 0,
548 (LPARAM) tmpMsg);
550 else
553 if( tmpMsg->message == WM_QUEUESYNC )
554 if (HOOK_IsHooked( WH_CBT ))
555 HOOK_CallHooksA( WH_CBT, HCBT_QS, 0, 0L);
557 result= QS_MOUSE | QS_KEY; /* ? */
559 HeapFree(SystemHeap, 0, tmpMsg);
561 return result;
564 /***********************************************************************
565 * MSG_PeekHardwareMsg
567 * Peek for a hardware message matching the hwnd and message filters.
569 static BOOL MSG_PeekHardwareMsg( MSG *msg, HWND hwnd, DWORD first, DWORD last,
570 BOOL remove )
572 /* FIXME: should deal with MSG32 instead of MSG16 */
574 DWORD status = SYSQ_MSG_ACCEPT;
575 MESSAGEQUEUE *sysMsgQueue = QUEUE_GetSysQueue();
576 enum { MOUSE_MSG = 0, KEYBOARD_MSG, HARDWARE_MSG } msgType;
577 QMSG *nextqmsg, *qmsg = 0;
578 BOOL bRet = FALSE;
580 /* FIXME: there has to be a better way to do this */
581 joySendMessages();
583 EnterCriticalSection(&sysMsgQueue->cSection);
585 /* Loop through the Q and translate the message we wish to process
586 * while we own the lock. Based on the translation status (abandon/cont/accept)
587 * we then process the message accordingly
590 for ( qmsg = sysMsgQueue->firstMsg; qmsg; qmsg = nextqmsg )
592 INT16 hittest;
593 POINT16 screen_pt;
594 BOOL mouseClick;
596 *msg = qmsg->msg;
598 nextqmsg = qmsg->nextMsg;
600 /* Translate message */
602 if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
604 HWND hWndScope = (HWND)qmsg->extraInfo;
605 WND *tmpWnd = (Options.managed && IsWindow(hWndScope) )
606 ? WIN_FindWndPtr(hWndScope) : WIN_GetDesktop();
608 status = MSG_TranslateMouseMsg(hwnd, first, last, msg, remove, tmpWnd,
609 &hittest, &screen_pt, &mouseClick );
610 msgType = MOUSE_MSG;
612 WIN_ReleaseWndPtr(tmpWnd);
615 else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
617 status = MSG_TranslateKbdMsg(hwnd, first, last, msg, remove);
618 msgType = KEYBOARD_MSG;
620 else /* Non-standard hardware event */
622 HARDWAREHOOKSTRUCT16 *hook;
623 msgType = HARDWARE_MSG;
624 if ((hook = SEGPTR_NEW(HARDWAREHOOKSTRUCT16)))
626 BOOL ret;
627 hook->hWnd = msg->hwnd;
628 hook->wMessage = msg->message & 0xffff;
629 hook->wParam = LOWORD (msg->wParam);
630 hook->lParam = msg->lParam;
631 ret = HOOK_CallHooks16( WH_HARDWARE,
632 remove ? HC_ACTION : HC_NOREMOVE,
633 0, (LPARAM)SEGPTR_GET(hook) );
634 SEGPTR_FREE(hook);
635 if (ret)
637 QUEUE_RemoveMsg( sysMsgQueue, qmsg );
638 continue;
640 status = SYSQ_MSG_ACCEPT;
645 switch (LOWORD(status))
647 case SYSQ_MSG_ACCEPT:
649 /* Remove the message from the system msg Q while it is still locked,
650 * before accepting it */
651 if (remove)
653 if (HOOK_IsHooked( WH_JOURNALRECORD )) MSG_JournalRecordMsg( msg );
654 QUEUE_RemoveMsg( sysMsgQueue, qmsg );
656 /* Now actually process the message, after we unlock the system msg Q.
657 * We should not hold on to the crst since SendMessage calls during processing
658 * will potentially cause callbacks to PeekMessage from the application.
659 * If we're holding the crst and QUEUE_WaitBits is called with a
660 * QS_SENDMESSAGE mask we will deadlock in hardware_event() when a
661 * message is being posted to the Q.
663 LeaveCriticalSection(&sysMsgQueue->cSection);
664 if( msgType == KEYBOARD_MSG )
665 status = MSG_ProcessKbdMsg( msg, remove );
666 else if ( msgType == MOUSE_MSG )
667 status = MSG_ProcessMouseMsg( msg, remove, hittest, screen_pt, mouseClick );
669 /* Reclaim the sys msg Q crst */
670 EnterCriticalSection(&sysMsgQueue->cSection);
672 /* Pass the translated message to the user if it was accepted */
673 if (status == SYSQ_MSG_ACCEPT)
674 break;
676 /* If not accepted, fall through into the SYSQ_MSG_SKIP case */
679 case SYSQ_MSG_SKIP:
680 if (HOOK_IsHooked( WH_CBT ))
682 if( msgType == KEYBOARD_MSG )
683 HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED,
684 LOWORD (msg->wParam), msg->lParam );
685 else if ( msgType == MOUSE_MSG )
687 MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
688 if (hook)
690 CONV_POINT32TO16( &msg->pt,&hook->pt );
691 hook->hwnd = msg->hwnd;
692 hook->wHitTestCode = HIWORD(status);
693 hook->dwExtraInfo = 0;
694 HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message & 0xffff,
695 (LPARAM)SEGPTR_GET(hook) );
696 SEGPTR_FREE(hook);
701 /* If the message was removed earlier set up nextqmsg so that we start
702 * at the top of the queue again. We need to do this since our next pointer
703 * could be invalid due to us unlocking the system message Q to process the message.
704 * If not removed just refresh nextqmsg to point to the next msg.
706 if (remove)
707 nextqmsg = sysMsgQueue->firstMsg;
708 else
709 nextqmsg = qmsg->nextMsg;
711 continue;
713 case SYSQ_MSG_CONTINUE:
714 continue;
716 case SYSQ_MSG_ABANDON:
717 bRet = FALSE;
718 goto END;
721 bRet = TRUE;
722 goto END;
725 END:
726 LeaveCriticalSection(&sysMsgQueue->cSection);
727 return bRet;
731 /**********************************************************************
732 * SetDoubleClickTime16 (USER.20)
734 void WINAPI SetDoubleClickTime16( UINT16 interval )
736 SetDoubleClickTime( interval );
740 /**********************************************************************
741 * SetDoubleClickTime32 (USER32.480)
743 BOOL WINAPI SetDoubleClickTime( UINT interval )
745 doubleClickSpeed = interval ? interval : 500;
746 return TRUE;
750 /**********************************************************************
751 * GetDoubleClickTime16 (USER.21)
753 UINT16 WINAPI GetDoubleClickTime16(void)
755 return doubleClickSpeed;
759 /**********************************************************************
760 * GetDoubleClickTime32 (USER32.239)
762 UINT WINAPI GetDoubleClickTime(void)
764 return doubleClickSpeed;
768 /***********************************************************************
769 * MSG_SendMessageInterThread
771 * Implementation of an inter-task SendMessage.
772 * Return values:
773 * 0 if error or timeout
774 * 1 if successflul
776 static LRESULT MSG_SendMessageInterThread( HQUEUE16 hDestQueue,
777 HWND hwnd, UINT msg,
778 WPARAM wParam, LPARAM lParam,
779 DWORD timeout, WORD flags,
780 LRESULT *pRes)
782 MESSAGEQUEUE *queue, *destQ;
783 SMSG *smsg;
784 LRESULT retVal = 1;
785 int iWndsLocks;
787 *pRes = 0;
789 if (IsTaskLocked16() || !IsWindow(hwnd))
790 return 0;
792 /* create a SMSG structure to hold SendMessage() parameters */
793 if (! (smsg = (SMSG *) HeapAlloc( SystemHeap, 0, sizeof(SMSG) )) )
794 return 0;
795 if (!(queue = (MESSAGEQUEUE*)QUEUE_Lock( GetFastQueue16() ))) return 0;
797 if (!(destQ = (MESSAGEQUEUE*)QUEUE_Lock( hDestQueue )))
799 QUEUE_Unlock( queue );
800 return 0;
803 TRACE_(sendmsg)("SM: %s [%04x] (%04x -> %04x)\n",
804 SPY_GetMsgName(msg), msg, queue->self, hDestQueue );
806 /* fill up SMSG structure */
807 smsg->hWnd = hwnd;
808 smsg->msg = msg;
809 smsg->wParam = wParam;
810 smsg->lParam = lParam;
812 smsg->lResult = 0;
813 smsg->hSrcQueue = GetFastQueue16();
814 smsg->hDstQueue = hDestQueue;
815 smsg->flags = flags;
817 /* add smsg struct in the processing SM list of the source queue */
818 QUEUE_AddSMSG(queue, SM_PROCESSING_LIST, smsg);
820 /* add smsg struct in the pending list of the destination queue */
821 if (QUEUE_AddSMSG(destQ, SM_PENDING_LIST, smsg) == FALSE)
822 return 0;
824 iWndsLocks = WIN_SuspendWndsLock();
826 /* force destination task to run next, if 16 bit threads */
827 if ( THREAD_IsWin16(NtCurrentTeb()) && THREAD_IsWin16(destQ->teb) )
828 DirectedYield16( destQ->teb->htask16 );
830 /* wait for the result, note that 16-bit apps almost always get out of
831 * DirectedYield() with SMSG_HAVE_RESULT flag already set */
833 while ( TRUE )
836 * The sequence is crucial to avoid deadlock situations:
837 * - first, we clear the QS_SMRESULT bit
838 * - then, we check the SMSG_HAVE_RESULT bit
839 * - only if this isn't set, we enter the wait state.
841 * As the receiver first sets the SMSG_HAVE_RESULT and then wakes us,
842 * we are guaranteed that -should we now clear the QS_SMRESULT that
843 * was signalled already by the receiver- we will not start waiting.
846 if ( smsg->flags & SMSG_HAVE_RESULT )
848 got:
849 *pRes = smsg->lResult;
850 TRACE_(sendmsg)("smResult = %08x\n", (unsigned)*pRes );
851 break;
854 QUEUE_ClearWakeBit( queue, QS_SMRESULT );
856 if ( smsg->flags & SMSG_HAVE_RESULT )
857 goto got;
859 if( QUEUE_WaitBits( QS_SMRESULT, timeout ) == 0 )
861 /* return with timeout */
862 SetLastError( 0 );
863 retVal = 0;
864 break;
867 WIN_RestoreWndsLock(iWndsLocks);
869 /* remove the smsg from the processingg list of the source queue */
870 QUEUE_RemoveSMSG( queue, SM_PROCESSING_LIST, smsg );
872 /* Note: the destination thread is in charge of removing the smsg from
873 the pending list */
875 /* In the case of an early reply (or a timeout), sender thread will
876 released the smsg structure if the receiver thread is done
877 (SMSG_RECEIVED set). If the receiver thread isn't done,
878 SMSG_RECEIVER_CLEANS_UP flag is set, and it will be the receiver
879 responsability to released smsg */
880 EnterCriticalSection( &queue->cSection );
882 if (smsg->flags & SMSG_RECEIVED)
883 HeapFree(SystemHeap, 0, smsg);
884 else
885 smsg->flags |= SMSG_RECEIVER_CLEANS;
887 LeaveCriticalSection( &queue->cSection );
890 QUEUE_Unlock( queue );
891 QUEUE_Unlock( destQ );
893 TRACE_(sendmsg)("done!\n");
894 return retVal;
898 /***********************************************************************
899 * ReplyMessage16 (USER.115)
901 void WINAPI ReplyMessage16( LRESULT result )
903 ReplyMessage( result );
906 /***********************************************************************
907 * ReplyMessage (USER.115)
909 BOOL WINAPI ReplyMessage( LRESULT result )
911 MESSAGEQUEUE *senderQ = 0;
912 MESSAGEQUEUE *queue = 0;
913 SMSG *smsg;
914 BOOL ret = FALSE;
916 if (!(queue = (MESSAGEQUEUE*)QUEUE_Lock( GetFastQueue16() )))
917 return FALSE;
919 TRACE_(sendmsg)("ReplyMessage, queue %04x\n", queue->self);
922 if ( !(smsg = queue->smWaiting)
923 || !(senderQ = QUEUE_Lock( smsg->hSrcQueue )) )
924 goto ReplyMessageEnd;
926 if ( !(smsg->flags & SMSG_ALREADY_REPLIED) )
928 /* This is the first reply, so pass result to sender */
930 TRACE_(sendmsg)("\trpm: smResult = %08lx\n", (long) result );
932 EnterCriticalSection(&senderQ->cSection);
934 smsg->lResult = result;
935 smsg->flags |= SMSG_ALREADY_REPLIED;
937 /* check if it's an early reply (called by the application) or
938 a regular reply (called by ReceiveMessage) */
939 if ( !(smsg->flags & SMSG_SENDING_REPLY) )
940 smsg->flags |= SMSG_EARLY_REPLY;
942 smsg->flags |= SMSG_HAVE_RESULT;
944 LeaveCriticalSection(&senderQ->cSection);
946 /* tell the sending task that its reply is ready */
947 QUEUE_SetWakeBit( senderQ, QS_SMRESULT );
949 /* switch directly to sending task (16 bit thread only) */
950 if ( THREAD_IsWin16( NtCurrentTeb() ) && THREAD_IsWin16( senderQ->teb ) )
951 DirectedYield16( senderQ->teb->htask16 );
953 ret = TRUE;
956 if (smsg->flags & SMSG_SENDING_REPLY)
958 /* remove msg from the waiting list, since this is the last
959 ReplyMessage */
960 QUEUE_RemoveSMSG( queue, SM_WAITING_LIST, smsg );
962 EnterCriticalSection(&senderQ->cSection);
964 /* tell the sender we're all done with smsg structure */
965 smsg->flags |= SMSG_RECEIVED;
967 /* sender will set SMSG_RECEIVER_CLEANS_UP if it wants the
968 receiver to clean up smsg, it could only happens when there is
969 an early reply or a timeout */
970 if ( smsg->flags & SMSG_RECEIVER_CLEANS )
972 TRACE_(sendmsg)("Receiver cleans up!\n" );
973 HeapFree( SystemHeap, 0, smsg );
976 LeaveCriticalSection(&senderQ->cSection);
979 ReplyMessageEnd:
980 if ( senderQ )
981 QUEUE_Unlock( senderQ );
982 if ( queue )
983 QUEUE_Unlock( queue );
985 return ret;
988 /***********************************************************************
989 * MSG_ConvertMsg
991 static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType )
993 UINT16 msg16;
994 MSGPARAM16 mp16;
996 switch ( MAKELONG( srcType, dstType ) )
998 case MAKELONG( QMSG_WIN16, QMSG_WIN16 ):
999 case MAKELONG( QMSG_WIN32A, QMSG_WIN32A ):
1000 case MAKELONG( QMSG_WIN32W, QMSG_WIN32W ):
1001 return TRUE;
1003 case MAKELONG( QMSG_WIN16, QMSG_WIN32A ):
1004 switch ( WINPROC_MapMsg16To32A( msg->message, msg->wParam,
1005 &msg->message, &msg->wParam, &msg->lParam ) )
1007 case 0:
1008 return TRUE;
1009 case 1:
1010 /* Pointer messages were mapped --> need to free allocated memory and fail */
1011 WINPROC_UnmapMsg16To32A( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 );
1012 default:
1013 return FALSE;
1016 case MAKELONG( QMSG_WIN16, QMSG_WIN32W ):
1017 switch ( WINPROC_MapMsg16To32W( msg->hwnd, msg->message, msg->wParam,
1018 &msg->message, &msg->wParam, &msg->lParam ) )
1020 case 0:
1021 return TRUE;
1022 case 1:
1023 /* Pointer messages were mapped --> need to free allocated memory and fail */
1024 WINPROC_UnmapMsg16To32W( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 );
1025 default:
1026 return FALSE;
1029 case MAKELONG( QMSG_WIN32A, QMSG_WIN16 ):
1030 mp16.lParam = msg->lParam;
1031 switch ( WINPROC_MapMsg32ATo16( msg->hwnd, msg->message, msg->wParam,
1032 &msg16, &mp16.wParam, &mp16.lParam ) )
1034 case 0:
1035 msg->message = msg16;
1036 msg->wParam = mp16.wParam;
1037 msg->lParam = mp16.lParam;
1038 return TRUE;
1039 case 1:
1040 /* Pointer messages were mapped --> need to free allocated memory and fail */
1041 WINPROC_UnmapMsg32ATo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 );
1042 default:
1043 return FALSE;
1046 case MAKELONG( QMSG_WIN32W, QMSG_WIN16 ):
1047 mp16.lParam = msg->lParam;
1048 switch ( WINPROC_MapMsg32WTo16( msg->hwnd, msg->message, msg->wParam,
1049 &msg16, &mp16.wParam, &mp16.lParam ) )
1051 case 0:
1052 msg->message = msg16;
1053 msg->wParam = mp16.wParam;
1054 msg->lParam = mp16.lParam;
1055 return TRUE;
1056 case 1:
1057 /* Pointer messages were mapped --> need to free allocated memory and fail */
1058 WINPROC_UnmapMsg32WTo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 );
1059 default:
1060 return FALSE;
1063 case MAKELONG( QMSG_WIN32A, QMSG_WIN32W ):
1064 switch ( WINPROC_MapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) )
1066 case 0:
1067 return TRUE;
1068 case 1:
1069 /* Pointer messages were mapped --> need to free allocated memory and fail */
1070 WINPROC_UnmapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, msg->lParam );
1071 default:
1072 return FALSE;
1075 case MAKELONG( QMSG_WIN32W, QMSG_WIN32A ):
1076 switch ( WINPROC_MapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) )
1078 case 0:
1079 return TRUE;
1080 case 1:
1081 /* Pointer messages were mapped --> need to free allocated memory and fail */
1082 WINPROC_UnmapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, msg->lParam );
1083 default:
1084 return FALSE;
1087 default:
1088 FIXME( "Invalid message type(s): %d / %d\n", srcType, dstType );
1089 return FALSE;
1093 /***********************************************************************
1094 * MSG_PeekMessage
1096 static BOOL MSG_PeekMessage( int type, LPMSG msg, HWND hwnd,
1097 DWORD first, DWORD last, WORD flags, BOOL peek )
1099 int mask;
1100 MESSAGEQUEUE *msgQueue;
1101 HQUEUE16 hQueue;
1102 POINT16 pt16;
1103 int iWndsLocks;
1105 mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */
1106 if (first || last)
1108 if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY;
1109 if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) ||
1110 ((first <= WM_NCMOUSELAST) && (last >= WM_NCMOUSEFIRST)) ) mask |= QS_MOUSE;
1111 if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER;
1112 if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER;
1113 if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT;
1115 else mask |= QS_MOUSE | QS_KEY | QS_TIMER | QS_PAINT;
1117 if (IsTaskLocked16()) flags |= PM_NOYIELD;
1119 /* Never yield on Win32 threads */
1120 if (!THREAD_IsWin16(NtCurrentTeb())) flags |= PM_NOYIELD;
1122 iWndsLocks = WIN_SuspendWndsLock();
1124 while(1)
1126 QMSG *qmsg;
1128 hQueue = GetFastQueue16();
1129 msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
1130 if (!msgQueue)
1132 WIN_RestoreWndsLock(iWndsLocks);
1133 return FALSE;
1135 msgQueue->changeBits = 0;
1137 /* First handle a message put by SendMessage() */
1139 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1140 QUEUE_ReceiveMessage( msgQueue );
1142 /* Now handle a WM_QUIT message */
1144 if (msgQueue->wPostQMsg &&
1145 (!first || WM_QUIT >= first) &&
1146 (!last || WM_QUIT <= last) )
1148 msg->hwnd = hwnd;
1149 msg->message = WM_QUIT;
1150 msg->wParam = msgQueue->wExitCode;
1151 msg->lParam = 0;
1152 if (flags & PM_REMOVE) msgQueue->wPostQMsg = 0;
1153 break;
1156 /* Now find a normal message */
1158 retry:
1159 if (((msgQueue->wakeBits & mask) & QS_POSTMESSAGE) &&
1160 ((qmsg = QUEUE_FindMsg( msgQueue, hwnd, first, last )) != 0))
1162 /* Try to convert message to requested type */
1163 MSG tmpMsg = qmsg->msg;
1164 if ( !MSG_ConvertMsg( &tmpMsg, qmsg->type, type ) )
1166 ERR( "Message of wrong type contains pointer parameters. Skipped!\n ");
1167 QUEUE_RemoveMsg( msgQueue, qmsg );
1168 goto retry;
1171 *msg = tmpMsg;
1172 msgQueue->GetMessageTimeVal = msg->time;
1173 CONV_POINT32TO16(&msg->pt, &pt16);
1174 msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
1175 msgQueue->GetMessageExtraInfoVal = qmsg->extraInfo;
1177 if (flags & PM_REMOVE) QUEUE_RemoveMsg( msgQueue, qmsg );
1178 break;
1181 msgQueue->changeBits |= MSG_JournalPlayBackMsg();
1183 /* Now find a hardware event */
1185 if (((msgQueue->wakeBits & mask) & (QS_MOUSE | QS_KEY)) &&
1186 MSG_PeekHardwareMsg( msg, hwnd, first, last, flags & PM_REMOVE ))
1188 /* Got one */
1189 msgQueue->GetMessageTimeVal = msg->time;
1190 CONV_POINT32TO16(&msg->pt, &pt16);
1191 msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
1192 msgQueue->GetMessageExtraInfoVal = 0; /* Always 0 for now */
1193 break;
1196 /* Check again for SendMessage */
1198 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1199 QUEUE_ReceiveMessage( msgQueue );
1201 /* Now find a WM_PAINT message */
1203 if ((msgQueue->wakeBits & mask) & QS_PAINT)
1205 WND* wndPtr;
1206 msg->hwnd = WIN_FindWinToRepaint( hwnd , hQueue );
1207 msg->message = WM_PAINT;
1208 msg->wParam = 0;
1209 msg->lParam = 0;
1211 if ((wndPtr = WIN_FindWndPtr(msg->hwnd)))
1213 if( wndPtr->dwStyle & WS_MINIMIZE &&
1214 (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON) )
1216 msg->message = WM_PAINTICON;
1217 msg->wParam = 1;
1220 if( !hwnd || msg->hwnd == hwnd || IsChild16(hwnd,msg->hwnd) )
1222 if( wndPtr->flags & WIN_INTERNAL_PAINT && !wndPtr->hrgnUpdate)
1224 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
1225 QUEUE_DecPaintCount( hQueue );
1227 WIN_ReleaseWndPtr(wndPtr);
1228 break;
1230 WIN_ReleaseWndPtr(wndPtr);
1234 /* Check for timer messages, but yield first */
1236 if (!(flags & PM_NOYIELD))
1238 UserYield16();
1239 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1240 QUEUE_ReceiveMessage( msgQueue );
1242 if ((msgQueue->wakeBits & mask) & QS_TIMER)
1244 if (TIMER_GetTimerMsg(msg, hwnd, hQueue, flags & PM_REMOVE)) break;
1247 if (peek)
1249 if (!(flags & PM_NOYIELD)) UserYield16();
1251 QUEUE_Unlock( msgQueue );
1252 WIN_RestoreWndsLock(iWndsLocks);
1253 return FALSE;
1255 msgQueue->wakeMask = mask;
1256 QUEUE_WaitBits( mask, INFINITE );
1257 QUEUE_Unlock( msgQueue );
1260 WIN_RestoreWndsLock(iWndsLocks);
1262 /* instead of unlocking queue for every break condition, all break
1263 condition will fall here */
1264 QUEUE_Unlock( msgQueue );
1266 /* We got a message */
1267 if (flags & PM_REMOVE)
1269 WORD message = msg->message;
1271 if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
1273 BYTE *p = &QueueKeyStateTable[msg->wParam & 0xff];
1275 if (!(*p & 0x80))
1276 *p ^= 0x01;
1277 *p |= 0x80;
1279 else if (message == WM_KEYUP || message == WM_SYSKEYUP)
1280 QueueKeyStateTable[msg->wParam & 0xff] &= ~0x80;
1283 if (peek)
1284 return TRUE;
1286 else
1287 return (msg->message != WM_QUIT);
1290 /***********************************************************************
1291 * MSG_InternalGetMessage
1293 * GetMessage() function for internal use. Behave like GetMessage(),
1294 * but also call message filters and optionally send WM_ENTERIDLE messages.
1295 * 'hwnd' must be the handle of the dialog or menu window.
1296 * 'code' is the message filter value (MSGF_??? codes).
1298 BOOL MSG_InternalGetMessage( int type, MSG *msg, HWND hwnd, HWND hwndOwner,
1299 WPARAM code, WORD flags, BOOL sendIdle, BOOL* idleSent )
1301 for (;;)
1303 if (sendIdle)
1305 if (!MSG_PeekMessage( type, msg, 0, 0, 0, flags, TRUE ))
1307 /* No message present -> send ENTERIDLE and wait */
1308 if (IsWindow(hwndOwner))
1310 SendMessageA( hwndOwner, WM_ENTERIDLE,
1311 code, (LPARAM)hwnd );
1313 if (idleSent!=NULL)
1314 *idleSent=TRUE;
1316 MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE );
1319 else /* Always wait for a message */
1320 MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE );
1322 /* Call message filters */
1324 if (HOOK_IsHooked( WH_SYSMSGFILTER ) || HOOK_IsHooked( WH_MSGFILTER ))
1326 MSG *pmsg = HeapAlloc( SystemHeap, 0, sizeof(MSG) );
1327 if (pmsg)
1329 BOOL ret;
1330 *pmsg = *msg;
1331 ret = (HOOK_CallHooksA( WH_SYSMSGFILTER, code, 0,
1332 (LPARAM) pmsg ) ||
1333 HOOK_CallHooksA( WH_MSGFILTER, code, 0,
1334 (LPARAM) pmsg ));
1336 HeapFree( SystemHeap, 0, pmsg );
1337 if (ret)
1339 /* Message filtered -> remove it from the queue */
1340 /* if it's still there. */
1341 if (!(flags & PM_REMOVE))
1342 MSG_PeekMessage( type, msg, 0, 0, 0, PM_REMOVE, TRUE );
1343 continue;
1348 return (msg->message != WM_QUIT);
1353 /***********************************************************************
1354 * PeekMessage32_16 (USER.819)
1356 BOOL16 WINAPI PeekMessage32_16( LPMSG16_32 lpmsg16_32, HWND16 hwnd,
1357 UINT16 first, UINT16 last, UINT16 flags,
1358 BOOL16 wHaveParamHigh )
1360 BOOL ret;
1361 MSG msg;
1363 ret = MSG_PeekMessage( QMSG_WIN16, &msg, hwnd, first, last, flags, TRUE );
1365 lpmsg16_32->msg.hwnd = msg.hwnd;
1366 lpmsg16_32->msg.message = msg.message;
1367 lpmsg16_32->msg.wParam = LOWORD(msg.wParam);
1368 lpmsg16_32->msg.lParam = msg.lParam;
1369 lpmsg16_32->msg.time = msg.time;
1370 lpmsg16_32->msg.pt.x = (INT16)msg.pt.x;
1371 lpmsg16_32->msg.pt.y = (INT16)msg.pt.y;
1373 if ( wHaveParamHigh )
1374 lpmsg16_32->wParamHigh = HIWORD(msg.wParam);
1376 return ret;
1379 /***********************************************************************
1380 * PeekMessage16 (USER.109)
1382 BOOL16 WINAPI PeekMessage16( LPMSG16 lpmsg, HWND16 hwnd,
1383 UINT16 first, UINT16 last, UINT16 flags )
1385 return PeekMessage32_16( (LPMSG16_32)lpmsg, hwnd, first, last, flags, FALSE );
1388 /***********************************************************************
1389 * PeekMessageA
1391 BOOL WINAPI PeekMessageA( LPMSG lpmsg, HWND hwnd,
1392 UINT min, UINT max, UINT wRemoveMsg)
1394 return MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
1397 /***********************************************************************
1398 * PeekMessageW Check queue for messages
1400 * Checks for a message in the thread's queue, filtered as for
1401 * GetMessage(). Returns immediately whether a message is available
1402 * or not.
1404 * Whether a retrieved message is removed from the queue is set by the
1405 * _wRemoveMsg_ flags, which should be one of the following values:
1407 * PM_NOREMOVE Do not remove the message from the queue.
1409 * PM_REMOVE Remove the message from the queue.
1411 * In addition, PM_NOYIELD may be combined into _wRemoveMsg_ to
1412 * request that the system not yield control during PeekMessage();
1413 * however applications may not rely on scheduling behavior.
1415 * RETURNS
1417 * Nonzero if a message is available and is retrieved, zero otherwise.
1419 * CONFORMANCE
1421 * ECMA-234, Win32
1424 BOOL WINAPI PeekMessageW(
1425 LPMSG lpmsg, /* buffer to receive message */
1426 HWND hwnd, /* restrict to messages for hwnd */
1427 UINT min, /* minimum message to receive */
1428 UINT max, /* maximum message to receive */
1429 UINT wRemoveMsg /* removal flags */
1432 return MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
1436 /***********************************************************************
1437 * GetMessage32_16 (USER.820)
1439 BOOL16 WINAPI GetMessage32_16( SEGPTR msg16_32, HWND16 hWnd, UINT16 first,
1440 UINT16 last, BOOL16 wHaveParamHigh )
1442 MSG32_16 *lpmsg16_32 = (MSG32_16 *)PTR_SEG_TO_LIN(msg16_32);
1443 MSG msg;
1445 MSG_PeekMessage( QMSG_WIN16, &msg, hWnd, first, last, PM_REMOVE, FALSE );
1447 lpmsg16_32->msg.hwnd = msg.hwnd;
1448 lpmsg16_32->msg.message = msg.message;
1449 lpmsg16_32->msg.wParam = LOWORD(msg.wParam);
1450 lpmsg16_32->msg.lParam = msg.lParam;
1451 lpmsg16_32->msg.time = msg.time;
1452 lpmsg16_32->msg.pt.x = (INT16)msg.pt.x;
1453 lpmsg16_32->msg.pt.y = (INT16)msg.pt.y;
1455 if ( wHaveParamHigh )
1456 lpmsg16_32->wParamHigh = HIWORD(msg.wParam);
1458 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1459 lpmsg16_32->msg.message, hWnd, first, last );
1461 HOOK_CallHooks16( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)msg16_32 );
1462 return lpmsg16_32->msg.message != WM_QUIT;
1465 /***********************************************************************
1466 * GetMessage16 (USER.108)
1468 BOOL16 WINAPI GetMessage16( SEGPTR msg, HWND16 hwnd, UINT16 first, UINT16 last)
1470 return GetMessage32_16( msg, hwnd, first, last, FALSE );
1473 /***********************************************************************
1474 * GetMessageA (USER32.270)
1476 BOOL WINAPI GetMessageA( MSG *lpmsg, HWND hwnd, UINT min, UINT max )
1478 MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
1480 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1481 lpmsg->message, hwnd, min, max );
1483 HOOK_CallHooksA( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
1484 return lpmsg->message != WM_QUIT;
1487 /***********************************************************************
1488 * GetMessage32W (USER32.274) Retrieve next message
1490 * GetMessage retrieves the next event from the calling thread's
1491 * queue and deposits it in *lpmsg.
1493 * If _hwnd_ is not NULL, only messages for window _hwnd_ and its
1494 * children as specified by IsChild() are retrieved. If _hwnd_ is NULL
1495 * all application messages are retrieved.
1497 * _min_ and _max_ specify the range of messages of interest. If
1498 * min==max==0, no filtering is performed. Useful examples are
1499 * WM_KEYFIRST and WM_KEYLAST to retrieve keyboard input, and
1500 * WM_MOUSEFIRST and WM_MOUSELAST to retrieve mouse input.
1502 * WM_PAINT messages are not removed from the queue; they remain until
1503 * processed. Other messages are removed from the queue.
1505 * RETURNS
1507 * -1 on error, 0 if message is WM_QUIT, nonzero otherwise.
1509 * CONFORMANCE
1511 * ECMA-234, Win32
1514 BOOL WINAPI GetMessageW(
1515 MSG* lpmsg, /* buffer to receive message */
1516 HWND hwnd, /* restrict to messages for hwnd */
1517 UINT min, /* minimum message to receive */
1518 UINT max /* maximum message to receive */
1521 MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
1523 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1524 lpmsg->message, hwnd, min, max );
1526 HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
1527 return lpmsg->message != WM_QUIT;
1530 /***********************************************************************
1531 * MSG_PostToQueue
1533 static BOOL MSG_PostToQueue( HQUEUE16 hQueue, int type, HWND hwnd,
1534 UINT message, WPARAM wParam, LPARAM lParam )
1536 MSG msg;
1538 if ( !hQueue ) return FALSE;
1540 msg.hwnd = hwnd;
1541 msg.message = message;
1542 msg.wParam = wParam;
1543 msg.lParam = lParam;
1544 msg.time = GetTickCount();
1545 msg.pt.x = 0;
1546 msg.pt.y = 0;
1548 return QUEUE_AddMsg( hQueue, type, &msg, 0 );
1551 /***********************************************************************
1552 * MSG_PostMessage
1554 static BOOL MSG_PostMessage( int type, HWND hwnd, UINT message,
1555 WPARAM wParam, LPARAM lParam )
1557 HQUEUE16 hQueue;
1558 WND *wndPtr;
1560 if (hwnd == HWND_BROADCAST)
1562 WND *pDesktop = WIN_GetDesktop();
1563 TRACE("HWND_BROADCAST !\n");
1565 for (wndPtr=WIN_LockWndPtr(pDesktop->child); wndPtr; WIN_UpdateWndPtr(&wndPtr,wndPtr->next))
1567 if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
1569 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n",
1570 wndPtr->hwndSelf, message, wParam, lParam);
1571 MSG_PostToQueue( wndPtr->hmemTaskQ, type,
1572 wndPtr->hwndSelf, message, wParam, lParam );
1575 WIN_ReleaseDesktop();
1576 TRACE("End of HWND_BROADCAST !\n");
1577 return TRUE;
1580 wndPtr = WIN_FindWndPtr( hwnd );
1581 hQueue = wndPtr? wndPtr->hmemTaskQ : 0;
1582 WIN_ReleaseWndPtr(wndPtr);
1584 return MSG_PostToQueue( hQueue, type, hwnd, message, wParam, lParam );
1587 /***********************************************************************
1588 * PostMessage16 (USER.110)
1590 BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam,
1591 LPARAM lParam )
1593 return (BOOL16) MSG_PostMessage( QMSG_WIN16, hwnd, message, wParam, lParam );
1596 /***********************************************************************
1597 * PostMessageA (USER32.419)
1599 BOOL WINAPI PostMessageA( HWND hwnd, UINT message, WPARAM wParam,
1600 LPARAM lParam )
1602 return MSG_PostMessage( QMSG_WIN32A, hwnd, message, wParam, lParam );
1605 /***********************************************************************
1606 * PostMessageW (USER32.420)
1608 BOOL WINAPI PostMessageW( HWND hwnd, UINT message, WPARAM wParam,
1609 LPARAM lParam )
1611 return MSG_PostMessage( QMSG_WIN32W, hwnd, message, wParam, lParam );
1614 /***********************************************************************
1615 * PostAppMessage16 (USER.116)
1617 BOOL16 WINAPI PostAppMessage16( HTASK16 hTask, UINT16 message,
1618 WPARAM16 wParam, LPARAM lParam )
1620 return MSG_PostToQueue( GetTaskQueue16(hTask), QMSG_WIN16,
1621 0, message, wParam, lParam );
1624 /**********************************************************************
1625 * PostThreadMessageA (USER32.422)
1627 BOOL WINAPI PostThreadMessageA( DWORD idThread, UINT message,
1628 WPARAM wParam, LPARAM lParam )
1630 return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32A,
1631 0, message, wParam, lParam );
1634 /**********************************************************************
1635 * PostThreadMessageW (USER32.423)
1637 BOOL WINAPI PostThreadMessageW( DWORD idThread, UINT message,
1638 WPARAM wParam, LPARAM lParam )
1640 return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32W,
1641 0, message, wParam, lParam );
1645 /************************************************************************
1646 * MSG_CallWndProcHook32
1648 static void MSG_CallWndProcHook( LPMSG pmsg, BOOL bUnicode )
1650 CWPSTRUCT cwp;
1652 cwp.lParam = pmsg->lParam;
1653 cwp.wParam = pmsg->wParam;
1654 cwp.message = pmsg->message;
1655 cwp.hwnd = pmsg->hwnd;
1657 if (bUnicode) HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1658 else HOOK_CallHooksA( WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp );
1660 pmsg->lParam = cwp.lParam;
1661 pmsg->wParam = cwp.wParam;
1662 pmsg->message = cwp.message;
1663 pmsg->hwnd = cwp.hwnd;
1667 /***********************************************************************
1668 * MSG_SendMessage
1670 * return values: 0 if timeout occurs
1671 * 1 otherwise
1673 static LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam,
1674 LPARAM lParam, DWORD timeout, WORD flags,
1675 LRESULT *pRes)
1677 WND * wndPtr = 0;
1678 WND **list, **ppWnd;
1679 LRESULT ret = 1;
1681 *pRes = 0;
1683 if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
1685 *pRes = 1;
1687 if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1689 WIN_ReleaseDesktop();
1690 return 1;
1692 WIN_ReleaseDesktop();
1694 TRACE("HWND_BROADCAST !\n");
1695 for (ppWnd = list; *ppWnd; ppWnd++)
1697 WIN_UpdateWndPtr(&wndPtr,*ppWnd);
1698 if (!IsWindow(wndPtr->hwndSelf)) continue;
1699 if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
1701 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n",
1702 wndPtr->hwndSelf, msg, (DWORD)wParam, lParam);
1703 MSG_SendMessage( wndPtr->hwndSelf, msg, wParam, lParam,
1704 timeout, flags, pRes);
1707 WIN_ReleaseWndPtr(wndPtr);
1708 WIN_ReleaseWinArray(list);
1709 TRACE("End of HWND_BROADCAST !\n");
1710 return 1;
1713 if (HOOK_IsHooked( WH_CALLWNDPROC ))
1715 if (flags & SMSG_UNICODE)
1716 MSG_CallWndProcHook( (LPMSG)&hwnd, TRUE);
1717 else if (flags & SMSG_WIN32)
1718 MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE);
1719 else
1721 LPCWPSTRUCT16 pmsg;
1723 if ((pmsg = SEGPTR_NEW(CWPSTRUCT16)))
1725 pmsg->hwnd = hwnd & 0xffff;
1726 pmsg->message= msg & 0xffff;
1727 pmsg->wParam = wParam & 0xffff;
1728 pmsg->lParam = lParam;
1729 HOOK_CallHooks16( WH_CALLWNDPROC, HC_ACTION, 1,
1730 (LPARAM)SEGPTR_GET(pmsg) );
1731 hwnd = pmsg->hwnd;
1732 msg = pmsg->message;
1733 wParam = pmsg->wParam;
1734 lParam = pmsg->lParam;
1735 SEGPTR_FREE( pmsg );
1740 if (!(wndPtr = WIN_FindWndPtr( hwnd )))
1742 WARN("invalid hwnd %04x\n", hwnd );
1743 return 0;
1745 if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
1747 ret = 0; /* Don't send anything if the task is dying */
1748 goto END;
1750 if (flags & SMSG_WIN32)
1751 SPY_EnterMessage( SPY_SENDMESSAGE, hwnd, msg, wParam, lParam );
1752 else
1753 SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wParam, lParam );
1755 if (wndPtr->hmemTaskQ != GetFastQueue16())
1756 ret = MSG_SendMessageInterThread( wndPtr->hmemTaskQ, hwnd, msg,
1757 wParam, lParam, timeout, flags, pRes );
1758 else
1760 /* Call the right CallWindowProc flavor */
1761 if (flags & SMSG_UNICODE)
1762 *pRes = CallWindowProcW( (WNDPROC)wndPtr->winproc,
1763 hwnd, msg, wParam, lParam );
1764 else if (flags & SMSG_WIN32)
1765 *pRes = CallWindowProcA( (WNDPROC)wndPtr->winproc,
1766 hwnd, msg, wParam, lParam );
1767 else
1768 *pRes = CallWindowProc16( (WNDPROC16)wndPtr->winproc,
1769 (HWND16) hwnd, (UINT16) msg,
1770 (WPARAM16) wParam, lParam );
1773 if (flags & SMSG_WIN32)
1774 SPY_ExitMessage( SPY_RESULT_OK, hwnd, msg, *pRes );
1775 else
1776 SPY_ExitMessage( SPY_RESULT_OK16, hwnd, msg, *pRes );
1777 END:
1778 WIN_ReleaseWndPtr(wndPtr);
1779 return ret;
1783 /***********************************************************************
1784 * SendMessage16 (USER.111)
1786 LRESULT WINAPI SendMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
1787 LPARAM lParam)
1789 LRESULT res;
1790 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, 0, &res);
1791 return res;
1795 /***********************************************************************
1796 * SendMessage32A (USER32.454)
1798 LRESULT WINAPI SendMessageA( HWND hwnd, UINT msg, WPARAM wParam,
1799 LPARAM lParam )
1801 LRESULT res;
1803 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE,
1804 SMSG_WIN32, &res);
1806 return res;
1810 /***********************************************************************
1811 * SendMessage32W (USER32.459) Send Window Message
1813 * Sends a message to the window procedure of the specified window.
1814 * SendMessage() will not return until the called window procedure
1815 * either returns or calls ReplyMessage().
1817 * Use PostMessage() to send message and return immediately. A window
1818 * procedure may use InSendMessage() to detect
1819 * SendMessage()-originated messages.
1821 * Applications which communicate via HWND_BROADCAST may use
1822 * RegisterWindowMessage() to obtain a unique message to avoid conflicts
1823 * with other applications.
1825 * CONFORMANCE
1827 * ECMA-234, Win32
1829 LRESULT WINAPI SendMessageW(
1830 HWND hwnd, /* Window to send message to. If HWND_BROADCAST,
1831 the message will be sent to all top-level windows. */
1833 UINT msg, /* message */
1834 WPARAM wParam, /* message parameter */
1835 LPARAM lParam /* additional message parameter */
1837 LRESULT res;
1839 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE,
1840 SMSG_WIN32 | SMSG_UNICODE, &res);
1842 return res;
1846 /***********************************************************************
1847 * SendMessageTimeout16 (not a WINAPI)
1849 LRESULT WINAPI SendMessageTimeout16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
1850 LPARAM lParam, UINT16 flags,
1851 UINT16 timeout, LPWORD resultp)
1853 LRESULT ret;
1854 LRESULT msgRet;
1856 /* FIXME: need support for SMTO_BLOCK */
1858 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, 0, &msgRet);
1859 if (resultp) *resultp = (WORD) msgRet;
1860 return ret;
1864 /***********************************************************************
1865 * SendMessageTimeoutA (USER32.457)
1867 LRESULT WINAPI SendMessageTimeoutA( HWND hwnd, UINT msg, WPARAM wParam,
1868 LPARAM lParam, UINT flags,
1869 UINT timeout, LPDWORD resultp)
1871 LRESULT ret;
1872 LRESULT msgRet;
1874 /* FIXME: need support for SMTO_BLOCK */
1876 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, SMSG_WIN32,
1877 &msgRet);
1879 if (resultp) *resultp = (DWORD) msgRet;
1880 return ret;
1884 /***********************************************************************
1885 * SendMessageTimeoutW (USER32.458)
1887 LRESULT WINAPI SendMessageTimeoutW( HWND hwnd, UINT msg, WPARAM wParam,
1888 LPARAM lParam, UINT flags,
1889 UINT timeout, LPDWORD resultp)
1891 LRESULT ret;
1892 LRESULT msgRet;
1894 /* FIXME: need support for SMTO_BLOCK */
1896 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout,
1897 SMSG_WIN32 | SMSG_UNICODE, &msgRet);
1899 if (resultp) *resultp = (DWORD) msgRet;
1900 return ret;
1904 /***********************************************************************
1905 * WaitMessage (USER.112) (USER32.578) Suspend thread pending messages
1907 * WaitMessage() suspends a thread until events appear in the thread's
1908 * queue.
1910 * BUGS
1912 * Is supposed to return BOOL under Win32.
1914 * Thread-local message queues are not supported.
1916 * CONFORMANCE
1918 * ECMA-234, Win32
1921 void WINAPI WaitMessage( void )
1923 QUEUE_WaitBits( QS_ALLINPUT, INFINITE );
1926 /***********************************************************************
1927 * MsgWaitForMultipleObjects (USER32.400)
1929 DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE *pHandles,
1930 BOOL fWaitAll, DWORD dwMilliseconds,
1931 DWORD dwWakeMask )
1933 DWORD i;
1934 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
1935 DWORD ret;
1936 PDB * pdb = PROCESS_Current();
1938 HQUEUE16 hQueue = GetFastQueue16();
1939 MESSAGEQUEUE *msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
1940 if (!msgQueue) return WAIT_FAILED;
1942 if (nCount > MAXIMUM_WAIT_OBJECTS-1)
1944 SetLastError( ERROR_INVALID_PARAMETER );
1945 QUEUE_Unlock( msgQueue );
1946 return WAIT_FAILED;
1949 msgQueue->changeBits = 0;
1950 msgQueue->wakeMask = dwWakeMask;
1952 if (THREAD_IsWin16(NtCurrentTeb()))
1955 * This is a temporary solution to a big problem.
1956 * You see, the main thread of all Win32 programs is created as a 16 bit
1957 * task. This means that if you want on an event using Win32 synchronization
1958 * methods, the 16 bit scheduler is stopped and things might just stop happening.
1959 * This implements a semi-busy loop that checks the handles to wait on and
1960 * also the message queue. When either one is ready, the wait function returns.
1962 * This will all go away when the real Win32 threads are implemented for all
1963 * the threads of an applications. Including the main thread.
1965 DWORD curTime = GetCurrentTime();
1970 * Check the handles in the list.
1972 SetEvent ( pdb->idle_event );
1973 ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, 5L);
1976 * If the handles have been triggered, return.
1978 if (ret != WAIT_TIMEOUT)
1979 break;
1982 * Then, let the 16 bit scheduler do it's thing.
1984 Yield16();
1987 * If a message matching the wait mask has arrived, return.
1989 if (msgQueue->changeBits & dwWakeMask)
1991 ret = nCount;
1992 break;
1996 * And continue doing this until we hit the timeout.
1998 } while ((dwMilliseconds == INFINITE) || (GetCurrentTime()-curTime < dwMilliseconds) );
2000 else
2002 /* Add the thread event to the handle list */
2003 for (i = 0; i < nCount; i++)
2004 handles[i] = pHandles[i];
2005 handles[nCount] = msgQueue->hEvent;
2007 if ( pdb->main_queue == INVALID_HANDLE_VALUE16 ) pdb->main_queue = hQueue;
2008 if ( pdb->main_queue == hQueue ) SetEvent ( pdb->idle_event );
2009 ret = WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds );
2010 if ( pdb->main_queue == hQueue ) ResetEvent ( pdb->idle_event );
2014 QUEUE_Unlock( msgQueue );
2016 return ret;
2021 struct accent_char
2023 BYTE ac_accent;
2024 BYTE ac_char;
2025 BYTE ac_result;
2028 static const struct accent_char accent_chars[] =
2030 /* A good idea should be to read /usr/X11/lib/X11/locale/iso8859-x/Compose */
2031 {'`', 'A', '\300'}, {'`', 'a', '\340'},
2032 {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
2033 {'^', 'A', '\302'}, {'^', 'a', '\342'},
2034 {'~', 'A', '\303'}, {'~', 'a', '\343'},
2035 {'"', 'A', '\304'}, {'"', 'a', '\344'},
2036 {'O', 'A', '\305'}, {'o', 'a', '\345'},
2037 {'0', 'A', '\305'}, {'0', 'a', '\345'},
2038 {'A', 'A', '\305'}, {'a', 'a', '\345'},
2039 {'A', 'E', '\306'}, {'a', 'e', '\346'},
2040 {',', 'C', '\307'}, {',', 'c', '\347'},
2041 {'`', 'E', '\310'}, {'`', 'e', '\350'},
2042 {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
2043 {'^', 'E', '\312'}, {'^', 'e', '\352'},
2044 {'"', 'E', '\313'}, {'"', 'e', '\353'},
2045 {'`', 'I', '\314'}, {'`', 'i', '\354'},
2046 {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
2047 {'^', 'I', '\316'}, {'^', 'i', '\356'},
2048 {'"', 'I', '\317'}, {'"', 'i', '\357'},
2049 {'-', 'D', '\320'}, {'-', 'd', '\360'},
2050 {'~', 'N', '\321'}, {'~', 'n', '\361'},
2051 {'`', 'O', '\322'}, {'`', 'o', '\362'},
2052 {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
2053 {'^', 'O', '\324'}, {'^', 'o', '\364'},
2054 {'~', 'O', '\325'}, {'~', 'o', '\365'},
2055 {'"', 'O', '\326'}, {'"', 'o', '\366'},
2056 {'/', 'O', '\330'}, {'/', 'o', '\370'},
2057 {'`', 'U', '\331'}, {'`', 'u', '\371'},
2058 {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
2059 {'^', 'U', '\333'}, {'^', 'u', '\373'},
2060 {'"', 'U', '\334'}, {'"', 'u', '\374'},
2061 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
2062 {'T', 'H', '\336'}, {'t', 'h', '\376'},
2063 {'s', 's', '\337'}, {'"', 'y', '\377'},
2064 {'s', 'z', '\337'}, {'i', 'j', '\377'},
2065 /* iso-8859-2 uses this */
2066 {'<', 'L', '\245'}, {'<', 'l', '\265'}, /* caron */
2067 {'<', 'S', '\251'}, {'<', 's', '\271'},
2068 {'<', 'T', '\253'}, {'<', 't', '\273'},
2069 {'<', 'Z', '\256'}, {'<', 'z', '\276'},
2070 {'<', 'C', '\310'}, {'<', 'c', '\350'},
2071 {'<', 'E', '\314'}, {'<', 'e', '\354'},
2072 {'<', 'D', '\317'}, {'<', 'd', '\357'},
2073 {'<', 'N', '\322'}, {'<', 'n', '\362'},
2074 {'<', 'R', '\330'}, {'<', 'r', '\370'},
2075 {';', 'A', '\241'}, {';', 'a', '\261'}, /* ogonek */
2076 {';', 'E', '\312'}, {';', 'e', '\332'},
2077 {'\'', 'Z', '\254'}, {'\'', 'z', '\274'}, /* acute */
2078 {'\'', 'R', '\300'}, {'\'', 'r', '\340'},
2079 {'\'', 'L', '\305'}, {'\'', 'l', '\345'},
2080 {'\'', 'C', '\306'}, {'\'', 'c', '\346'},
2081 {'\'', 'N', '\321'}, {'\'', 'n', '\361'},
2082 /* collision whith S, from iso-8859-9 !!! */
2083 {',', 'S', '\252'}, {',', 's', '\272'}, /* cedilla */
2084 {',', 'T', '\336'}, {',', 't', '\376'},
2085 {'.', 'Z', '\257'}, {'.', 'z', '\277'}, /* dot above */
2086 {'/', 'L', '\243'}, {'/', 'l', '\263'}, /* slash */
2087 {'/', 'D', '\320'}, {'/', 'd', '\360'},
2088 {'(', 'A', '\303'}, {'(', 'a', '\343'}, /* breve */
2089 {'\275', 'O', '\325'}, {'\275', 'o', '\365'}, /* double acute */
2090 {'\275', 'U', '\334'}, {'\275', 'u', '\374'},
2091 {'0', 'U', '\332'}, {'0', 'u', '\372'}, /* ring above */
2092 /* iso-8859-3 uses this */
2093 {'/', 'H', '\241'}, {'/', 'h', '\261'}, /* slash */
2094 {'>', 'H', '\246'}, {'>', 'h', '\266'}, /* circumflex */
2095 {'>', 'J', '\254'}, {'>', 'j', '\274'},
2096 {'>', 'C', '\306'}, {'>', 'c', '\346'},
2097 {'>', 'G', '\330'}, {'>', 'g', '\370'},
2098 {'>', 'S', '\336'}, {'>', 's', '\376'},
2099 /* collision whith G( from iso-8859-9 !!! */
2100 {'(', 'G', '\253'}, {'(', 'g', '\273'}, /* breve */
2101 {'(', 'U', '\335'}, {'(', 'u', '\375'},
2102 /* collision whith I. from iso-8859-3 !!! */
2103 {'.', 'I', '\251'}, {'.', 'i', '\271'}, /* dot above */
2104 {'.', 'C', '\305'}, {'.', 'c', '\345'},
2105 {'.', 'G', '\325'}, {'.', 'g', '\365'},
2106 /* iso-8859-4 uses this */
2107 {',', 'R', '\243'}, {',', 'r', '\263'}, /* cedilla */
2108 {',', 'L', '\246'}, {',', 'l', '\266'},
2109 {',', 'G', '\253'}, {',', 'g', '\273'},
2110 {',', 'N', '\321'}, {',', 'n', '\361'},
2111 {',', 'K', '\323'}, {',', 'k', '\363'},
2112 {'~', 'I', '\245'}, {'~', 'i', '\265'}, /* tilde */
2113 {'-', 'E', '\252'}, {'-', 'e', '\272'}, /* macron */
2114 {'-', 'A', '\300'}, {'-', 'a', '\340'},
2115 {'-', 'I', '\317'}, {'-', 'i', '\357'},
2116 {'-', 'O', '\322'}, {'-', 'o', '\362'},
2117 {'-', 'U', '\336'}, {'-', 'u', '\376'},
2118 {'/', 'T', '\254'}, {'/', 't', '\274'}, /* slash */
2119 {'.', 'E', '\314'}, {'.', 'e', '\344'}, /* dot above */
2120 {';', 'I', '\307'}, {';', 'i', '\347'}, /* ogonek */
2121 {';', 'U', '\331'}, {';', 'u', '\371'},
2122 /* iso-8859-9 uses this */
2123 /* iso-8859-9 has really bad choosen G( S, and I. as they collide
2124 * whith the same letters on other iso-8859-x (that is they are on
2125 * different places :-( ), if you use turkish uncomment these and
2126 * comment out the lines in iso-8859-2 and iso-8859-3 sections
2127 * FIXME: should be dynamic according to chosen language
2128 * if/when Wine has turkish support.
2130 /* collision whith G( from iso-8859-3 !!! */
2131 /* {'(', 'G', '\320'}, {'(', 'g', '\360'}, */ /* breve */
2132 /* collision whith S, from iso-8859-2 !!! */
2133 /* {',', 'S', '\336'}, {',', 's', '\376'}, */ /* cedilla */
2134 /* collision whith I. from iso-8859-3 !!! */
2135 /* {'.', 'I', '\335'}, {'.', 'i', '\375'}, */ /* dot above */
2139 /***********************************************************************
2140 * MSG_DoTranslateMessage
2142 * Implementation of TranslateMessage.
2144 * TranslateMessage translates virtual-key messages into character-messages,
2145 * as follows :
2146 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
2147 * ditto replacing WM_* with WM_SYS*
2148 * This produces WM_CHAR messages only for keys mapped to ASCII characters
2149 * by the keyboard driver.
2151 static BOOL MSG_DoTranslateMessage( UINT message, HWND hwnd,
2152 WPARAM wParam, LPARAM lParam )
2154 static int dead_char;
2155 BYTE wp[2];
2157 if (message != WM_MOUSEMOVE && message != WM_TIMER)
2158 TRACE("(%s, %04X, %08lX)\n",
2159 SPY_GetMsgName(message), wParam, lParam );
2160 if(message >= WM_KEYFIRST && message <= WM_KEYLAST)
2161 TRACE_(key)("(%s, %04X, %08lX)\n",
2162 SPY_GetMsgName(message), wParam, lParam );
2164 if ((message != WM_KEYDOWN) && (message != WM_SYSKEYDOWN)) return FALSE;
2166 TRACE_(key)("Translating key %04X, scancode %04X\n",
2167 wParam, HIWORD(lParam) );
2169 /* FIXME : should handle ToAscii yielding 2 */
2170 switch (ToAscii(wParam, HIWORD(lParam),
2171 QueueKeyStateTable,(LPWORD)wp, 0))
2173 case 1 :
2174 message = (message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
2175 /* Should dead chars handling go in ToAscii ? */
2176 if (dead_char)
2178 int i;
2180 if (wp[0] == ' ') wp[0] = dead_char;
2181 if (dead_char == 0xa2) dead_char = '(';
2182 else if (dead_char == 0xa8) dead_char = '"';
2183 else if (dead_char == 0xb2) dead_char = ';';
2184 else if (dead_char == 0xb4) dead_char = '\'';
2185 else if (dead_char == 0xb7) dead_char = '<';
2186 else if (dead_char == 0xb8) dead_char = ',';
2187 else if (dead_char == 0xff) dead_char = '.';
2188 for (i = 0; i < sizeof(accent_chars)/sizeof(accent_chars[0]); i++)
2189 if ((accent_chars[i].ac_accent == dead_char) &&
2190 (accent_chars[i].ac_char == wp[0]))
2192 wp[0] = accent_chars[i].ac_result;
2193 break;
2195 dead_char = 0;
2197 TRACE_(key)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message));
2198 PostMessage16( hwnd, message, wp[0], lParam );
2199 return TRUE;
2201 case -1 :
2202 message = (message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
2203 dead_char = wp[0];
2204 TRACE_(key)("-1 -> PostMessage(%s)\n",
2205 SPY_GetMsgName(message));
2206 PostMessage16( hwnd, message, wp[0], lParam );
2207 return TRUE;
2209 return FALSE;
2213 /***********************************************************************
2214 * TranslateMessage16 (USER.113)
2216 BOOL16 WINAPI TranslateMessage16( const MSG16 *msg )
2218 return MSG_DoTranslateMessage( msg->message, msg->hwnd,
2219 msg->wParam, msg->lParam );
2223 /***********************************************************************
2224 * WIN16_TranslateMessage32 (USER.821)
2226 BOOL16 WINAPI TranslateMessage32_16( const MSG32_16 *msg, BOOL16 wHaveParamHigh )
2228 WPARAM wParam;
2230 if (wHaveParamHigh)
2231 wParam = MAKELONG(msg->msg.wParam, msg->wParamHigh);
2232 else
2233 wParam = (WPARAM)msg->msg.wParam;
2235 return MSG_DoTranslateMessage( msg->msg.message, msg->msg.hwnd,
2236 wParam, msg->msg.lParam );
2239 /***********************************************************************
2240 * TranslateMessage32 (USER32.556)
2242 BOOL WINAPI TranslateMessage( const MSG *msg )
2244 return MSG_DoTranslateMessage( msg->message, msg->hwnd,
2245 msg->wParam, msg->lParam );
2249 /***********************************************************************
2250 * DispatchMessage16 (USER.114)
2252 LONG WINAPI DispatchMessage16( const MSG16* msg )
2254 WND * wndPtr;
2255 LONG retval;
2256 int painting;
2258 /* Process timer messages */
2259 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2261 if (msg->lParam)
2263 return CallWindowProc16( (WNDPROC16)msg->lParam, msg->hwnd,
2264 msg->message, msg->wParam, GetTickCount() );
2268 if (!msg->hwnd) return 0;
2269 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2270 if (!wndPtr->winproc)
2272 retval = 0;
2273 goto END;
2275 painting = (msg->message == WM_PAINT);
2276 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2278 SPY_EnterMessage( SPY_DISPATCHMESSAGE16, msg->hwnd, msg->message,
2279 msg->wParam, msg->lParam );
2280 retval = CallWindowProc16( (WNDPROC16)wndPtr->winproc,
2281 msg->hwnd, msg->message,
2282 msg->wParam, msg->lParam );
2283 SPY_ExitMessage( SPY_RESULT_OK16, msg->hwnd, msg->message, retval );
2285 WIN_ReleaseWndPtr(wndPtr);
2286 wndPtr = WIN_FindWndPtr(msg->hwnd);
2287 if (painting && wndPtr &&
2288 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2290 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2291 msg->hwnd);
2292 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2293 /* Validate the update region to avoid infinite WM_PAINT loop */
2294 ValidateRect( msg->hwnd, NULL );
2296 END:
2297 WIN_ReleaseWndPtr(wndPtr);
2298 return retval;
2302 /***********************************************************************
2303 * WIN16_DispatchMessage32 (USER.822)
2305 LONG WINAPI DispatchMessage32_16( const MSG32_16* lpmsg16_32, BOOL16 wHaveParamHigh )
2307 if (wHaveParamHigh == FALSE)
2308 return DispatchMessage16(&(lpmsg16_32->msg));
2309 else
2311 MSG msg;
2313 msg.hwnd = lpmsg16_32->msg.hwnd;
2314 msg.message = lpmsg16_32->msg.message;
2315 msg.wParam = MAKELONG(lpmsg16_32->msg.wParam, lpmsg16_32->wParamHigh);
2316 msg.lParam = lpmsg16_32->msg.lParam;
2317 msg.time = lpmsg16_32->msg.time;
2318 msg.pt.x = (INT)lpmsg16_32->msg.pt.x;
2319 msg.pt.y = (INT)lpmsg16_32->msg.pt.y;
2320 return DispatchMessageA(&msg);
2324 /***********************************************************************
2325 * DispatchMessage32A (USER32.141)
2327 LONG WINAPI DispatchMessageA( const MSG* msg )
2329 WND * wndPtr;
2330 LONG retval;
2331 int painting;
2333 /* Process timer messages */
2334 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2336 if (msg->lParam)
2338 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2339 return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
2340 msg->message, msg->wParam, GetTickCount() );
2344 if (!msg->hwnd) return 0;
2345 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2346 if (!wndPtr->winproc)
2348 retval = 0;
2349 goto END;
2351 painting = (msg->message == WM_PAINT);
2352 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2353 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2355 SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
2356 msg->wParam, msg->lParam );
2357 retval = CallWindowProcA( (WNDPROC)wndPtr->winproc,
2358 msg->hwnd, msg->message,
2359 msg->wParam, msg->lParam );
2360 SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval );
2362 WIN_ReleaseWndPtr(wndPtr);
2363 wndPtr = WIN_FindWndPtr(msg->hwnd);
2365 if (painting && wndPtr &&
2366 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2368 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2369 msg->hwnd);
2370 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2371 /* Validate the update region to avoid infinite WM_PAINT loop */
2372 ValidateRect( msg->hwnd, NULL );
2374 END:
2375 WIN_ReleaseWndPtr(wndPtr);
2376 return retval;
2380 /***********************************************************************
2381 * DispatchMessage32W (USER32.142) Process Message
2383 * Process the message specified in the structure *_msg_.
2385 * If the lpMsg parameter points to a WM_TIMER message and the
2386 * parameter of the WM_TIMER message is not NULL, the lParam parameter
2387 * points to the function that is called instead of the window
2388 * procedure.
2390 * The message must be valid.
2392 * RETURNS
2394 * DispatchMessage() returns the result of the window procedure invoked.
2396 * CONFORMANCE
2398 * ECMA-234, Win32
2401 LONG WINAPI DispatchMessageW( const MSG* msg )
2403 WND * wndPtr;
2404 LONG retval;
2405 int painting;
2407 /* Process timer messages */
2408 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2410 if (msg->lParam)
2412 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2413 return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd,
2414 msg->message, msg->wParam, GetTickCount() );
2418 if (!msg->hwnd) return 0;
2419 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2420 if (!wndPtr->winproc)
2422 retval = 0;
2423 goto END;
2425 painting = (msg->message == WM_PAINT);
2426 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2427 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2429 SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
2430 msg->wParam, msg->lParam );
2431 retval = CallWindowProcW( (WNDPROC)wndPtr->winproc,
2432 msg->hwnd, msg->message,
2433 msg->wParam, msg->lParam );
2434 SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval );
2436 WIN_ReleaseWndPtr(wndPtr);
2437 wndPtr = WIN_FindWndPtr(msg->hwnd);
2439 if (painting && wndPtr &&
2440 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2442 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2443 msg->hwnd);
2444 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2445 /* Validate the update region to avoid infinite WM_PAINT loop */
2446 ValidateRect( msg->hwnd, NULL );
2448 END:
2449 WIN_ReleaseWndPtr(wndPtr);
2450 return retval;
2454 /***********************************************************************
2455 * RegisterWindowMessageA (USER.118) (USER32.437)
2457 WORD WINAPI RegisterWindowMessageA( LPCSTR str )
2459 TRACE("%s\n", str );
2460 return GlobalAddAtomA( str );
2464 /***********************************************************************
2465 * RegisterWindowMessage32W (USER32.438)
2467 WORD WINAPI RegisterWindowMessageW( LPCWSTR str )
2469 TRACE("%p\n", str );
2470 return GlobalAddAtomW( str );
2474 /***********************************************************************
2475 * GetTickCount (USER.13) (KERNEL32.299) System Time
2476 * Returns the number of milliseconds, modulo 2^32, since the start
2477 * of the current session.
2479 * CONFORMANCE
2481 * ECMA-234, Win32
2483 DWORD WINAPI GetTickCount(void)
2485 struct timeval t;
2486 gettimeofday( &t, NULL );
2487 return ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - MSG_WineStartTicks;
2491 /***********************************************************************
2492 * GetCurrentTime16 (USER.15)
2494 * (effectively identical to GetTickCount)
2496 DWORD WINAPI GetCurrentTime16(void)
2498 return GetTickCount();
2502 /***********************************************************************
2503 * InSendMessage16 (USER.192)
2505 BOOL16 WINAPI InSendMessage16(void)
2507 return InSendMessage();
2511 /***********************************************************************
2512 * InSendMessage32 (USER32.320)
2514 BOOL WINAPI InSendMessage(void)
2516 MESSAGEQUEUE *queue;
2517 BOOL ret;
2519 if (!(queue = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
2520 return 0;
2521 ret = (BOOL)queue->smWaiting;
2523 QUEUE_Unlock( queue );
2524 return ret;
2527 /***********************************************************************
2528 * BroadcastSystemMessage (USER32.12)
2530 LONG WINAPI BroadcastSystemMessage(
2531 DWORD dwFlags,LPDWORD recipients,UINT uMessage,WPARAM wParam,
2532 LPARAM lParam
2534 FIXME_(sendmsg)("(%08lx,%08lx,%08x,%08x,%08lx): stub!\n",
2535 dwFlags,*recipients,uMessage,wParam,lParam
2537 return 0;
2540 /***********************************************************************
2541 * SendNotifyMessageA (USER32.460)
2542 * FIXME
2543 * The message sended with PostMessage has to be put in the queue
2544 * with a higher priority as the other "Posted" messages.
2545 * QUEUE_AddMsg has to be modifyed.
2547 BOOL WINAPI SendNotifyMessageA(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
2548 { BOOL ret = TRUE;
2549 FIXME("(%04x,%08x,%08x,%08lx) not complete\n",
2550 hwnd, msg, wParam, lParam);
2552 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL))
2553 { ret=SendMessageA ( hwnd, msg, wParam, lParam );
2555 else
2556 { PostMessageA ( hwnd, msg, wParam, lParam );
2558 return ret;
2561 /***********************************************************************
2562 * SendNotifyMessageW (USER32.461)
2563 * FIXME
2564 * The message sended with PostMessage has to be put in the queue
2565 * with a higher priority as the other "Posted" messages.
2566 * QUEUE_AddMsg has to be modifyed.
2568 BOOL WINAPI SendNotifyMessageW(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
2569 { BOOL ret = TRUE;
2570 FIXME("(%04x,%08x,%08x,%08lx) not complete\n",
2571 hwnd, msg, wParam, lParam);
2573 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL))
2574 { ret=SendMessageW ( hwnd, msg, wParam, lParam );
2576 else
2577 { PostMessageW ( hwnd, msg, wParam, lParam );
2579 return ret;
2582 /***********************************************************************
2583 * SendMessageCallback32A
2584 * FIXME: It's like PostMessage. The callback gets called when the message
2585 * is processed. We have to modify the message processing for a exact
2586 * implementation...
2588 BOOL WINAPI SendMessageCallbackA(
2589 HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam,
2590 FARPROC lpResultCallBack,DWORD dwData)
2592 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2593 hWnd,Msg,wParam,lParam,lpResultCallBack,dwData);
2594 if ( hWnd == HWND_BROADCAST)
2595 { PostMessageA( hWnd, Msg, wParam, lParam);
2596 FIXME("Broadcast: Callback will not be called!\n");
2597 return TRUE;
2599 (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam ));
2600 return TRUE;
2602 /***********************************************************************
2603 * SendMessageCallback32W
2604 * FIXME: It's like PostMessage. The callback gets called when the message
2605 * is processed. We have to modify the message processing for a exact
2606 * implementation...
2608 BOOL WINAPI SendMessageCallbackW(
2609 HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam,
2610 FARPROC lpResultCallBack,DWORD dwData)
2612 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2613 hWnd,Msg,wParam,lParam,lpResultCallBack,dwData);
2614 if ( hWnd == HWND_BROADCAST)
2615 { PostMessageW( hWnd, Msg, wParam, lParam);
2616 FIXME("Broadcast: Callback will not be called!\n");
2617 return TRUE;
2619 (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam ));
2620 return TRUE;