FindResourceExA/W should search for the specified language resource only.
[wine/dcerpc.git] / windows / message.c
blobccaa14e7ed2af9694d67728943ce88c9fb2bfb40
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 "selectors.h"
27 #include "thread.h"
28 #include "options.h"
29 #include "menu.h"
30 #include "struct32.h"
31 #include "debugtools.h"
33 DEFAULT_DEBUG_CHANNEL(msg);
34 DECLARE_DEBUG_CHANNEL(key);
35 DECLARE_DEBUG_CHANNEL(sendmsg);
37 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
38 #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
41 typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP,
42 SYSQ_MSG_ACCEPT, SYSQ_MSG_CONTINUE } SYSQ_STATUS;
44 extern HQUEUE16 hCursorQueue; /* queue.c */
46 static UINT doubleClickSpeed = 452;
48 /***********************************************************************
49 * MSG_CheckFilter
51 static BOOL MSG_CheckFilter(DWORD uMsg, DWORD first, DWORD last)
53 if( first || last )
54 return (uMsg >= first && uMsg <= last);
55 return TRUE;
58 /***********************************************************************
59 * MSG_SendParentNotify
61 * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
62 * the window has the WS_EX_NOPARENTNOTIFY style.
64 static void MSG_SendParentNotify(WND* wndPtr, WORD event, WORD idChild, LPARAM lValue)
66 #define lppt ((LPPOINT16)&lValue)
68 /* pt has to be in the client coordinates of the parent window */
69 WND *tmpWnd = WIN_LockWndPtr(wndPtr);
71 MapWindowPoints16( 0, tmpWnd->hwndSelf, lppt, 1 );
72 while (tmpWnd)
74 if (!(tmpWnd->dwStyle & WS_CHILD) || (tmpWnd->dwExStyle & WS_EX_NOPARENTNOTIFY))
76 WIN_ReleaseWndPtr(tmpWnd);
77 break;
79 lppt->x += tmpWnd->rectClient.left;
80 lppt->y += tmpWnd->rectClient.top;
81 WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent);
82 SendMessageA( tmpWnd->hwndSelf, WM_PARENTNOTIFY,
83 MAKEWPARAM( event, idChild ), lValue );
86 #undef lppt
90 /***********************************************************************
91 * MSG_TranslateMouseMsg
93 * Translate an mouse hardware event into a real mouse message.
95 * Returns:
97 * SYSQ_MSG_ABANDON - abandon the peek message loop
98 * SYSQ_MSG_CONTINUE - leave the message in the queue and
99 * continue with the translation loop
100 * SYSQ_MSG_ACCEPT - proceed to process the translated message
102 static DWORD MSG_TranslateMouseMsg( HWND hTopWnd, DWORD first, DWORD last,
103 MSG *msg, BOOL remove, WND* pWndScope,
104 INT16 *pHitTest, POINT16 *pScreen_pt, BOOL *pmouseClick )
106 static DWORD dblclk_time_limit = 0;
107 static UINT16 clk_message = 0;
108 static HWND16 clk_hwnd = 0;
109 static POINT16 clk_pos = { 0, 0 };
111 WND *pWnd;
112 HWND hWnd;
113 INT16 ht, hittest;
114 UINT message = msg->message;
115 POINT16 screen_pt, pt;
116 HANDLE16 hQ = GetFastQueue16();
117 MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock(hQ);
118 BOOL mouseClick = ((message == WM_LBUTTONDOWN) ||
119 (message == WM_RBUTTONDOWN) ||
120 (message == WM_MBUTTONDOWN))?1:0;
121 DWORD retvalue;
123 /* Find the window to dispatch this mouse message to */
125 CONV_POINT32TO16( &msg->pt, &pt );
127 hWnd = GetCapture();
129 /* If no capture HWND, find window which contains the mouse position.
130 * Also find the position of the cursor hot spot (hittest) */
131 if( !hWnd )
133 ht = hittest = WINPOS_WindowFromPoint( pWndScope, pt, &pWnd );
134 if( !pWnd ) pWnd = WIN_GetDesktop();
135 else WIN_LockWndPtr(pWnd);
136 hWnd = pWnd->hwndSelf;
138 else
140 ht = hittest = HTCLIENT;
141 pWnd = WIN_FindWndPtr(hWnd);
142 if (queue)
143 ht = PERQDATA_GetCaptureInfo( queue->pQData );
146 /* Save hittest for return */
147 *pHitTest = hittest;
149 /* stop if not the right queue */
151 if (pWnd->hmemTaskQ != hQ)
153 /* Not for the current task */
154 if (queue) QUEUE_ClearWakeBit( queue, QS_MOUSE );
155 /* Wake up the other task */
156 QUEUE_Unlock( queue );
157 queue = (MESSAGEQUEUE *)QUEUE_Lock( pWnd->hmemTaskQ );
158 if (queue) QUEUE_SetWakeBit( queue, QS_MOUSE );
160 QUEUE_Unlock( queue );
161 retvalue = SYSQ_MSG_ABANDON;
162 goto END;
165 /* check if hWnd is within hWndScope */
167 if( hTopWnd && hWnd != hTopWnd )
168 if( !IsChild(hTopWnd, hWnd) )
170 QUEUE_Unlock( queue );
171 retvalue = SYSQ_MSG_CONTINUE;
172 goto END;
175 /* Was it a mouse click message */
176 if( mouseClick )
178 /* translate double clicks -
179 * note that ...MOUSEMOVEs can slip in between
180 * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
182 if(GetClassLongA(hWnd, GCL_STYLE) & CS_DBLCLKS || ht != HTCLIENT )
184 if ((message == clk_message) && (hWnd == clk_hwnd) &&
185 (msg->time - dblclk_time_limit < doubleClickSpeed) &&
186 (abs(msg->pt.x - clk_pos.x) < GetSystemMetrics(SM_CXDOUBLECLK)/2) &&
187 (abs(msg->pt.y - clk_pos.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2))
189 message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
190 mouseClick++; /* == 2 */
194 /* save mouse position */
195 screen_pt = pt;
196 *pScreen_pt = pt;
198 if (hittest != HTCLIENT)
200 message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
201 msg->wParam = hittest;
203 else
204 ScreenToClient16( hWnd, &pt );
206 /* check message filter */
208 if (!MSG_CheckFilter(message, first, last))
210 QUEUE_Unlock(queue);
211 retvalue = SYSQ_MSG_CONTINUE;
212 goto END;
215 /* Update global hCursorQueue */
216 hCursorQueue = queue->self;
218 /* Update static double click conditions */
219 if( remove && mouseClick )
221 if( mouseClick == 1 )
223 /* set conditions */
224 dblclk_time_limit = msg->time;
225 clk_message = msg->message;
226 clk_hwnd = hWnd;
227 clk_pos = screen_pt;
228 } else
229 /* got double click - zero them out */
230 dblclk_time_limit = clk_hwnd = 0;
233 QUEUE_Unlock(queue);
235 /* Update message params */
236 msg->hwnd = hWnd;
237 msg->message = message;
238 msg->lParam = MAKELONG( pt.x, pt.y );
239 retvalue = SYSQ_MSG_ACCEPT;
241 END:
242 WIN_ReleaseWndPtr(pWnd);
244 /* Return mouseclick flag */
245 *pmouseClick = mouseClick;
247 return retvalue;
251 /***********************************************************************
252 * MSG_ProcessMouseMsg
254 * Processes a translated mouse hardware event.
255 * The passed in msg structure should contain the updated hWnd,
256 * lParam, wParam and message fields from MSG_TranslateMouseMsg.
258 * Returns:
260 * SYSQ_MSG_SKIP - Message should be skipped entirely (in this case
261 * HIWORD contains hit test code). Continue translating..
262 * SYSQ_MSG_ACCEPT - the translated message must be passed to the user
263 * MSG_PeekHardwareMsg should return TRUE.
265 static DWORD MSG_ProcessMouseMsg( MSG *msg, BOOL remove, INT16 hittest,
266 POINT16 screen_pt, BOOL mouseClick )
268 WND *pWnd;
269 HWND hWnd = msg->hwnd;
270 INT16 sendSC = (GetCapture() == 0);
271 UINT message = msg->message;
272 BOOL eatMsg = FALSE;
273 DWORD retvalue;
275 pWnd = WIN_FindWndPtr(hWnd);
277 /* call WH_MOUSE */
279 if (HOOK_IsHooked( WH_MOUSE ))
281 SYSQ_STATUS ret = 0;
282 MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
283 if( hook )
285 hook->pt = screen_pt;
286 hook->hwnd = hWnd;
287 hook->wHitTestCode = hittest;
288 hook->dwExtraInfo = 0;
289 ret = HOOK_CallHooks16( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
290 message, (LPARAM)SEGPTR_GET(hook) );
291 SEGPTR_FREE(hook);
293 if( ret )
295 retvalue = MAKELONG((INT16)SYSQ_MSG_SKIP, hittest);
296 goto END;
300 if (message >= WM_NCMOUSEFIRST && message <= WM_NCMOUSELAST)
301 message += WM_MOUSEFIRST - WM_NCMOUSEFIRST;
303 if ((hittest == HTERROR) || (hittest == HTNOWHERE))
304 eatMsg = sendSC = 1;
305 else if( remove && mouseClick )
307 HWND hwndTop = WIN_GetTopParent( hWnd );
309 if( sendSC )
311 /* Send the WM_PARENTNOTIFY,
312 * note that even for double/nonclient clicks
313 * notification message is still WM_L/M/RBUTTONDOWN.
316 MSG_SendParentNotify( pWnd, message, 0, MAKELPARAM(screen_pt.x, screen_pt.y) );
318 /* Activate the window if needed */
320 if (hWnd != GetActiveWindow() && hWnd != GetDesktopWindow())
322 LONG ret = SendMessageA( hWnd, WM_MOUSEACTIVATE, hwndTop,
323 MAKELONG( hittest, message ) );
325 if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
326 eatMsg = TRUE;
328 if (((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
329 && hwndTop != GetForegroundWindow() )
331 if (!WINPOS_SetActiveWindow( hwndTop, TRUE , TRUE ))
332 eatMsg = TRUE;
336 } else sendSC = (remove && sendSC);
338 /* Send the WM_SETCURSOR message */
340 if (sendSC)
342 /* Windows sends the normal mouse message as the message parameter
343 in the WM_SETCURSOR message even if it's non-client mouse message */
344 SendMessageA( hWnd, WM_SETCURSOR, hWnd,
345 MAKELONG( hittest, message ));
347 if (eatMsg)
349 retvalue = MAKELONG( (UINT16)SYSQ_MSG_SKIP, hittest);
350 goto END;
353 retvalue = SYSQ_MSG_ACCEPT;
354 END:
355 WIN_ReleaseWndPtr(pWnd);
357 return retvalue;
361 /***********************************************************************
362 * MSG_TranslateKbdMsg
364 * Translate an keyboard hardware event into a real message.
366 static DWORD MSG_TranslateKbdMsg( HWND hTopWnd, DWORD first, DWORD last,
367 MSG *msg, BOOL remove )
369 WORD message = msg->message;
370 HWND hWnd = GetFocus();
371 WND *pWnd;
373 /* Should check Ctrl-Esc and PrintScreen here */
375 if (!hWnd)
377 /* Send the message to the active window instead, */
378 /* translating messages to their WM_SYS equivalent */
380 hWnd = GetActiveWindow();
382 if( message < WM_SYSKEYDOWN )
383 message += WM_SYSKEYDOWN - WM_KEYDOWN;
385 pWnd = WIN_FindWndPtr( hWnd );
386 if (pWnd && (pWnd->hmemTaskQ != GetFastQueue16()))
388 /* Not for the current task */
389 MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() );
390 if (queue) QUEUE_ClearWakeBit( queue, QS_KEY );
391 QUEUE_Unlock( queue );
393 /* Wake up the other task */
394 queue = (MESSAGEQUEUE *)QUEUE_Lock( pWnd->hmemTaskQ );
395 if (queue) QUEUE_SetWakeBit( queue, QS_KEY );
396 QUEUE_Unlock( queue );
397 WIN_ReleaseWndPtr(pWnd);
398 return SYSQ_MSG_ABANDON;
400 WIN_ReleaseWndPtr(pWnd);
402 if (hTopWnd && hWnd != hTopWnd)
403 if (!IsChild(hTopWnd, hWnd)) return SYSQ_MSG_CONTINUE;
404 if (!MSG_CheckFilter(message, first, last)) return SYSQ_MSG_CONTINUE;
406 msg->hwnd = hWnd;
407 msg->message = message;
409 return SYSQ_MSG_ACCEPT;
413 /***********************************************************************
414 * MSG_ProcessKbdMsg
416 * Processes a translated keyboard message
418 static DWORD MSG_ProcessKbdMsg( MSG *msg, BOOL remove )
420 /* Handle F1 key by sending out WM_HELP message */
421 if ((msg->message == WM_KEYUP) &&
422 (msg->wParam == VK_F1) &&
423 remove &&
424 (msg->hwnd != GetDesktopWindow()) &&
425 !MENU_IsMenuActive())
427 HELPINFO hi;
428 WND *pWnd = WIN_FindWndPtr(msg->hwnd);
430 if (NULL != pWnd)
432 hi.cbSize = sizeof(HELPINFO);
433 hi.iContextType = HELPINFO_WINDOW;
434 hi.iCtrlId = pWnd->wIDmenu;
435 hi.hItemHandle = msg->hwnd;
436 hi.dwContextId = pWnd->helpContext;
437 hi.MousePos = msg->pt;
438 SendMessageA(msg->hwnd, WM_HELP, 0, (LPARAM)&hi);
440 WIN_ReleaseWndPtr(pWnd);
443 return (HOOK_CallHooks16( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE,
444 LOWORD (msg->wParam), msg->lParam )
445 ? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT);
449 /***********************************************************************
450 * MSG_JournalRecordMsg
452 * Build an EVENTMSG structure and call JOURNALRECORD hook
454 static void MSG_JournalRecordMsg( MSG *msg )
456 EVENTMSG *event = (EVENTMSG *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG));
457 if (!event) return;
458 event->message = msg->message;
459 event->time = msg->time;
460 if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
462 event->paramL = (msg->wParam & 0xFF) | (HIWORD(msg->lParam) << 8);
463 event->paramH = msg->lParam & 0x7FFF;
464 if (HIWORD(msg->lParam) & 0x0100)
465 event->paramH |= 0x8000; /* special_key - bit */
466 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
468 else if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
470 event->paramL = LOWORD(msg->lParam); /* X pos */
471 event->paramH = HIWORD(msg->lParam); /* Y pos */
472 ClientToScreen16( msg->hwnd, (LPPOINT16)&event->paramL );
473 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
475 else if ((msg->message >= WM_NCMOUSEFIRST) &&
476 (msg->message <= WM_NCMOUSELAST))
478 event->paramL = LOWORD(msg->lParam); /* X pos */
479 event->paramH = HIWORD(msg->lParam); /* Y pos */
480 event->message += WM_MOUSEMOVE-WM_NCMOUSEMOVE;/* give no info about NC area */
481 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
484 HeapFree(SystemHeap, 0, event);
487 /***********************************************************************
488 * MSG_JournalPlayBackMsg
490 * Get an EVENTMSG struct via call JOURNALPLAYBACK hook function
492 static int MSG_JournalPlayBackMsg(void)
494 EVENTMSG *tmpMsg;
495 long wtime,lParam,wParam;
496 WORD keyDown,i,result=0;
498 if ( HOOK_IsHooked( WH_JOURNALPLAYBACK ) )
500 tmpMsg = (EVENTMSG *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG));
501 if (!tmpMsg) return result;
503 wtime=HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_GETNEXT, 0,
504 (LPARAM) tmpMsg );
505 /* TRACE(msg,"Playback wait time =%ld\n",wtime); */
506 if (wtime<=0)
508 wtime=0;
509 if ((tmpMsg->message>= WM_KEYFIRST) && (tmpMsg->message <= WM_KEYLAST))
511 wParam=tmpMsg->paramL & 0xFF;
512 lParam=MAKELONG(tmpMsg->paramH&0x7ffff,tmpMsg->paramL>>8);
513 if (tmpMsg->message == WM_KEYDOWN || tmpMsg->message == WM_SYSKEYDOWN)
515 for (keyDown=i=0; i<256 && !keyDown; i++)
516 if (InputKeyStateTable[i] & 0x80)
517 keyDown++;
518 if (!keyDown)
519 lParam |= 0x40000000;
520 AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] |= 0x80;
522 else /* WM_KEYUP, WM_SYSKEYUP */
524 lParam |= 0xC0000000;
525 AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] &= ~0x80;
527 if (InputKeyStateTable[VK_MENU] & 0x80)
528 lParam |= 0x20000000;
529 if (tmpMsg->paramH & 0x8000) /*special_key bit*/
530 lParam |= 0x01000000;
531 hardware_event( tmpMsg->message & 0xffff, LOWORD(wParam), lParam,
532 0, 0, tmpMsg->time, 0 );
534 else
536 if ((tmpMsg->message>= WM_MOUSEFIRST) && (tmpMsg->message <= WM_MOUSELAST))
538 switch (tmpMsg->message)
540 case WM_LBUTTONDOWN:
541 MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=TRUE;break;
542 case WM_LBUTTONUP:
543 MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=FALSE;break;
544 case WM_MBUTTONDOWN:
545 MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=TRUE;break;
546 case WM_MBUTTONUP:
547 MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=FALSE;break;
548 case WM_RBUTTONDOWN:
549 MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=TRUE;break;
550 case WM_RBUTTONUP:
551 MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=FALSE;break;
553 AsyncKeyStateTable[VK_LBUTTON]= InputKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0;
554 AsyncKeyStateTable[VK_MBUTTON]= InputKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0;
555 AsyncKeyStateTable[VK_RBUTTON]= InputKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0;
556 SetCursorPos(tmpMsg->paramL,tmpMsg->paramH);
557 lParam=MAKELONG(tmpMsg->paramL,tmpMsg->paramH);
558 wParam=0;
559 if (MouseButtonsStates[0]) wParam |= MK_LBUTTON;
560 if (MouseButtonsStates[1]) wParam |= MK_MBUTTON;
561 if (MouseButtonsStates[2]) wParam |= MK_RBUTTON;
562 hardware_event( tmpMsg->message & 0xffff, LOWORD (wParam), lParam,
563 tmpMsg->paramL, tmpMsg->paramH, tmpMsg->time, 0 );
566 HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_SKIP, 0,
567 (LPARAM) tmpMsg);
569 else
572 if( tmpMsg->message == WM_QUEUESYNC )
573 if (HOOK_IsHooked( WH_CBT ))
574 HOOK_CallHooksA( WH_CBT, HCBT_QS, 0, 0L);
576 result= QS_MOUSE | QS_KEY; /* ? */
578 HeapFree(SystemHeap, 0, tmpMsg);
580 return result;
583 /***********************************************************************
584 * MSG_PeekHardwareMsg
586 * Peek for a hardware message matching the hwnd and message filters.
588 static BOOL MSG_PeekHardwareMsg( MSG *msg, HWND hwnd, DWORD first, DWORD last,
589 BOOL remove )
591 /* FIXME: should deal with MSG32 instead of MSG16 */
593 DWORD status = SYSQ_MSG_ACCEPT;
594 MESSAGEQUEUE *sysMsgQueue = QUEUE_GetSysQueue();
595 enum { MOUSE_MSG = 0, KEYBOARD_MSG, HARDWARE_MSG } msgType;
596 QMSG *nextqmsg, *qmsg = 0;
597 BOOL bRet = FALSE;
599 EnterCriticalSection(&sysMsgQueue->cSection);
601 /* Loop through the Q and translate the message we wish to process
602 * while we own the lock. Based on the translation status (abandon/cont/accept)
603 * we then process the message accordingly
606 for ( qmsg = sysMsgQueue->firstMsg; qmsg; qmsg = nextqmsg )
608 INT16 hittest;
609 POINT16 screen_pt;
610 BOOL mouseClick;
612 *msg = qmsg->msg;
614 nextqmsg = qmsg->nextMsg;
616 /* Translate message */
618 if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
620 HWND hWndScope = (HWND)qmsg->extraInfo;
621 WND *tmpWnd = (Options.managed && IsWindow(hWndScope) )
622 ? WIN_FindWndPtr(hWndScope) : WIN_GetDesktop();
624 status = MSG_TranslateMouseMsg(hwnd, first, last, msg, remove, tmpWnd,
625 &hittest, &screen_pt, &mouseClick );
626 msgType = MOUSE_MSG;
628 WIN_ReleaseWndPtr(tmpWnd);
631 else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
633 status = MSG_TranslateKbdMsg(hwnd, first, last, msg, remove);
634 msgType = KEYBOARD_MSG;
636 else /* Non-standard hardware event */
638 HARDWAREHOOKSTRUCT16 *hook;
639 msgType = HARDWARE_MSG;
640 if ((hook = SEGPTR_NEW(HARDWAREHOOKSTRUCT16)))
642 BOOL ret;
643 hook->hWnd = msg->hwnd;
644 hook->wMessage = msg->message & 0xffff;
645 hook->wParam = LOWORD (msg->wParam);
646 hook->lParam = msg->lParam;
647 ret = HOOK_CallHooks16( WH_HARDWARE,
648 remove ? HC_ACTION : HC_NOREMOVE,
649 0, (LPARAM)SEGPTR_GET(hook) );
650 SEGPTR_FREE(hook);
651 if (ret)
653 QUEUE_RemoveMsg( sysMsgQueue, qmsg );
654 continue;
656 status = SYSQ_MSG_ACCEPT;
661 switch (LOWORD(status))
663 case SYSQ_MSG_ACCEPT:
665 /* Remove the message from the system msg Q while it is still locked,
666 * before accepting it */
667 if (remove)
669 if (HOOK_IsHooked( WH_JOURNALRECORD )) MSG_JournalRecordMsg( msg );
670 QUEUE_RemoveMsg( sysMsgQueue, qmsg );
672 /* Now actually process the message, after we unlock the system msg Q.
673 * We should not hold on to the crst since SendMessage calls during processing
674 * will potentially cause callbacks to PeekMessage from the application.
675 * If we're holding the crst and QUEUE_WaitBits is called with a
676 * QS_SENDMESSAGE mask we will deadlock in hardware_event() when a
677 * message is being posted to the Q.
679 LeaveCriticalSection(&sysMsgQueue->cSection);
680 if( msgType == KEYBOARD_MSG )
681 status = MSG_ProcessKbdMsg( msg, remove );
682 else if ( msgType == MOUSE_MSG )
683 status = MSG_ProcessMouseMsg( msg, remove, hittest, screen_pt, mouseClick );
685 /* Reclaim the sys msg Q crst */
686 EnterCriticalSection(&sysMsgQueue->cSection);
688 /* Pass the translated message to the user if it was accepted */
689 if (status == SYSQ_MSG_ACCEPT)
690 break;
692 /* If not accepted, fall through into the SYSQ_MSG_SKIP case */
695 case SYSQ_MSG_SKIP:
696 if (HOOK_IsHooked( WH_CBT ))
698 if( msgType == KEYBOARD_MSG )
699 HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED,
700 LOWORD (msg->wParam), msg->lParam );
701 else if ( msgType == MOUSE_MSG )
703 MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
704 if (hook)
706 CONV_POINT32TO16( &msg->pt,&hook->pt );
707 hook->hwnd = msg->hwnd;
708 hook->wHitTestCode = HIWORD(status);
709 hook->dwExtraInfo = 0;
710 HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message & 0xffff,
711 (LPARAM)SEGPTR_GET(hook) );
712 SEGPTR_FREE(hook);
717 /* If the message was removed earlier set up nextqmsg so that we start
718 * at the top of the queue again. We need to do this since our next pointer
719 * could be invalid due to us unlocking the system message Q to process the message.
720 * If not removed just refresh nextqmsg to point to the next msg.
722 if (remove)
723 nextqmsg = sysMsgQueue->firstMsg;
724 else
725 nextqmsg = qmsg->nextMsg;
727 continue;
729 case SYSQ_MSG_CONTINUE:
730 continue;
732 case SYSQ_MSG_ABANDON:
733 bRet = FALSE;
734 goto END;
737 bRet = TRUE;
738 goto END;
741 END:
742 LeaveCriticalSection(&sysMsgQueue->cSection);
743 return bRet;
747 /**********************************************************************
748 * SetDoubleClickTime16 (USER.20)
750 void WINAPI SetDoubleClickTime16( UINT16 interval )
752 SetDoubleClickTime( interval );
756 /**********************************************************************
757 * SetDoubleClickTime (USER32.480)
759 BOOL WINAPI SetDoubleClickTime( UINT interval )
761 doubleClickSpeed = interval ? interval : 500;
762 return TRUE;
766 /**********************************************************************
767 * GetDoubleClickTime16 (USER.21)
769 UINT16 WINAPI GetDoubleClickTime16(void)
771 return doubleClickSpeed;
775 /**********************************************************************
776 * GetDoubleClickTime (USER32.239)
778 UINT WINAPI GetDoubleClickTime(void)
780 return doubleClickSpeed;
784 /***********************************************************************
785 * MSG_SendMessageInterThread
787 * Implementation of an inter-task SendMessage.
788 * Return values:
789 * 0 if error or timeout
790 * 1 if successflul
792 static LRESULT MSG_SendMessageInterThread( HQUEUE16 hDestQueue,
793 HWND hwnd, UINT msg,
794 WPARAM wParam, LPARAM lParam,
795 DWORD timeout, WORD flags,
796 LRESULT *pRes)
798 MESSAGEQUEUE *queue, *destQ;
799 SMSG *smsg;
800 LRESULT retVal = 1;
801 int iWndsLocks;
803 *pRes = 0;
805 if (IsTaskLocked16() || !IsWindow(hwnd))
806 return 0;
808 /* create a SMSG structure to hold SendMessage() parameters */
809 if (! (smsg = (SMSG *) HeapAlloc( SystemHeap, 0, sizeof(SMSG) )) )
810 return 0;
811 if (!(queue = (MESSAGEQUEUE*)QUEUE_Lock( GetFastQueue16() ))) return 0;
813 if (!(destQ = (MESSAGEQUEUE*)QUEUE_Lock( hDestQueue )))
815 QUEUE_Unlock( queue );
816 return 0;
819 TRACE_(sendmsg)("SM: %s [%04x] (%04x -> %04x)\n",
820 SPY_GetMsgName(msg), msg, queue->self, hDestQueue );
822 /* fill up SMSG structure */
823 smsg->hWnd = hwnd;
824 smsg->msg = msg;
825 smsg->wParam = wParam;
826 smsg->lParam = lParam;
828 smsg->lResult = 0;
829 smsg->hSrcQueue = GetFastQueue16();
830 smsg->hDstQueue = hDestQueue;
831 smsg->flags = flags;
833 /* add smsg struct in the processing SM list of the source queue */
834 QUEUE_AddSMSG(queue, SM_PROCESSING_LIST, smsg);
836 /* add smsg struct in the pending list of the destination queue */
837 if (QUEUE_AddSMSG(destQ, SM_PENDING_LIST, smsg) == FALSE)
838 return 0;
840 iWndsLocks = WIN_SuspendWndsLock();
842 /* force destination task to run next, if 16 bit threads */
843 if ( THREAD_IsWin16(NtCurrentTeb()) && THREAD_IsWin16(destQ->teb) )
844 DirectedYield16( destQ->teb->htask16 );
846 /* wait for the result, note that 16-bit apps almost always get out of
847 * DirectedYield() with SMSG_HAVE_RESULT flag already set */
849 while ( TRUE )
852 * The sequence is crucial to avoid deadlock situations:
853 * - first, we clear the QS_SMRESULT bit
854 * - then, we check the SMSG_HAVE_RESULT bit
855 * - only if this isn't set, we enter the wait state.
857 * As the receiver first sets the SMSG_HAVE_RESULT and then wakes us,
858 * we are guaranteed that -should we now clear the QS_SMRESULT that
859 * was signalled already by the receiver- we will not start waiting.
862 if ( smsg->flags & SMSG_HAVE_RESULT )
864 got:
865 *pRes = smsg->lResult;
866 TRACE_(sendmsg)("smResult = %08x\n", (unsigned)*pRes );
867 break;
870 QUEUE_ClearWakeBit( queue, QS_SMRESULT );
872 if ( smsg->flags & SMSG_HAVE_RESULT )
873 goto got;
875 if( QUEUE_WaitBits( QS_SMRESULT, timeout ) == 0 )
877 /* return with timeout */
878 SetLastError( 0 );
879 retVal = 0;
880 break;
883 WIN_RestoreWndsLock(iWndsLocks);
885 /* remove the smsg from the processingg list of the source queue */
886 QUEUE_RemoveSMSG( queue, SM_PROCESSING_LIST, smsg );
888 /* Note: the destination thread is in charge of removing the smsg from
889 the pending list */
891 /* In the case of an early reply (or a timeout), sender thread will
892 released the smsg structure if the receiver thread is done
893 (SMSG_RECEIVED set). If the receiver thread isn't done,
894 SMSG_RECEIVER_CLEANS_UP flag is set, and it will be the receiver
895 responsability to released smsg */
896 EnterCriticalSection( &queue->cSection );
898 if (smsg->flags & SMSG_RECEIVED)
899 HeapFree(SystemHeap, 0, smsg);
900 else
901 smsg->flags |= SMSG_RECEIVER_CLEANS;
903 LeaveCriticalSection( &queue->cSection );
906 QUEUE_Unlock( queue );
907 QUEUE_Unlock( destQ );
909 TRACE_(sendmsg)("done!\n");
910 return retVal;
914 /***********************************************************************
915 * ReplyMessage16 (USER.115)
917 void WINAPI ReplyMessage16( LRESULT result )
919 ReplyMessage( result );
922 /***********************************************************************
923 * ReplyMessage (USER.115)
925 BOOL WINAPI ReplyMessage( LRESULT result )
927 MESSAGEQUEUE *senderQ = 0;
928 MESSAGEQUEUE *queue = 0;
929 SMSG *smsg;
930 BOOL ret = FALSE;
932 if (!(queue = (MESSAGEQUEUE*)QUEUE_Lock( GetFastQueue16() )))
933 return FALSE;
935 TRACE_(sendmsg)("ReplyMessage, queue %04x\n", queue->self);
938 if ( !(smsg = queue->smWaiting)
939 || !(senderQ = QUEUE_Lock( smsg->hSrcQueue )) )
940 goto ReplyMessageEnd;
942 if ( !(smsg->flags & SMSG_ALREADY_REPLIED) )
944 /* This is the first reply, so pass result to sender */
946 TRACE_(sendmsg)("\trpm: smResult = %08lx\n", (long) result );
948 EnterCriticalSection(&senderQ->cSection);
950 smsg->lResult = result;
951 smsg->flags |= SMSG_ALREADY_REPLIED;
953 /* check if it's an early reply (called by the application) or
954 a regular reply (called by ReceiveMessage) */
955 if ( !(smsg->flags & SMSG_SENDING_REPLY) )
956 smsg->flags |= SMSG_EARLY_REPLY;
958 smsg->flags |= SMSG_HAVE_RESULT;
960 LeaveCriticalSection(&senderQ->cSection);
962 /* tell the sending task that its reply is ready */
963 QUEUE_SetWakeBit( senderQ, QS_SMRESULT );
965 /* switch directly to sending task (16 bit thread only) */
966 if ( THREAD_IsWin16( NtCurrentTeb() ) && THREAD_IsWin16( senderQ->teb ) )
967 DirectedYield16( senderQ->teb->htask16 );
969 ret = TRUE;
972 if (smsg->flags & SMSG_SENDING_REPLY)
974 /* remove msg from the waiting list, since this is the last
975 ReplyMessage */
976 QUEUE_RemoveSMSG( queue, SM_WAITING_LIST, smsg );
978 EnterCriticalSection(&senderQ->cSection);
980 /* tell the sender we're all done with smsg structure */
981 smsg->flags |= SMSG_RECEIVED;
983 /* sender will set SMSG_RECEIVER_CLEANS_UP if it wants the
984 receiver to clean up smsg, it could only happens when there is
985 an early reply or a timeout */
986 if ( smsg->flags & SMSG_RECEIVER_CLEANS )
988 TRACE_(sendmsg)("Receiver cleans up!\n" );
989 HeapFree( SystemHeap, 0, smsg );
992 LeaveCriticalSection(&senderQ->cSection);
995 ReplyMessageEnd:
996 if ( senderQ )
997 QUEUE_Unlock( senderQ );
998 if ( queue )
999 QUEUE_Unlock( queue );
1001 return ret;
1004 /***********************************************************************
1005 * MSG_ConvertMsg
1007 static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType )
1009 UINT16 msg16;
1010 MSGPARAM16 mp16;
1012 switch ( MAKELONG( srcType, dstType ) )
1014 case MAKELONG( QMSG_WIN16, QMSG_WIN16 ):
1015 case MAKELONG( QMSG_WIN32A, QMSG_WIN32A ):
1016 case MAKELONG( QMSG_WIN32W, QMSG_WIN32W ):
1017 return TRUE;
1019 case MAKELONG( QMSG_WIN16, QMSG_WIN32A ):
1020 switch ( WINPROC_MapMsg16To32A( msg->message, msg->wParam,
1021 &msg->message, &msg->wParam, &msg->lParam ) )
1023 case 0:
1024 return TRUE;
1025 case 1:
1026 /* Pointer messages were mapped --> need to free allocated memory and fail */
1027 WINPROC_UnmapMsg16To32A( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 );
1028 default:
1029 return FALSE;
1032 case MAKELONG( QMSG_WIN16, QMSG_WIN32W ):
1033 switch ( WINPROC_MapMsg16To32W( msg->hwnd, msg->message, msg->wParam,
1034 &msg->message, &msg->wParam, &msg->lParam ) )
1036 case 0:
1037 return TRUE;
1038 case 1:
1039 /* Pointer messages were mapped --> need to free allocated memory and fail */
1040 WINPROC_UnmapMsg16To32W( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 );
1041 default:
1042 return FALSE;
1045 case MAKELONG( QMSG_WIN32A, QMSG_WIN16 ):
1046 mp16.lParam = msg->lParam;
1047 switch ( WINPROC_MapMsg32ATo16( msg->hwnd, msg->message, msg->wParam,
1048 &msg16, &mp16.wParam, &mp16.lParam ) )
1050 case 0:
1051 msg->message = msg16;
1052 msg->wParam = mp16.wParam;
1053 msg->lParam = mp16.lParam;
1054 return TRUE;
1055 case 1:
1056 /* Pointer messages were mapped --> need to free allocated memory and fail */
1057 WINPROC_UnmapMsg32ATo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 );
1058 default:
1059 return FALSE;
1062 case MAKELONG( QMSG_WIN32W, QMSG_WIN16 ):
1063 mp16.lParam = msg->lParam;
1064 switch ( WINPROC_MapMsg32WTo16( msg->hwnd, msg->message, msg->wParam,
1065 &msg16, &mp16.wParam, &mp16.lParam ) )
1067 case 0:
1068 msg->message = msg16;
1069 msg->wParam = mp16.wParam;
1070 msg->lParam = mp16.lParam;
1071 return TRUE;
1072 case 1:
1073 /* Pointer messages were mapped --> need to free allocated memory and fail */
1074 WINPROC_UnmapMsg32WTo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 );
1075 default:
1076 return FALSE;
1079 case MAKELONG( QMSG_WIN32A, QMSG_WIN32W ):
1080 switch ( WINPROC_MapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) )
1082 case 0:
1083 return TRUE;
1084 case 1:
1085 /* Pointer messages were mapped --> need to free allocated memory and fail */
1086 WINPROC_UnmapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, msg->lParam );
1087 default:
1088 return FALSE;
1091 case MAKELONG( QMSG_WIN32W, QMSG_WIN32A ):
1092 switch ( WINPROC_MapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) )
1094 case 0:
1095 return TRUE;
1096 case 1:
1097 /* Pointer messages were mapped --> need to free allocated memory and fail */
1098 WINPROC_UnmapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, msg->lParam );
1099 default:
1100 return FALSE;
1103 default:
1104 FIXME( "Invalid message type(s): %d / %d\n", srcType, dstType );
1105 return FALSE;
1109 /***********************************************************************
1110 * MSG_PeekMessage
1112 static BOOL MSG_PeekMessage( int type, LPMSG msg, HWND hwnd,
1113 DWORD first, DWORD last, WORD flags, BOOL peek )
1115 int mask;
1116 MESSAGEQUEUE *msgQueue;
1117 HQUEUE16 hQueue;
1118 POINT16 pt16;
1119 int iWndsLocks;
1121 mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */
1122 if (first || last)
1124 if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY;
1125 if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) ||
1126 ((first <= WM_NCMOUSELAST) && (last >= WM_NCMOUSEFIRST)) ) mask |= QS_MOUSE;
1127 if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER;
1128 if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER;
1129 if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT;
1131 else mask |= QS_MOUSE | QS_KEY | QS_TIMER | QS_PAINT;
1133 if (IsTaskLocked16()) flags |= PM_NOYIELD;
1135 /* Never yield on Win32 threads */
1136 if (!THREAD_IsWin16(NtCurrentTeb())) flags |= PM_NOYIELD;
1138 iWndsLocks = WIN_SuspendWndsLock();
1140 while(1)
1142 QMSG *qmsg;
1144 hQueue = GetFastQueue16();
1145 msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
1146 if (!msgQueue)
1148 WIN_RestoreWndsLock(iWndsLocks);
1149 return FALSE;
1151 msgQueue->changeBits = 0;
1153 /* First handle a message put by SendMessage() */
1155 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1156 QUEUE_ReceiveMessage( msgQueue );
1158 /* Now handle a WM_QUIT message */
1160 if (msgQueue->wPostQMsg &&
1161 (!first || WM_QUIT >= first) &&
1162 (!last || WM_QUIT <= last) )
1164 msg->hwnd = hwnd;
1165 msg->message = WM_QUIT;
1166 msg->wParam = msgQueue->wExitCode;
1167 msg->lParam = 0;
1168 if (flags & PM_REMOVE) msgQueue->wPostQMsg = 0;
1169 break;
1172 /* Now find a normal message */
1174 retry:
1175 if (((msgQueue->wakeBits & mask) & QS_POSTMESSAGE) &&
1176 ((qmsg = QUEUE_FindMsg( msgQueue, hwnd, first, last )) != 0))
1178 /* Try to convert message to requested type */
1179 MSG tmpMsg = qmsg->msg;
1180 if ( !MSG_ConvertMsg( &tmpMsg, qmsg->type, type ) )
1182 ERR( "Message of wrong type contains pointer parameters. Skipped!\n ");
1183 QUEUE_RemoveMsg( msgQueue, qmsg );
1184 goto retry;
1187 *msg = tmpMsg;
1188 msgQueue->GetMessageTimeVal = msg->time;
1189 CONV_POINT32TO16(&msg->pt, &pt16);
1190 msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
1191 msgQueue->GetMessageExtraInfoVal = qmsg->extraInfo;
1193 if (flags & PM_REMOVE) QUEUE_RemoveMsg( msgQueue, qmsg );
1194 break;
1197 msgQueue->changeBits |= MSG_JournalPlayBackMsg();
1199 /* Now find a hardware event */
1201 if (MSG_PeekHardwareMsg( msg, hwnd, first, last, flags & PM_REMOVE ))
1203 /* Got one */
1204 msgQueue->GetMessageTimeVal = msg->time;
1205 CONV_POINT32TO16(&msg->pt, &pt16);
1206 msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
1207 msgQueue->GetMessageExtraInfoVal = 0; /* Always 0 for now */
1208 break;
1211 /* Check again for SendMessage */
1213 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1214 QUEUE_ReceiveMessage( msgQueue );
1216 /* Now find a WM_PAINT message */
1218 if ((msgQueue->wakeBits & mask) & QS_PAINT)
1220 WND* wndPtr;
1221 msg->hwnd = WIN_FindWinToRepaint( hwnd , hQueue );
1222 msg->message = WM_PAINT;
1223 msg->wParam = 0;
1224 msg->lParam = 0;
1226 if ((wndPtr = WIN_FindWndPtr(msg->hwnd)))
1228 if( wndPtr->dwStyle & WS_MINIMIZE &&
1229 (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON) )
1231 msg->message = WM_PAINTICON;
1232 msg->wParam = 1;
1235 if( !hwnd || msg->hwnd == hwnd || IsChild16(hwnd,msg->hwnd) )
1237 if( wndPtr->flags & WIN_INTERNAL_PAINT && !wndPtr->hrgnUpdate)
1239 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
1240 QUEUE_DecPaintCount( hQueue );
1242 WIN_ReleaseWndPtr(wndPtr);
1243 break;
1245 WIN_ReleaseWndPtr(wndPtr);
1249 /* Check for timer messages, but yield first */
1251 if (!(flags & PM_NOYIELD))
1253 UserYield16();
1254 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1255 QUEUE_ReceiveMessage( msgQueue );
1257 if ((msgQueue->wakeBits & mask) & QS_TIMER)
1259 if (TIMER_GetTimerMsg(msg, hwnd, hQueue, flags & PM_REMOVE)) break;
1262 if (peek)
1264 if (!(flags & PM_NOYIELD)) UserYield16();
1266 QUEUE_Unlock( msgQueue );
1267 WIN_RestoreWndsLock(iWndsLocks);
1268 return FALSE;
1270 msgQueue->wakeMask = mask;
1271 QUEUE_WaitBits( mask, INFINITE );
1272 QUEUE_Unlock( msgQueue );
1275 WIN_RestoreWndsLock(iWndsLocks);
1277 /* instead of unlocking queue for every break condition, all break
1278 condition will fall here */
1279 QUEUE_Unlock( msgQueue );
1281 /* We got a message */
1282 if (flags & PM_REMOVE)
1284 WORD message = msg->message;
1286 if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
1288 BYTE *p = &QueueKeyStateTable[msg->wParam & 0xff];
1290 if (!(*p & 0x80))
1291 *p ^= 0x01;
1292 *p |= 0x80;
1294 else if (message == WM_KEYUP || message == WM_SYSKEYUP)
1295 QueueKeyStateTable[msg->wParam & 0xff] &= ~0x80;
1298 if (peek)
1299 return TRUE;
1301 else
1302 return (msg->message != WM_QUIT);
1305 /***********************************************************************
1306 * MSG_InternalGetMessage
1308 * GetMessage() function for internal use. Behave like GetMessage(),
1309 * but also call message filters and optionally send WM_ENTERIDLE messages.
1310 * 'hwnd' must be the handle of the dialog or menu window.
1311 * 'code' is the message filter value (MSGF_??? codes).
1313 BOOL MSG_InternalGetMessage( int type, MSG *msg, HWND hwnd, HWND hwndOwner,
1314 WPARAM code, WORD flags, BOOL sendIdle, BOOL* idleSent )
1316 for (;;)
1318 if (sendIdle)
1320 if (!MSG_PeekMessage( type, msg, 0, 0, 0, flags, TRUE ))
1322 /* No message present -> send ENTERIDLE and wait */
1323 if (IsWindow(hwndOwner))
1325 SendMessageA( hwndOwner, WM_ENTERIDLE,
1326 code, (LPARAM)hwnd );
1328 if (idleSent!=NULL)
1329 *idleSent=TRUE;
1331 MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE );
1334 else /* Always wait for a message */
1335 MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE );
1337 /* Call message filters */
1339 if (HOOK_IsHooked( WH_SYSMSGFILTER ) || HOOK_IsHooked( WH_MSGFILTER ))
1341 MSG *pmsg = HeapAlloc( SystemHeap, 0, sizeof(MSG) );
1342 if (pmsg)
1344 BOOL ret;
1345 *pmsg = *msg;
1346 ret = (HOOK_CallHooksA( WH_SYSMSGFILTER, code, 0,
1347 (LPARAM) pmsg ) ||
1348 HOOK_CallHooksA( WH_MSGFILTER, code, 0,
1349 (LPARAM) pmsg ));
1351 HeapFree( SystemHeap, 0, pmsg );
1352 if (ret)
1354 /* Message filtered -> remove it from the queue */
1355 /* if it's still there. */
1356 if (!(flags & PM_REMOVE))
1357 MSG_PeekMessage( type, msg, 0, 0, 0, PM_REMOVE, TRUE );
1358 continue;
1363 return (msg->message != WM_QUIT);
1368 /***********************************************************************
1369 * PeekMessage32_16 (USER.819)
1371 BOOL16 WINAPI PeekMessage32_16( LPMSG16_32 lpmsg16_32, HWND16 hwnd,
1372 UINT16 first, UINT16 last, UINT16 flags,
1373 BOOL16 wHaveParamHigh )
1375 BOOL ret;
1376 MSG msg;
1378 ret = MSG_PeekMessage( QMSG_WIN16, &msg, hwnd, first, last, flags, TRUE );
1380 lpmsg16_32->msg.hwnd = msg.hwnd;
1381 lpmsg16_32->msg.message = msg.message;
1382 lpmsg16_32->msg.wParam = LOWORD(msg.wParam);
1383 lpmsg16_32->msg.lParam = msg.lParam;
1384 lpmsg16_32->msg.time = msg.time;
1385 lpmsg16_32->msg.pt.x = (INT16)msg.pt.x;
1386 lpmsg16_32->msg.pt.y = (INT16)msg.pt.y;
1388 if ( wHaveParamHigh )
1389 lpmsg16_32->wParamHigh = HIWORD(msg.wParam);
1391 return ret;
1394 /***********************************************************************
1395 * PeekMessage16 (USER.109)
1397 BOOL16 WINAPI PeekMessage16( LPMSG16 lpmsg, HWND16 hwnd,
1398 UINT16 first, UINT16 last, UINT16 flags )
1400 return PeekMessage32_16( (LPMSG16_32)lpmsg, hwnd, first, last, flags, FALSE );
1403 /***********************************************************************
1404 * PeekMessageA
1406 BOOL WINAPI PeekMessageA( LPMSG lpmsg, HWND hwnd,
1407 UINT min, UINT max, UINT wRemoveMsg)
1409 return MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
1412 /***********************************************************************
1413 * PeekMessageW Check queue for messages
1415 * Checks for a message in the thread's queue, filtered as for
1416 * GetMessage(). Returns immediately whether a message is available
1417 * or not.
1419 * Whether a retrieved message is removed from the queue is set by the
1420 * _wRemoveMsg_ flags, which should be one of the following values:
1422 * PM_NOREMOVE Do not remove the message from the queue.
1424 * PM_REMOVE Remove the message from the queue.
1426 * In addition, PM_NOYIELD may be combined into _wRemoveMsg_ to
1427 * request that the system not yield control during PeekMessage();
1428 * however applications may not rely on scheduling behavior.
1430 * RETURNS
1432 * Nonzero if a message is available and is retrieved, zero otherwise.
1434 * CONFORMANCE
1436 * ECMA-234, Win32
1439 BOOL WINAPI PeekMessageW(
1440 LPMSG lpmsg, /* buffer to receive message */
1441 HWND hwnd, /* restrict to messages for hwnd */
1442 UINT min, /* minimum message to receive */
1443 UINT max, /* maximum message to receive */
1444 UINT wRemoveMsg /* removal flags */
1447 return MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
1451 /***********************************************************************
1452 * GetMessage32_16 (USER.820)
1454 BOOL16 WINAPI GetMessage32_16( SEGPTR msg16_32, HWND16 hWnd, UINT16 first,
1455 UINT16 last, BOOL16 wHaveParamHigh )
1457 MSG32_16 *lpmsg16_32 = (MSG32_16 *)PTR_SEG_TO_LIN(msg16_32);
1458 MSG msg;
1460 MSG_PeekMessage( QMSG_WIN16, &msg, hWnd, first, last, PM_REMOVE, FALSE );
1462 lpmsg16_32->msg.hwnd = msg.hwnd;
1463 lpmsg16_32->msg.message = msg.message;
1464 lpmsg16_32->msg.wParam = LOWORD(msg.wParam);
1465 lpmsg16_32->msg.lParam = msg.lParam;
1466 lpmsg16_32->msg.time = msg.time;
1467 lpmsg16_32->msg.pt.x = (INT16)msg.pt.x;
1468 lpmsg16_32->msg.pt.y = (INT16)msg.pt.y;
1470 if ( wHaveParamHigh )
1471 lpmsg16_32->wParamHigh = HIWORD(msg.wParam);
1473 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1474 lpmsg16_32->msg.message, hWnd, first, last );
1476 HOOK_CallHooks16( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)msg16_32 );
1477 return lpmsg16_32->msg.message != WM_QUIT;
1480 /***********************************************************************
1481 * GetMessage16 (USER.108)
1483 BOOL16 WINAPI GetMessage16( SEGPTR msg, HWND16 hwnd, UINT16 first, UINT16 last)
1485 return GetMessage32_16( msg, hwnd, first, last, FALSE );
1488 /***********************************************************************
1489 * GetMessageA (USER32.270)
1491 BOOL WINAPI GetMessageA( MSG *lpmsg, HWND hwnd, UINT min, UINT max )
1493 MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
1495 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1496 lpmsg->message, hwnd, min, max );
1498 HOOK_CallHooksA( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
1499 return lpmsg->message != WM_QUIT;
1502 /***********************************************************************
1503 * GetMessageW (USER32.274) Retrieve next message
1505 * GetMessage retrieves the next event from the calling thread's
1506 * queue and deposits it in *lpmsg.
1508 * If _hwnd_ is not NULL, only messages for window _hwnd_ and its
1509 * children as specified by IsChild() are retrieved. If _hwnd_ is NULL
1510 * all application messages are retrieved.
1512 * _min_ and _max_ specify the range of messages of interest. If
1513 * min==max==0, no filtering is performed. Useful examples are
1514 * WM_KEYFIRST and WM_KEYLAST to retrieve keyboard input, and
1515 * WM_MOUSEFIRST and WM_MOUSELAST to retrieve mouse input.
1517 * WM_PAINT messages are not removed from the queue; they remain until
1518 * processed. Other messages are removed from the queue.
1520 * RETURNS
1522 * -1 on error, 0 if message is WM_QUIT, nonzero otherwise.
1524 * CONFORMANCE
1526 * ECMA-234, Win32
1529 BOOL WINAPI GetMessageW(
1530 MSG* lpmsg, /* buffer to receive message */
1531 HWND hwnd, /* restrict to messages for hwnd */
1532 UINT min, /* minimum message to receive */
1533 UINT max /* maximum message to receive */
1536 MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
1538 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1539 lpmsg->message, hwnd, min, max );
1541 HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
1542 return lpmsg->message != WM_QUIT;
1545 /***********************************************************************
1546 * MSG_PostToQueue
1548 static BOOL MSG_PostToQueue( HQUEUE16 hQueue, int type, HWND hwnd,
1549 UINT message, WPARAM wParam, LPARAM lParam )
1551 MSG msg;
1553 if ( !hQueue ) return FALSE;
1555 msg.hwnd = hwnd;
1556 msg.message = message;
1557 msg.wParam = wParam;
1558 msg.lParam = lParam;
1559 msg.time = GetTickCount();
1560 GetCursorPos(&msg.pt);
1562 return QUEUE_AddMsg( hQueue, type, &msg, 0 );
1565 /***********************************************************************
1566 * MSG_PostMessage
1568 static BOOL MSG_PostMessage( int type, HWND hwnd, UINT message,
1569 WPARAM wParam, LPARAM lParam )
1571 HQUEUE16 hQueue;
1572 WND *wndPtr;
1574 if (hwnd == HWND_BROADCAST)
1576 WND *pDesktop = WIN_GetDesktop();
1577 TRACE("HWND_BROADCAST !\n");
1579 for (wndPtr=WIN_LockWndPtr(pDesktop->child); wndPtr; WIN_UpdateWndPtr(&wndPtr,wndPtr->next))
1581 if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
1583 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n",
1584 wndPtr->hwndSelf, message, wParam, lParam);
1585 MSG_PostToQueue( wndPtr->hmemTaskQ, type,
1586 wndPtr->hwndSelf, message, wParam, lParam );
1589 WIN_ReleaseDesktop();
1590 TRACE("End of HWND_BROADCAST !\n");
1591 return TRUE;
1594 wndPtr = WIN_FindWndPtr( hwnd );
1595 hQueue = wndPtr? wndPtr->hmemTaskQ : 0;
1596 WIN_ReleaseWndPtr(wndPtr);
1598 return MSG_PostToQueue( hQueue, type, hwnd, message, wParam, lParam );
1601 /***********************************************************************
1602 * PostMessage16 (USER.110)
1604 BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam,
1605 LPARAM lParam )
1607 return (BOOL16) MSG_PostMessage( QMSG_WIN16, hwnd, message, wParam, lParam );
1610 /***********************************************************************
1611 * PostMessageA (USER32.419)
1613 BOOL WINAPI PostMessageA( HWND hwnd, UINT message, WPARAM wParam,
1614 LPARAM lParam )
1616 return MSG_PostMessage( QMSG_WIN32A, hwnd, message, wParam, lParam );
1619 /***********************************************************************
1620 * PostMessageW (USER32.420)
1622 BOOL WINAPI PostMessageW( HWND hwnd, UINT message, WPARAM wParam,
1623 LPARAM lParam )
1625 return MSG_PostMessage( QMSG_WIN32W, hwnd, message, wParam, lParam );
1628 /***********************************************************************
1629 * PostAppMessage16 (USER.116)
1631 BOOL16 WINAPI PostAppMessage16( HTASK16 hTask, UINT16 message,
1632 WPARAM16 wParam, LPARAM lParam )
1634 return MSG_PostToQueue( GetTaskQueue16(hTask), QMSG_WIN16,
1635 0, message, wParam, lParam );
1638 /**********************************************************************
1639 * PostThreadMessageA (USER32.422)
1641 BOOL WINAPI PostThreadMessageA( DWORD idThread, UINT message,
1642 WPARAM wParam, LPARAM lParam )
1644 return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32A,
1645 0, message, wParam, lParam );
1648 /**********************************************************************
1649 * PostThreadMessageW (USER32.423)
1651 BOOL WINAPI PostThreadMessageW( DWORD idThread, UINT message,
1652 WPARAM wParam, LPARAM lParam )
1654 return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32W,
1655 0, message, wParam, lParam );
1659 /************************************************************************
1660 * MSG_CallWndProcHook32
1662 static void MSG_CallWndProcHook( LPMSG pmsg, BOOL bUnicode )
1664 CWPSTRUCT cwp;
1666 cwp.lParam = pmsg->lParam;
1667 cwp.wParam = pmsg->wParam;
1668 cwp.message = pmsg->message;
1669 cwp.hwnd = pmsg->hwnd;
1671 if (bUnicode) HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1672 else HOOK_CallHooksA( WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp );
1674 pmsg->lParam = cwp.lParam;
1675 pmsg->wParam = cwp.wParam;
1676 pmsg->message = cwp.message;
1677 pmsg->hwnd = cwp.hwnd;
1681 /***********************************************************************
1682 * MSG_SendMessage
1684 * return values: 0 if timeout occurs
1685 * 1 otherwise
1687 static LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam,
1688 LPARAM lParam, DWORD timeout, WORD flags,
1689 LRESULT *pRes)
1691 WND * wndPtr = 0;
1692 WND **list, **ppWnd;
1693 LRESULT ret = 1;
1695 *pRes = 0;
1697 if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
1699 *pRes = 1;
1701 if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1703 WIN_ReleaseDesktop();
1704 return 1;
1706 WIN_ReleaseDesktop();
1708 TRACE("HWND_BROADCAST !\n");
1709 for (ppWnd = list; *ppWnd; ppWnd++)
1711 WIN_UpdateWndPtr(&wndPtr,*ppWnd);
1712 if (!IsWindow(wndPtr->hwndSelf)) continue;
1713 if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
1715 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n",
1716 wndPtr->hwndSelf, msg, (DWORD)wParam, lParam);
1717 MSG_SendMessage( wndPtr->hwndSelf, msg, wParam, lParam,
1718 timeout, flags, pRes);
1721 WIN_ReleaseWndPtr(wndPtr);
1722 WIN_ReleaseWinArray(list);
1723 TRACE("End of HWND_BROADCAST !\n");
1724 return 1;
1727 if (HOOK_IsHooked( WH_CALLWNDPROC ))
1729 if (flags & SMSG_UNICODE)
1730 MSG_CallWndProcHook( (LPMSG)&hwnd, TRUE);
1731 else if (flags & SMSG_WIN32)
1732 MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE);
1733 else
1735 LPCWPSTRUCT16 pmsg;
1737 if ((pmsg = SEGPTR_NEW(CWPSTRUCT16)))
1739 pmsg->hwnd = hwnd & 0xffff;
1740 pmsg->message= msg & 0xffff;
1741 pmsg->wParam = wParam & 0xffff;
1742 pmsg->lParam = lParam;
1743 HOOK_CallHooks16( WH_CALLWNDPROC, HC_ACTION, 1,
1744 (LPARAM)SEGPTR_GET(pmsg) );
1745 hwnd = pmsg->hwnd;
1746 msg = pmsg->message;
1747 wParam = pmsg->wParam;
1748 lParam = pmsg->lParam;
1749 SEGPTR_FREE( pmsg );
1754 if (!(wndPtr = WIN_FindWndPtr( hwnd )))
1756 WARN("invalid hwnd %04x\n", hwnd );
1757 return 0;
1759 if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
1761 ret = 0; /* Don't send anything if the task is dying */
1762 goto END;
1764 if (flags & SMSG_WIN32)
1765 SPY_EnterMessage( SPY_SENDMESSAGE, hwnd, msg, wParam, lParam );
1766 else
1767 SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wParam, lParam );
1769 if (wndPtr->hmemTaskQ != GetFastQueue16())
1770 ret = MSG_SendMessageInterThread( wndPtr->hmemTaskQ, hwnd, msg,
1771 wParam, lParam, timeout, flags, pRes );
1772 else
1774 /* Call the right CallWindowProc flavor */
1775 if (flags & SMSG_UNICODE)
1776 *pRes = CallWindowProcW( (WNDPROC)wndPtr->winproc,
1777 hwnd, msg, wParam, lParam );
1778 else if (flags & SMSG_WIN32)
1779 *pRes = CallWindowProcA( (WNDPROC)wndPtr->winproc,
1780 hwnd, msg, wParam, lParam );
1781 else
1782 *pRes = CallWindowProc16( (WNDPROC16)wndPtr->winproc,
1783 (HWND16) hwnd, (UINT16) msg,
1784 (WPARAM16) wParam, lParam );
1787 if (flags & SMSG_WIN32)
1788 SPY_ExitMessage( SPY_RESULT_OK, hwnd, msg, *pRes );
1789 else
1790 SPY_ExitMessage( SPY_RESULT_OK16, hwnd, msg, *pRes );
1791 END:
1792 WIN_ReleaseWndPtr(wndPtr);
1793 return ret;
1797 /***********************************************************************
1798 * SendMessage16 (USER.111)
1800 LRESULT WINAPI SendMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
1801 LPARAM lParam)
1803 LRESULT res;
1804 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, 0, &res);
1805 return res;
1809 /***********************************************************************
1810 * SendMessageA (USER32.454)
1812 LRESULT WINAPI SendMessageA( HWND hwnd, UINT msg, WPARAM wParam,
1813 LPARAM lParam )
1815 LRESULT res;
1817 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE,
1818 SMSG_WIN32, &res);
1820 return res;
1824 /***********************************************************************
1825 * SendMessageW (USER32.459) Send Window Message
1827 * Sends a message to the window procedure of the specified window.
1828 * SendMessage() will not return until the called window procedure
1829 * either returns or calls ReplyMessage().
1831 * Use PostMessage() to send message and return immediately. A window
1832 * procedure may use InSendMessage() to detect
1833 * SendMessage()-originated messages.
1835 * Applications which communicate via HWND_BROADCAST may use
1836 * RegisterWindowMessage() to obtain a unique message to avoid conflicts
1837 * with other applications.
1839 * CONFORMANCE
1841 * ECMA-234, Win32
1843 LRESULT WINAPI SendMessageW(
1844 HWND hwnd, /* Window to send message to. If HWND_BROADCAST,
1845 the message will be sent to all top-level windows. */
1847 UINT msg, /* message */
1848 WPARAM wParam, /* message parameter */
1849 LPARAM lParam /* additional message parameter */
1851 LRESULT res;
1853 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE,
1854 SMSG_WIN32 | SMSG_UNICODE, &res);
1856 return res;
1860 /***********************************************************************
1861 * SendMessageTimeout16 (not a WINAPI)
1863 LRESULT WINAPI SendMessageTimeout16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
1864 LPARAM lParam, UINT16 flags,
1865 UINT16 timeout, LPWORD resultp)
1867 LRESULT ret;
1868 LRESULT msgRet;
1870 /* FIXME: need support for SMTO_BLOCK */
1872 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, 0, &msgRet);
1873 if (resultp) *resultp = (WORD) msgRet;
1874 return ret;
1878 /***********************************************************************
1879 * SendMessageTimeoutA (USER32.457)
1881 LRESULT WINAPI SendMessageTimeoutA( HWND hwnd, UINT msg, WPARAM wParam,
1882 LPARAM lParam, UINT flags,
1883 UINT timeout, LPDWORD resultp)
1885 LRESULT ret;
1886 LRESULT msgRet;
1888 /* FIXME: need support for SMTO_BLOCK */
1890 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, SMSG_WIN32,
1891 &msgRet);
1893 if (resultp) *resultp = (DWORD) msgRet;
1894 return ret;
1898 /***********************************************************************
1899 * SendMessageTimeoutW (USER32.458)
1901 LRESULT WINAPI SendMessageTimeoutW( HWND hwnd, UINT msg, WPARAM wParam,
1902 LPARAM lParam, UINT flags,
1903 UINT timeout, LPDWORD resultp)
1905 LRESULT ret;
1906 LRESULT msgRet;
1908 /* FIXME: need support for SMTO_BLOCK */
1910 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout,
1911 SMSG_WIN32 | SMSG_UNICODE, &msgRet);
1913 if (resultp) *resultp = (DWORD) msgRet;
1914 return ret;
1918 /***********************************************************************
1919 * WaitMessage (USER.112) (USER32.578) Suspend thread pending messages
1921 * WaitMessage() suspends a thread until events appear in the thread's
1922 * queue.
1924 * BUGS
1926 * Is supposed to return BOOL under Win32.
1928 * Thread-local message queues are not supported.
1930 * CONFORMANCE
1932 * ECMA-234, Win32
1935 void WINAPI WaitMessage( void )
1937 QUEUE_WaitBits( QS_ALLINPUT, INFINITE );
1940 /***********************************************************************
1941 * MsgWaitForMultipleObjects (USER32.400)
1943 DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE *pHandles,
1944 BOOL fWaitAll, DWORD dwMilliseconds,
1945 DWORD dwWakeMask )
1947 DWORD i;
1948 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
1949 DWORD ret;
1951 HQUEUE16 hQueue = GetFastQueue16();
1952 MESSAGEQUEUE *msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
1953 if (!msgQueue) return WAIT_FAILED;
1955 if (nCount > MAXIMUM_WAIT_OBJECTS-1)
1957 SetLastError( ERROR_INVALID_PARAMETER );
1958 QUEUE_Unlock( msgQueue );
1959 return WAIT_FAILED;
1962 msgQueue->changeBits = 0;
1963 msgQueue->wakeMask = dwWakeMask;
1965 if (THREAD_IsWin16(NtCurrentTeb()))
1968 * This is a temporary solution to a big problem.
1969 * You see, the main thread of all Win32 programs is created as a 16 bit
1970 * task. This means that if you wait on an event using Win32 synchronization
1971 * methods, the 16 bit scheduler is stopped and things might just stop happening.
1972 * This implements a semi-busy loop that checks the handles to wait on and
1973 * also the message queue. When either one is ready, the wait function returns.
1975 * This will all go away when the real Win32 threads are implemented for all
1976 * the threads of an applications. Including the main thread.
1978 DWORD curTime = GetCurrentTime();
1983 * Check the handles in the list.
1985 ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, 5L);
1988 * If the handles have been triggered, return.
1990 if (ret != WAIT_TIMEOUT)
1991 break;
1994 * Then, let the 16 bit scheduler do it's thing.
1996 Yield16();
1999 * If a message matching the wait mask has arrived, return.
2001 if (msgQueue->changeBits & dwWakeMask)
2003 ret = nCount;
2004 break;
2008 * And continue doing this until we hit the timeout.
2010 } while ((dwMilliseconds == INFINITE) || (GetCurrentTime()-curTime < dwMilliseconds) );
2012 else
2014 /* Add the thread event to the handle list */
2015 for (i = 0; i < nCount; i++)
2016 handles[i] = pHandles[i];
2017 handles[nCount] = msgQueue->server_queue;
2018 ret = WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds );
2020 QUEUE_Unlock( msgQueue );
2021 return ret;
2026 struct accent_char
2028 BYTE ac_accent;
2029 BYTE ac_char;
2030 BYTE ac_result;
2033 static const struct accent_char accent_chars[] =
2035 /* A good idea should be to read /usr/X11/lib/X11/locale/iso8859-x/Compose */
2036 {'`', 'A', '\300'}, {'`', 'a', '\340'},
2037 {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
2038 {'^', 'A', '\302'}, {'^', 'a', '\342'},
2039 {'~', 'A', '\303'}, {'~', 'a', '\343'},
2040 {'"', 'A', '\304'}, {'"', 'a', '\344'},
2041 {'O', 'A', '\305'}, {'o', 'a', '\345'},
2042 {'0', 'A', '\305'}, {'0', 'a', '\345'},
2043 {'A', 'A', '\305'}, {'a', 'a', '\345'},
2044 {'A', 'E', '\306'}, {'a', 'e', '\346'},
2045 {',', 'C', '\307'}, {',', 'c', '\347'},
2046 {'`', 'E', '\310'}, {'`', 'e', '\350'},
2047 {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
2048 {'^', 'E', '\312'}, {'^', 'e', '\352'},
2049 {'"', 'E', '\313'}, {'"', 'e', '\353'},
2050 {'`', 'I', '\314'}, {'`', 'i', '\354'},
2051 {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
2052 {'^', 'I', '\316'}, {'^', 'i', '\356'},
2053 {'"', 'I', '\317'}, {'"', 'i', '\357'},
2054 {'-', 'D', '\320'}, {'-', 'd', '\360'},
2055 {'~', 'N', '\321'}, {'~', 'n', '\361'},
2056 {'`', 'O', '\322'}, {'`', 'o', '\362'},
2057 {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
2058 {'^', 'O', '\324'}, {'^', 'o', '\364'},
2059 {'~', 'O', '\325'}, {'~', 'o', '\365'},
2060 {'"', 'O', '\326'}, {'"', 'o', '\366'},
2061 {'/', 'O', '\330'}, {'/', 'o', '\370'},
2062 {'`', 'U', '\331'}, {'`', 'u', '\371'},
2063 {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
2064 {'^', 'U', '\333'}, {'^', 'u', '\373'},
2065 {'"', 'U', '\334'}, {'"', 'u', '\374'},
2066 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
2067 {'T', 'H', '\336'}, {'t', 'h', '\376'},
2068 {'s', 's', '\337'}, {'"', 'y', '\377'},
2069 {'s', 'z', '\337'}, {'i', 'j', '\377'},
2070 /* iso-8859-2 uses this */
2071 {'<', 'L', '\245'}, {'<', 'l', '\265'}, /* caron */
2072 {'<', 'S', '\251'}, {'<', 's', '\271'},
2073 {'<', 'T', '\253'}, {'<', 't', '\273'},
2074 {'<', 'Z', '\256'}, {'<', 'z', '\276'},
2075 {'<', 'C', '\310'}, {'<', 'c', '\350'},
2076 {'<', 'E', '\314'}, {'<', 'e', '\354'},
2077 {'<', 'D', '\317'}, {'<', 'd', '\357'},
2078 {'<', 'N', '\322'}, {'<', 'n', '\362'},
2079 {'<', 'R', '\330'}, {'<', 'r', '\370'},
2080 {';', 'A', '\241'}, {';', 'a', '\261'}, /* ogonek */
2081 {';', 'E', '\312'}, {';', 'e', '\332'},
2082 {'\'', 'Z', '\254'}, {'\'', 'z', '\274'}, /* acute */
2083 {'\'', 'R', '\300'}, {'\'', 'r', '\340'},
2084 {'\'', 'L', '\305'}, {'\'', 'l', '\345'},
2085 {'\'', 'C', '\306'}, {'\'', 'c', '\346'},
2086 {'\'', 'N', '\321'}, {'\'', 'n', '\361'},
2087 /* collision whith S, from iso-8859-9 !!! */
2088 {',', 'S', '\252'}, {',', 's', '\272'}, /* cedilla */
2089 {',', 'T', '\336'}, {',', 't', '\376'},
2090 {'.', 'Z', '\257'}, {'.', 'z', '\277'}, /* dot above */
2091 {'/', 'L', '\243'}, {'/', 'l', '\263'}, /* slash */
2092 {'/', 'D', '\320'}, {'/', 'd', '\360'},
2093 {'(', 'A', '\303'}, {'(', 'a', '\343'}, /* breve */
2094 {'\275', 'O', '\325'}, {'\275', 'o', '\365'}, /* double acute */
2095 {'\275', 'U', '\334'}, {'\275', 'u', '\374'},
2096 {'0', 'U', '\332'}, {'0', 'u', '\372'}, /* ring above */
2097 /* iso-8859-3 uses this */
2098 {'/', 'H', '\241'}, {'/', 'h', '\261'}, /* slash */
2099 {'>', 'H', '\246'}, {'>', 'h', '\266'}, /* circumflex */
2100 {'>', 'J', '\254'}, {'>', 'j', '\274'},
2101 {'>', 'C', '\306'}, {'>', 'c', '\346'},
2102 {'>', 'G', '\330'}, {'>', 'g', '\370'},
2103 {'>', 'S', '\336'}, {'>', 's', '\376'},
2104 /* collision whith G( from iso-8859-9 !!! */
2105 {'(', 'G', '\253'}, {'(', 'g', '\273'}, /* breve */
2106 {'(', 'U', '\335'}, {'(', 'u', '\375'},
2107 /* collision whith I. from iso-8859-3 !!! */
2108 {'.', 'I', '\251'}, {'.', 'i', '\271'}, /* dot above */
2109 {'.', 'C', '\305'}, {'.', 'c', '\345'},
2110 {'.', 'G', '\325'}, {'.', 'g', '\365'},
2111 /* iso-8859-4 uses this */
2112 {',', 'R', '\243'}, {',', 'r', '\263'}, /* cedilla */
2113 {',', 'L', '\246'}, {',', 'l', '\266'},
2114 {',', 'G', '\253'}, {',', 'g', '\273'},
2115 {',', 'N', '\321'}, {',', 'n', '\361'},
2116 {',', 'K', '\323'}, {',', 'k', '\363'},
2117 {'~', 'I', '\245'}, {'~', 'i', '\265'}, /* tilde */
2118 {'-', 'E', '\252'}, {'-', 'e', '\272'}, /* macron */
2119 {'-', 'A', '\300'}, {'-', 'a', '\340'},
2120 {'-', 'I', '\317'}, {'-', 'i', '\357'},
2121 {'-', 'O', '\322'}, {'-', 'o', '\362'},
2122 {'-', 'U', '\336'}, {'-', 'u', '\376'},
2123 {'/', 'T', '\254'}, {'/', 't', '\274'}, /* slash */
2124 {'.', 'E', '\314'}, {'.', 'e', '\344'}, /* dot above */
2125 {';', 'I', '\307'}, {';', 'i', '\347'}, /* ogonek */
2126 {';', 'U', '\331'}, {';', 'u', '\371'},
2127 /* iso-8859-9 uses this */
2128 /* iso-8859-9 has really bad choosen G( S, and I. as they collide
2129 * whith the same letters on other iso-8859-x (that is they are on
2130 * different places :-( ), if you use turkish uncomment these and
2131 * comment out the lines in iso-8859-2 and iso-8859-3 sections
2132 * FIXME: should be dynamic according to chosen language
2133 * if/when Wine has turkish support.
2135 /* collision whith G( from iso-8859-3 !!! */
2136 /* {'(', 'G', '\320'}, {'(', 'g', '\360'}, */ /* breve */
2137 /* collision whith S, from iso-8859-2 !!! */
2138 /* {',', 'S', '\336'}, {',', 's', '\376'}, */ /* cedilla */
2139 /* collision whith I. from iso-8859-3 !!! */
2140 /* {'.', 'I', '\335'}, {'.', 'i', '\375'}, */ /* dot above */
2144 /***********************************************************************
2145 * MSG_DoTranslateMessage
2147 * Implementation of TranslateMessage.
2149 * TranslateMessage translates virtual-key messages into character-messages,
2150 * as follows :
2151 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
2152 * ditto replacing WM_* with WM_SYS*
2153 * This produces WM_CHAR messages only for keys mapped to ASCII characters
2154 * by the keyboard driver.
2156 static BOOL MSG_DoTranslateMessage( UINT message, HWND hwnd,
2157 WPARAM wParam, LPARAM lParam )
2159 static int dead_char;
2160 BYTE wp[2];
2162 if (message != WM_MOUSEMOVE && message != WM_TIMER)
2163 TRACE("(%s, %04X, %08lX)\n",
2164 SPY_GetMsgName(message), wParam, lParam );
2165 if(message >= WM_KEYFIRST && message <= WM_KEYLAST)
2166 TRACE_(key)("(%s, %04X, %08lX)\n",
2167 SPY_GetMsgName(message), wParam, lParam );
2169 if ((message != WM_KEYDOWN) && (message != WM_SYSKEYDOWN)) return FALSE;
2171 TRACE_(key)("Translating key %04X, scancode %04X\n",
2172 wParam, HIWORD(lParam) );
2174 /* FIXME : should handle ToAscii yielding 2 */
2175 switch (ToAscii(wParam, HIWORD(lParam),
2176 QueueKeyStateTable,(LPWORD)wp, 0))
2178 case 1 :
2179 message = (message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
2180 /* Should dead chars handling go in ToAscii ? */
2181 if (dead_char)
2183 int i;
2185 if (wp[0] == ' ') wp[0] = dead_char;
2186 if (dead_char == 0xa2) dead_char = '(';
2187 else if (dead_char == 0xa8) dead_char = '"';
2188 else if (dead_char == 0xb2) dead_char = ';';
2189 else if (dead_char == 0xb4) dead_char = '\'';
2190 else if (dead_char == 0xb7) dead_char = '<';
2191 else if (dead_char == 0xb8) dead_char = ',';
2192 else if (dead_char == 0xff) dead_char = '.';
2193 for (i = 0; i < sizeof(accent_chars)/sizeof(accent_chars[0]); i++)
2194 if ((accent_chars[i].ac_accent == dead_char) &&
2195 (accent_chars[i].ac_char == wp[0]))
2197 wp[0] = accent_chars[i].ac_result;
2198 break;
2200 dead_char = 0;
2202 TRACE_(key)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message));
2203 PostMessage16( hwnd, message, wp[0], lParam );
2204 return TRUE;
2206 case -1 :
2207 message = (message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
2208 dead_char = wp[0];
2209 TRACE_(key)("-1 -> PostMessage(%s)\n",
2210 SPY_GetMsgName(message));
2211 PostMessage16( hwnd, message, wp[0], lParam );
2212 return TRUE;
2214 return FALSE;
2218 /***********************************************************************
2219 * TranslateMessage16 (USER.113)
2221 BOOL16 WINAPI TranslateMessage16( const MSG16 *msg )
2223 return MSG_DoTranslateMessage( msg->message, msg->hwnd,
2224 msg->wParam, msg->lParam );
2228 /***********************************************************************
2229 * TranslateMessage32 (USER.821)
2231 BOOL16 WINAPI TranslateMessage32_16( const MSG32_16 *msg, BOOL16 wHaveParamHigh )
2233 WPARAM wParam;
2235 if (wHaveParamHigh)
2236 wParam = MAKELONG(msg->msg.wParam, msg->wParamHigh);
2237 else
2238 wParam = (WPARAM)msg->msg.wParam;
2240 return MSG_DoTranslateMessage( msg->msg.message, msg->msg.hwnd,
2241 wParam, msg->msg.lParam );
2244 /***********************************************************************
2245 * TranslateMessage (USER32.556)
2247 BOOL WINAPI TranslateMessage( const MSG *msg )
2249 return MSG_DoTranslateMessage( msg->message, msg->hwnd,
2250 msg->wParam, msg->lParam );
2254 /***********************************************************************
2255 * DispatchMessage16 (USER.114)
2257 LONG WINAPI DispatchMessage16( const MSG16* msg )
2259 WND * wndPtr;
2260 LONG retval;
2261 int painting;
2263 /* Process timer messages */
2264 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2266 if (msg->lParam)
2268 return CallWindowProc16( (WNDPROC16)msg->lParam, msg->hwnd,
2269 msg->message, msg->wParam, GetTickCount() );
2273 if (!msg->hwnd) return 0;
2274 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2275 if (!wndPtr->winproc)
2277 retval = 0;
2278 goto END;
2280 painting = (msg->message == WM_PAINT);
2281 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2283 SPY_EnterMessage( SPY_DISPATCHMESSAGE16, msg->hwnd, msg->message,
2284 msg->wParam, msg->lParam );
2285 retval = CallWindowProc16( (WNDPROC16)wndPtr->winproc,
2286 msg->hwnd, msg->message,
2287 msg->wParam, msg->lParam );
2288 SPY_ExitMessage( SPY_RESULT_OK16, msg->hwnd, msg->message, retval );
2290 WIN_ReleaseWndPtr(wndPtr);
2291 wndPtr = WIN_FindWndPtr(msg->hwnd);
2292 if (painting && wndPtr &&
2293 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2295 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2296 msg->hwnd);
2297 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2298 /* Validate the update region to avoid infinite WM_PAINT loop */
2299 ValidateRect( msg->hwnd, NULL );
2301 END:
2302 WIN_ReleaseWndPtr(wndPtr);
2303 return retval;
2307 /***********************************************************************
2308 * DispatchMessage32 (USER.822)
2310 LONG WINAPI DispatchMessage32_16( const MSG32_16* lpmsg16_32, BOOL16 wHaveParamHigh )
2312 if (wHaveParamHigh == FALSE)
2313 return DispatchMessage16(&(lpmsg16_32->msg));
2314 else
2316 MSG msg;
2318 msg.hwnd = lpmsg16_32->msg.hwnd;
2319 msg.message = lpmsg16_32->msg.message;
2320 msg.wParam = MAKELONG(lpmsg16_32->msg.wParam, lpmsg16_32->wParamHigh);
2321 msg.lParam = lpmsg16_32->msg.lParam;
2322 msg.time = lpmsg16_32->msg.time;
2323 msg.pt.x = (INT)lpmsg16_32->msg.pt.x;
2324 msg.pt.y = (INT)lpmsg16_32->msg.pt.y;
2325 return DispatchMessageA(&msg);
2329 /***********************************************************************
2330 * DispatchMessageA (USER32.141)
2332 LONG WINAPI DispatchMessageA( const MSG* msg )
2334 WND * wndPtr;
2335 LONG retval;
2336 int painting;
2338 /* Process timer messages */
2339 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2341 if (msg->lParam)
2343 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2344 return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
2345 msg->message, msg->wParam, GetTickCount() );
2349 if (!msg->hwnd) return 0;
2350 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2351 if (!wndPtr->winproc)
2353 retval = 0;
2354 goto END;
2356 painting = (msg->message == WM_PAINT);
2357 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2358 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2360 SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
2361 msg->wParam, msg->lParam );
2362 retval = CallWindowProcA( (WNDPROC)wndPtr->winproc,
2363 msg->hwnd, msg->message,
2364 msg->wParam, msg->lParam );
2365 SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval );
2367 WIN_ReleaseWndPtr(wndPtr);
2368 wndPtr = WIN_FindWndPtr(msg->hwnd);
2370 if (painting && wndPtr &&
2371 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2373 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2374 msg->hwnd);
2375 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2376 /* Validate the update region to avoid infinite WM_PAINT loop */
2377 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0,
2378 RDW_FRAME | RDW_VALIDATE | RDW_NOCHILDREN | RDW_NOINTERNALPAINT, 0 );
2380 END:
2381 WIN_ReleaseWndPtr(wndPtr);
2382 return retval;
2386 /***********************************************************************
2387 * DispatchMessageW (USER32.142) Process Message
2389 * Process the message specified in the structure *_msg_.
2391 * If the lpMsg parameter points to a WM_TIMER message and the
2392 * parameter of the WM_TIMER message is not NULL, the lParam parameter
2393 * points to the function that is called instead of the window
2394 * procedure.
2396 * The message must be valid.
2398 * RETURNS
2400 * DispatchMessage() returns the result of the window procedure invoked.
2402 * CONFORMANCE
2404 * ECMA-234, Win32
2407 LONG WINAPI DispatchMessageW( const MSG* msg )
2409 WND * wndPtr;
2410 LONG retval;
2411 int painting;
2413 /* Process timer messages */
2414 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2416 if (msg->lParam)
2418 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2419 return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd,
2420 msg->message, msg->wParam, GetTickCount() );
2424 if (!msg->hwnd) return 0;
2425 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2426 if (!wndPtr->winproc)
2428 retval = 0;
2429 goto END;
2431 painting = (msg->message == WM_PAINT);
2432 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2433 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2435 SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
2436 msg->wParam, msg->lParam );
2437 retval = CallWindowProcW( (WNDPROC)wndPtr->winproc,
2438 msg->hwnd, msg->message,
2439 msg->wParam, msg->lParam );
2440 SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval );
2442 WIN_ReleaseWndPtr(wndPtr);
2443 wndPtr = WIN_FindWndPtr(msg->hwnd);
2445 if (painting && wndPtr &&
2446 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2448 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2449 msg->hwnd);
2450 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2451 /* Validate the update region to avoid infinite WM_PAINT loop */
2452 ValidateRect( msg->hwnd, NULL );
2454 END:
2455 WIN_ReleaseWndPtr(wndPtr);
2456 return retval;
2460 /***********************************************************************
2461 * RegisterWindowMessageA (USER.118) (USER32.437)
2463 WORD WINAPI RegisterWindowMessageA( LPCSTR str )
2465 TRACE("%s\n", str );
2466 return GlobalAddAtomA( str );
2470 /***********************************************************************
2471 * RegisterWindowMessageW (USER32.438)
2473 WORD WINAPI RegisterWindowMessageW( LPCWSTR str )
2475 TRACE("%p\n", str );
2476 return GlobalAddAtomW( str );
2480 /***********************************************************************
2481 * GetCurrentTime16 (USER.15)
2483 * (effectively identical to GetTickCount)
2485 DWORD WINAPI GetCurrentTime16(void)
2487 return GetTickCount();
2491 /***********************************************************************
2492 * InSendMessage16 (USER.192)
2494 BOOL16 WINAPI InSendMessage16(void)
2496 return InSendMessage();
2500 /***********************************************************************
2501 * InSendMessage (USER32.320)
2503 BOOL WINAPI InSendMessage(void)
2505 MESSAGEQUEUE *queue;
2506 BOOL ret;
2508 if (!(queue = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
2509 return 0;
2510 ret = (BOOL)queue->smWaiting;
2512 QUEUE_Unlock( queue );
2513 return ret;
2516 /***********************************************************************
2517 * BroadcastSystemMessage (USER32.12)
2519 LONG WINAPI BroadcastSystemMessage(
2520 DWORD dwFlags,LPDWORD recipients,UINT uMessage,WPARAM wParam,
2521 LPARAM lParam
2523 FIXME_(sendmsg)("(%08lx,%08lx,%08x,%08x,%08lx): stub!\n",
2524 dwFlags,*recipients,uMessage,wParam,lParam
2526 return 0;
2529 /***********************************************************************
2530 * SendNotifyMessageA (USER32.460)
2531 * FIXME
2532 * The message sended with PostMessage has to be put in the queue
2533 * with a higher priority as the other "Posted" messages.
2534 * QUEUE_AddMsg has to be modifyed.
2536 BOOL WINAPI SendNotifyMessageA(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
2537 { BOOL ret = TRUE;
2538 FIXME("(%04x,%08x,%08x,%08lx) not complete\n",
2539 hwnd, msg, wParam, lParam);
2541 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL))
2542 { ret=SendMessageA ( hwnd, msg, wParam, lParam );
2544 else
2545 { PostMessageA ( hwnd, msg, wParam, lParam );
2547 return ret;
2550 /***********************************************************************
2551 * SendNotifyMessageW (USER32.461)
2552 * FIXME
2553 * The message sended with PostMessage has to be put in the queue
2554 * with a higher priority as the other "Posted" messages.
2555 * QUEUE_AddMsg has to be modifyed.
2557 BOOL WINAPI SendNotifyMessageW(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
2558 { BOOL ret = TRUE;
2559 FIXME("(%04x,%08x,%08x,%08lx) not complete\n",
2560 hwnd, msg, wParam, lParam);
2562 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL))
2563 { ret=SendMessageW ( hwnd, msg, wParam, lParam );
2565 else
2566 { PostMessageW ( hwnd, msg, wParam, lParam );
2568 return ret;
2571 /***********************************************************************
2572 * SendMessageCallbackA
2573 * FIXME: It's like PostMessage. The callback gets called when the message
2574 * is processed. We have to modify the message processing for a exact
2575 * implementation...
2577 BOOL WINAPI SendMessageCallbackA(
2578 HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam,
2579 FARPROC lpResultCallBack,DWORD dwData)
2581 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2582 hWnd,Msg,wParam,lParam,lpResultCallBack,dwData);
2583 if ( hWnd == HWND_BROADCAST)
2584 { PostMessageA( hWnd, Msg, wParam, lParam);
2585 FIXME("Broadcast: Callback will not be called!\n");
2586 return TRUE;
2588 (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam ));
2589 return TRUE;
2591 /***********************************************************************
2592 * SendMessageCallbackW
2593 * FIXME: It's like PostMessage. The callback gets called when the message
2594 * is processed. We have to modify the message processing for a exact
2595 * implementation...
2597 BOOL WINAPI SendMessageCallbackW(
2598 HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam,
2599 FARPROC lpResultCallBack,DWORD dwData)
2601 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2602 hWnd,Msg,wParam,lParam,lpResultCallBack,dwData);
2603 if ( hWnd == HWND_BROADCAST)
2604 { PostMessageW( hWnd, Msg, wParam, lParam);
2605 FIXME("Broadcast: Callback will not be called!\n");
2606 return TRUE;
2608 (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam ));
2609 return TRUE;