SetScrollInfo : don't show/hide scrollbar if no parameter (minval,
[wine.git] / windows / message.c
blob7b57766ad395e213b2980f2e68790c15909a7901
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 a 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 if ( !hWnd ) return SYSQ_MSG_ABANDON;
386 pWnd = WIN_FindWndPtr( hWnd );
388 if (pWnd && (pWnd->hmemTaskQ != GetFastQueue16()))
390 /* Not for the current task */
391 MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() );
392 if (queue) QUEUE_ClearWakeBit( queue, QS_KEY );
393 QUEUE_Unlock( queue );
395 /* Wake up the other task */
396 queue = (MESSAGEQUEUE *)QUEUE_Lock( pWnd->hmemTaskQ );
397 if (queue) QUEUE_SetWakeBit( queue, QS_KEY );
398 QUEUE_Unlock( queue );
399 WIN_ReleaseWndPtr(pWnd);
400 return SYSQ_MSG_ABANDON;
402 WIN_ReleaseWndPtr(pWnd);
404 if (hTopWnd && hWnd != hTopWnd)
405 if (!IsChild(hTopWnd, hWnd)) return SYSQ_MSG_CONTINUE;
406 if (!MSG_CheckFilter(message, first, last)) return SYSQ_MSG_CONTINUE;
408 msg->hwnd = hWnd;
409 msg->message = message;
411 return SYSQ_MSG_ACCEPT;
415 /***********************************************************************
416 * MSG_ProcessKbdMsg
418 * Processes a translated keyboard message
420 static DWORD MSG_ProcessKbdMsg( MSG *msg, BOOL remove )
422 /* Handle F1 key by sending out WM_HELP message */
423 if ((msg->message == WM_KEYUP) &&
424 (msg->wParam == VK_F1) &&
425 remove &&
426 (msg->hwnd != GetDesktopWindow()) &&
427 !MENU_IsMenuActive())
429 HELPINFO hi;
430 WND *pWnd = WIN_FindWndPtr(msg->hwnd);
432 if (NULL != pWnd)
434 hi.cbSize = sizeof(HELPINFO);
435 hi.iContextType = HELPINFO_WINDOW;
436 hi.iCtrlId = pWnd->wIDmenu;
437 hi.hItemHandle = msg->hwnd;
438 hi.dwContextId = pWnd->helpContext;
439 hi.MousePos = msg->pt;
440 SendMessageA(msg->hwnd, WM_HELP, 0, (LPARAM)&hi);
442 WIN_ReleaseWndPtr(pWnd);
445 return (HOOK_CallHooks16( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE,
446 LOWORD (msg->wParam), msg->lParam )
447 ? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT);
451 /***********************************************************************
452 * MSG_JournalRecordMsg
454 * Build an EVENTMSG structure and call JOURNALRECORD hook
456 static void MSG_JournalRecordMsg( MSG *msg )
458 EVENTMSG *event = (EVENTMSG *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG));
459 if (!event) return;
460 event->message = msg->message;
461 event->time = msg->time;
462 if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
464 event->paramL = (msg->wParam & 0xFF) | (HIWORD(msg->lParam) << 8);
465 event->paramH = msg->lParam & 0x7FFF;
466 if (HIWORD(msg->lParam) & 0x0100)
467 event->paramH |= 0x8000; /* special_key - bit */
468 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
470 else if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
472 event->paramL = LOWORD(msg->lParam); /* X pos */
473 event->paramH = HIWORD(msg->lParam); /* Y pos */
474 ClientToScreen16( msg->hwnd, (LPPOINT16)&event->paramL );
475 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
477 else if ((msg->message >= WM_NCMOUSEFIRST) &&
478 (msg->message <= WM_NCMOUSELAST))
480 event->paramL = LOWORD(msg->lParam); /* X pos */
481 event->paramH = HIWORD(msg->lParam); /* Y pos */
482 event->message += WM_MOUSEMOVE-WM_NCMOUSEMOVE;/* give no info about NC area */
483 HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
486 HeapFree(SystemHeap, 0, event);
489 /***********************************************************************
490 * MSG_JournalPlayBackMsg
492 * Get an EVENTMSG struct via call JOURNALPLAYBACK hook function
494 static int MSG_JournalPlayBackMsg(void)
496 EVENTMSG *tmpMsg;
497 long wtime,lParam,wParam;
498 WORD keyDown,i,result=0;
500 if ( HOOK_IsHooked( WH_JOURNALPLAYBACK ) )
502 tmpMsg = (EVENTMSG *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG));
503 if (!tmpMsg) return result;
505 wtime=HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_GETNEXT, 0,
506 (LPARAM) tmpMsg );
507 /* TRACE(msg,"Playback wait time =%ld\n",wtime); */
508 if (wtime<=0)
510 wtime=0;
511 if ((tmpMsg->message>= WM_KEYFIRST) && (tmpMsg->message <= WM_KEYLAST))
513 wParam=tmpMsg->paramL & 0xFF;
514 lParam=MAKELONG(tmpMsg->paramH&0x7ffff,tmpMsg->paramL>>8);
515 if (tmpMsg->message == WM_KEYDOWN || tmpMsg->message == WM_SYSKEYDOWN)
517 for (keyDown=i=0; i<256 && !keyDown; i++)
518 if (InputKeyStateTable[i] & 0x80)
519 keyDown++;
520 if (!keyDown)
521 lParam |= 0x40000000;
522 AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] |= 0x80;
524 else /* WM_KEYUP, WM_SYSKEYUP */
526 lParam |= 0xC0000000;
527 AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] &= ~0x80;
529 if (InputKeyStateTable[VK_MENU] & 0x80)
530 lParam |= 0x20000000;
531 if (tmpMsg->paramH & 0x8000) /*special_key bit*/
532 lParam |= 0x01000000;
533 hardware_event( tmpMsg->message & 0xffff, LOWORD(wParam), lParam,
534 0, 0, tmpMsg->time, 0 );
536 else
538 if ((tmpMsg->message>= WM_MOUSEFIRST) && (tmpMsg->message <= WM_MOUSELAST))
540 switch (tmpMsg->message)
542 case WM_LBUTTONDOWN:
543 MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=TRUE;break;
544 case WM_LBUTTONUP:
545 MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=FALSE;break;
546 case WM_MBUTTONDOWN:
547 MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=TRUE;break;
548 case WM_MBUTTONUP:
549 MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=FALSE;break;
550 case WM_RBUTTONDOWN:
551 MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=TRUE;break;
552 case WM_RBUTTONUP:
553 MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=FALSE;break;
555 AsyncKeyStateTable[VK_LBUTTON]= InputKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0;
556 AsyncKeyStateTable[VK_MBUTTON]= InputKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0;
557 AsyncKeyStateTable[VK_RBUTTON]= InputKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0;
558 SetCursorPos(tmpMsg->paramL,tmpMsg->paramH);
559 lParam=MAKELONG(tmpMsg->paramL,tmpMsg->paramH);
560 wParam=0;
561 if (MouseButtonsStates[0]) wParam |= MK_LBUTTON;
562 if (MouseButtonsStates[1]) wParam |= MK_MBUTTON;
563 if (MouseButtonsStates[2]) wParam |= MK_RBUTTON;
564 hardware_event( tmpMsg->message & 0xffff, LOWORD (wParam), lParam,
565 tmpMsg->paramL, tmpMsg->paramH, tmpMsg->time, 0 );
568 HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_SKIP, 0,
569 (LPARAM) tmpMsg);
571 else
574 if( tmpMsg->message == WM_QUEUESYNC )
575 if (HOOK_IsHooked( WH_CBT ))
576 HOOK_CallHooksA( WH_CBT, HCBT_QS, 0, 0L);
578 result= QS_MOUSE | QS_KEY; /* ? */
580 HeapFree(SystemHeap, 0, tmpMsg);
582 return result;
585 /***********************************************************************
586 * MSG_PeekHardwareMsg
588 * Peek for a hardware message matching the hwnd and message filters.
590 static BOOL MSG_PeekHardwareMsg( MSG *msg, HWND hwnd, DWORD first, DWORD last,
591 BOOL remove )
593 /* FIXME: should deal with MSG32 instead of MSG16 */
595 DWORD status = SYSQ_MSG_ACCEPT;
596 MESSAGEQUEUE *sysMsgQueue = QUEUE_GetSysQueue();
597 enum { MOUSE_MSG = 0, KEYBOARD_MSG, HARDWARE_MSG } msgType;
598 QMSG *nextqmsg, *qmsg = 0;
599 BOOL bRet = FALSE;
601 EnterCriticalSection(&sysMsgQueue->cSection);
603 /* Loop through the Q and translate the message we wish to process
604 * while we own the lock. Based on the translation status (abandon/cont/accept)
605 * we then process the message accordingly
608 for ( qmsg = sysMsgQueue->firstMsg; qmsg; qmsg = nextqmsg )
610 INT16 hittest;
611 POINT16 screen_pt;
612 BOOL mouseClick;
614 *msg = qmsg->msg;
616 nextqmsg = qmsg->nextMsg;
618 /* Translate message */
620 if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
622 HWND hWndScope = (HWND)qmsg->extraInfo;
623 WND *tmpWnd = (Options.managed && IsWindow(hWndScope) )
624 ? WIN_FindWndPtr(hWndScope) : WIN_GetDesktop();
626 status = MSG_TranslateMouseMsg(hwnd, first, last, msg, remove, tmpWnd,
627 &hittest, &screen_pt, &mouseClick );
628 msgType = MOUSE_MSG;
630 WIN_ReleaseWndPtr(tmpWnd);
633 else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
635 status = MSG_TranslateKbdMsg(hwnd, first, last, msg, remove);
636 msgType = KEYBOARD_MSG;
638 else /* Non-standard hardware event */
640 HARDWAREHOOKSTRUCT16 *hook;
641 msgType = HARDWARE_MSG;
642 if ((hook = SEGPTR_NEW(HARDWAREHOOKSTRUCT16)))
644 BOOL ret;
645 hook->hWnd = msg->hwnd;
646 hook->wMessage = msg->message & 0xffff;
647 hook->wParam = LOWORD (msg->wParam);
648 hook->lParam = msg->lParam;
649 ret = HOOK_CallHooks16( WH_HARDWARE,
650 remove ? HC_ACTION : HC_NOREMOVE,
651 0, (LPARAM)SEGPTR_GET(hook) );
652 SEGPTR_FREE(hook);
653 if (ret)
655 QUEUE_RemoveMsg( sysMsgQueue, qmsg );
656 continue;
658 status = SYSQ_MSG_ACCEPT;
663 switch (LOWORD(status))
665 case SYSQ_MSG_ACCEPT:
667 /* Remove the message from the system msg Q while it is still locked,
668 * before accepting it */
669 if (remove)
671 if (HOOK_IsHooked( WH_JOURNALRECORD )) MSG_JournalRecordMsg( msg );
672 QUEUE_RemoveMsg( sysMsgQueue, qmsg );
674 /* Now actually process the message, after we unlock the system msg Q.
675 * We should not hold on to the crst since SendMessage calls during processing
676 * will potentially cause callbacks to PeekMessage from the application.
677 * If we're holding the crst and QUEUE_WaitBits is called with a
678 * QS_SENDMESSAGE mask we will deadlock in hardware_event() when a
679 * message is being posted to the Q.
681 LeaveCriticalSection(&sysMsgQueue->cSection);
682 if( msgType == KEYBOARD_MSG )
683 status = MSG_ProcessKbdMsg( msg, remove );
684 else if ( msgType == MOUSE_MSG )
685 status = MSG_ProcessMouseMsg( msg, remove, hittest, screen_pt, mouseClick );
687 /* Reclaim the sys msg Q crst */
688 EnterCriticalSection(&sysMsgQueue->cSection);
690 /* Pass the translated message to the user if it was accepted */
691 if (status == SYSQ_MSG_ACCEPT)
692 break;
694 /* If not accepted, fall through into the SYSQ_MSG_SKIP case */
697 case SYSQ_MSG_SKIP:
698 if (HOOK_IsHooked( WH_CBT ))
700 if( msgType == KEYBOARD_MSG )
701 HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED,
702 LOWORD (msg->wParam), msg->lParam );
703 else if ( msgType == MOUSE_MSG )
705 MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
706 if (hook)
708 CONV_POINT32TO16( &msg->pt,&hook->pt );
709 hook->hwnd = msg->hwnd;
710 hook->wHitTestCode = HIWORD(status);
711 hook->dwExtraInfo = 0;
712 HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message & 0xffff,
713 (LPARAM)SEGPTR_GET(hook) );
714 SEGPTR_FREE(hook);
719 /* If the message was removed earlier set up nextqmsg so that we start
720 * at the top of the queue again. We need to do this since our next pointer
721 * could be invalid due to us unlocking the system message Q to process the message.
722 * If not removed just refresh nextqmsg to point to the next msg.
724 if (remove)
725 nextqmsg = sysMsgQueue->firstMsg;
726 else
727 nextqmsg = qmsg->nextMsg;
729 continue;
731 case SYSQ_MSG_CONTINUE:
732 continue;
734 case SYSQ_MSG_ABANDON:
735 bRet = FALSE;
736 goto END;
739 bRet = TRUE;
740 goto END;
743 END:
744 LeaveCriticalSection(&sysMsgQueue->cSection);
745 return bRet;
749 /**********************************************************************
750 * SetDoubleClickTime16 (USER.20)
752 void WINAPI SetDoubleClickTime16( UINT16 interval )
754 SetDoubleClickTime( interval );
758 /**********************************************************************
759 * SetDoubleClickTime (USER32.480)
761 BOOL WINAPI SetDoubleClickTime( UINT interval )
763 doubleClickSpeed = interval ? interval : 500;
764 return TRUE;
768 /**********************************************************************
769 * GetDoubleClickTime16 (USER.21)
771 UINT16 WINAPI GetDoubleClickTime16(void)
773 return doubleClickSpeed;
777 /**********************************************************************
778 * GetDoubleClickTime (USER32.239)
780 UINT WINAPI GetDoubleClickTime(void)
782 return doubleClickSpeed;
786 /***********************************************************************
787 * MSG_SendMessageInterThread
789 * Implementation of an inter-task SendMessage.
790 * Return values:
791 * 0 if error or timeout
792 * 1 if successflul
794 static LRESULT MSG_SendMessageInterThread( HQUEUE16 hDestQueue,
795 HWND hwnd, UINT msg,
796 WPARAM wParam, LPARAM lParam,
797 DWORD timeout, WORD flags,
798 LRESULT *pRes)
800 MESSAGEQUEUE *queue, *destQ;
801 SMSG *smsg;
802 LRESULT retVal = 1;
803 int iWndsLocks;
805 *pRes = 0;
807 if (IsTaskLocked16() || !IsWindow(hwnd))
808 return 0;
810 /* create a SMSG structure to hold SendMessage() parameters */
811 if (! (smsg = (SMSG *) HeapAlloc( SystemHeap, 0, sizeof(SMSG) )) )
812 return 0;
813 if (!(queue = (MESSAGEQUEUE*)QUEUE_Lock( GetFastQueue16() ))) return 0;
815 if (!(destQ = (MESSAGEQUEUE*)QUEUE_Lock( hDestQueue )))
817 QUEUE_Unlock( queue );
818 return 0;
821 TRACE_(sendmsg)("SM: %s [%04x] (%04x -> %04x)\n",
822 SPY_GetMsgName(msg), msg, queue->self, hDestQueue );
824 /* fill up SMSG structure */
825 smsg->hWnd = hwnd;
826 smsg->msg = msg;
827 smsg->wParam = wParam;
828 smsg->lParam = lParam;
830 smsg->lResult = 0;
831 smsg->hSrcQueue = GetFastQueue16();
832 smsg->hDstQueue = hDestQueue;
833 smsg->flags = flags;
835 /* add smsg struct in the processing SM list of the source queue */
836 QUEUE_AddSMSG(queue, SM_PROCESSING_LIST, smsg);
838 /* add smsg struct in the pending list of the destination queue */
839 if (QUEUE_AddSMSG(destQ, SM_PENDING_LIST, smsg) == FALSE)
841 retVal = 0;
842 goto CLEANUP;
845 iWndsLocks = WIN_SuspendWndsLock();
847 /* force destination task to run next, if 16 bit threads */
848 if ( THREAD_IsWin16(NtCurrentTeb()) && THREAD_IsWin16(destQ->teb) )
849 DirectedYield16( destQ->teb->htask16 );
851 /* wait for the result, note that 16-bit apps almost always get out of
852 * DirectedYield() with SMSG_HAVE_RESULT flag already set */
854 while ( TRUE )
857 * The sequence is crucial to avoid deadlock situations:
858 * - first, we clear the QS_SMRESULT bit
859 * - then, we check the SMSG_HAVE_RESULT bit
860 * - only if this isn't set, we enter the wait state.
862 * As the receiver first sets the SMSG_HAVE_RESULT and then wakes us,
863 * we are guaranteed that -should we now clear the QS_SMRESULT that
864 * was signalled already by the receiver- we will not start waiting.
867 if ( smsg->flags & SMSG_HAVE_RESULT )
869 got:
870 *pRes = smsg->lResult;
871 TRACE_(sendmsg)("smResult = %08x\n", (unsigned)*pRes );
872 break;
875 QUEUE_ClearWakeBit( queue, QS_SMRESULT );
877 if ( smsg->flags & SMSG_HAVE_RESULT )
878 goto got;
880 if( QUEUE_WaitBits( QS_SMRESULT, timeout ) == 0 )
882 /* return with timeout */
883 SetLastError( 0 );
884 retVal = 0;
885 break;
888 WIN_RestoreWndsLock(iWndsLocks);
890 /* remove the smsg from the processingg list of the source queue */
891 QUEUE_RemoveSMSG( queue, SM_PROCESSING_LIST, smsg );
893 /* Note: the destination thread is in charge of removing the smsg from
894 the pending list */
896 /* In the case of an early reply (or a timeout), sender thread will
897 released the smsg structure if the receiver thread is done
898 (SMSG_RECEIVED set). If the receiver thread isn't done,
899 SMSG_RECEIVER_CLEANS_UP flag is set, and it will be the receiver
900 responsability to released smsg */
901 EnterCriticalSection( &queue->cSection );
903 if (smsg->flags & SMSG_RECEIVED)
904 HeapFree(SystemHeap, 0, smsg);
905 else
906 smsg->flags |= SMSG_RECEIVER_CLEANS;
908 LeaveCriticalSection( &queue->cSection );
911 CLEANUP:
912 QUEUE_Unlock( queue );
913 QUEUE_Unlock( destQ );
915 TRACE_(sendmsg)("done!\n");
916 return retVal;
920 /***********************************************************************
921 * ReplyMessage16 (USER.115)
923 void WINAPI ReplyMessage16( LRESULT result )
925 ReplyMessage( result );
928 /***********************************************************************
929 * ReplyMessage (USER.115)
931 BOOL WINAPI ReplyMessage( LRESULT result )
933 MESSAGEQUEUE *senderQ = 0;
934 MESSAGEQUEUE *queue = 0;
935 SMSG *smsg;
936 BOOL ret = FALSE;
938 if (!(queue = (MESSAGEQUEUE*)QUEUE_Lock( GetFastQueue16() )))
939 return FALSE;
941 TRACE_(sendmsg)("ReplyMessage, queue %04x\n", queue->self);
944 if ( !(smsg = queue->smWaiting)
945 || !(senderQ = QUEUE_Lock( smsg->hSrcQueue )) )
946 goto ReplyMessageEnd;
948 if ( !(smsg->flags & SMSG_ALREADY_REPLIED) )
950 /* This is the first reply, so pass result to sender */
952 TRACE_(sendmsg)("\trpm: smResult = %08lx\n", (long) result );
954 EnterCriticalSection(&senderQ->cSection);
956 smsg->lResult = result;
957 smsg->flags |= SMSG_ALREADY_REPLIED;
959 /* check if it's an early reply (called by the application) or
960 a regular reply (called by ReceiveMessage) */
961 if ( !(smsg->flags & SMSG_SENDING_REPLY) )
962 smsg->flags |= SMSG_EARLY_REPLY;
964 smsg->flags |= SMSG_HAVE_RESULT;
966 LeaveCriticalSection(&senderQ->cSection);
968 /* tell the sending task that its reply is ready */
969 QUEUE_SetWakeBit( senderQ, QS_SMRESULT );
971 /* switch directly to sending task (16 bit thread only) */
972 if ( THREAD_IsWin16( NtCurrentTeb() ) && THREAD_IsWin16( senderQ->teb ) )
973 DirectedYield16( senderQ->teb->htask16 );
975 ret = TRUE;
978 if (smsg->flags & SMSG_SENDING_REPLY)
980 /* remove msg from the waiting list, since this is the last
981 ReplyMessage */
982 QUEUE_RemoveSMSG( queue, SM_WAITING_LIST, smsg );
984 EnterCriticalSection(&senderQ->cSection);
986 /* tell the sender we're all done with smsg structure */
987 smsg->flags |= SMSG_RECEIVED;
989 /* sender will set SMSG_RECEIVER_CLEANS_UP if it wants the
990 receiver to clean up smsg, it could only happens when there is
991 an early reply or a timeout */
992 if ( smsg->flags & SMSG_RECEIVER_CLEANS )
994 TRACE_(sendmsg)("Receiver cleans up!\n" );
995 HeapFree( SystemHeap, 0, smsg );
998 LeaveCriticalSection(&senderQ->cSection);
1001 ReplyMessageEnd:
1002 if ( senderQ )
1003 QUEUE_Unlock( senderQ );
1004 if ( queue )
1005 QUEUE_Unlock( queue );
1007 return ret;
1010 /***********************************************************************
1011 * MSG_ConvertMsg
1013 static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType )
1015 UINT16 msg16;
1016 MSGPARAM16 mp16;
1018 switch ( MAKELONG( srcType, dstType ) )
1020 case MAKELONG( QMSG_WIN16, QMSG_WIN16 ):
1021 case MAKELONG( QMSG_WIN32A, QMSG_WIN32A ):
1022 case MAKELONG( QMSG_WIN32W, QMSG_WIN32W ):
1023 return TRUE;
1025 case MAKELONG( QMSG_WIN16, QMSG_WIN32A ):
1026 switch ( WINPROC_MapMsg16To32A( msg->message, msg->wParam,
1027 &msg->message, &msg->wParam, &msg->lParam ) )
1029 case 0:
1030 return TRUE;
1031 case 1:
1032 /* Pointer messages were mapped --> need to free allocated memory and fail */
1033 WINPROC_UnmapMsg16To32A( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 );
1034 default:
1035 return FALSE;
1038 case MAKELONG( QMSG_WIN16, QMSG_WIN32W ):
1039 switch ( WINPROC_MapMsg16To32W( msg->hwnd, msg->message, msg->wParam,
1040 &msg->message, &msg->wParam, &msg->lParam ) )
1042 case 0:
1043 return TRUE;
1044 case 1:
1045 /* Pointer messages were mapped --> need to free allocated memory and fail */
1046 WINPROC_UnmapMsg16To32W( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 );
1047 default:
1048 return FALSE;
1051 case MAKELONG( QMSG_WIN32A, QMSG_WIN16 ):
1052 mp16.lParam = msg->lParam;
1053 switch ( WINPROC_MapMsg32ATo16( msg->hwnd, msg->message, msg->wParam,
1054 &msg16, &mp16.wParam, &mp16.lParam ) )
1056 case 0:
1057 msg->message = msg16;
1058 msg->wParam = mp16.wParam;
1059 msg->lParam = mp16.lParam;
1060 return TRUE;
1061 case 1:
1062 /* Pointer messages were mapped --> need to free allocated memory and fail */
1063 WINPROC_UnmapMsg32ATo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 );
1064 default:
1065 return FALSE;
1068 case MAKELONG( QMSG_WIN32W, QMSG_WIN16 ):
1069 mp16.lParam = msg->lParam;
1070 switch ( WINPROC_MapMsg32WTo16( msg->hwnd, msg->message, msg->wParam,
1071 &msg16, &mp16.wParam, &mp16.lParam ) )
1073 case 0:
1074 msg->message = msg16;
1075 msg->wParam = mp16.wParam;
1076 msg->lParam = mp16.lParam;
1077 return TRUE;
1078 case 1:
1079 /* Pointer messages were mapped --> need to free allocated memory and fail */
1080 WINPROC_UnmapMsg32WTo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 );
1081 default:
1082 return FALSE;
1085 case MAKELONG( QMSG_WIN32A, QMSG_WIN32W ):
1086 switch ( WINPROC_MapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) )
1088 case 0:
1089 return TRUE;
1090 case 1:
1091 /* Pointer messages were mapped --> need to free allocated memory and fail */
1092 WINPROC_UnmapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, msg->lParam );
1093 default:
1094 return FALSE;
1097 case MAKELONG( QMSG_WIN32W, QMSG_WIN32A ):
1098 switch ( WINPROC_MapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, &msg->lParam ) )
1100 case 0:
1101 return TRUE;
1102 case 1:
1103 /* Pointer messages were mapped --> need to free allocated memory and fail */
1104 WINPROC_UnmapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, msg->lParam );
1105 default:
1106 return FALSE;
1109 default:
1110 FIXME( "Invalid message type(s): %d / %d\n", srcType, dstType );
1111 return FALSE;
1115 /***********************************************************************
1116 * MSG_PeekMessage
1118 static BOOL MSG_PeekMessage( int type, LPMSG msg, HWND hwnd,
1119 DWORD first, DWORD last, WORD flags, BOOL peek )
1121 int mask;
1122 MESSAGEQUEUE *msgQueue;
1123 HQUEUE16 hQueue;
1124 POINT16 pt16;
1125 int iWndsLocks;
1127 mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */
1128 if (first || last)
1130 if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY;
1131 if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) ||
1132 ((first <= WM_NCMOUSELAST) && (last >= WM_NCMOUSEFIRST)) ) mask |= QS_MOUSE;
1133 if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER;
1134 if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER;
1135 if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT;
1137 else mask |= QS_MOUSE | QS_KEY | QS_TIMER | QS_PAINT;
1139 if (IsTaskLocked16()) flags |= PM_NOYIELD;
1141 /* Never yield on Win32 threads */
1142 if (!THREAD_IsWin16(NtCurrentTeb())) flags |= PM_NOYIELD;
1144 iWndsLocks = WIN_SuspendWndsLock();
1146 while(1)
1148 QMSG *qmsg;
1150 hQueue = GetFastQueue16();
1151 msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
1152 if (!msgQueue)
1154 WIN_RestoreWndsLock(iWndsLocks);
1155 return FALSE;
1157 msgQueue->changeBits = 0;
1159 /* First handle a message put by SendMessage() */
1161 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1162 QUEUE_ReceiveMessage( msgQueue );
1164 /* Now handle a WM_QUIT message */
1166 if (msgQueue->wPostQMsg &&
1167 (!first || WM_QUIT >= first) &&
1168 (!last || WM_QUIT <= last) )
1170 msg->hwnd = hwnd;
1171 msg->message = WM_QUIT;
1172 msg->wParam = msgQueue->wExitCode;
1173 msg->lParam = 0;
1174 if (flags & PM_REMOVE) msgQueue->wPostQMsg = 0;
1175 break;
1178 /* Now find a normal message */
1180 retry:
1181 if (((msgQueue->wakeBits & mask) & QS_POSTMESSAGE) &&
1182 ((qmsg = QUEUE_FindMsg( msgQueue, hwnd, first, last )) != 0))
1184 /* Try to convert message to requested type */
1185 MSG tmpMsg = qmsg->msg;
1186 if ( !MSG_ConvertMsg( &tmpMsg, qmsg->type, type ) )
1188 ERR( "Message of wrong type contains pointer parameters. Skipped!\n ");
1189 QUEUE_RemoveMsg( msgQueue, qmsg );
1190 goto retry;
1193 *msg = tmpMsg;
1194 msgQueue->GetMessageTimeVal = msg->time;
1195 CONV_POINT32TO16(&msg->pt, &pt16);
1196 msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
1197 msgQueue->GetMessageExtraInfoVal = qmsg->extraInfo;
1199 if (flags & PM_REMOVE) QUEUE_RemoveMsg( msgQueue, qmsg );
1200 break;
1203 msgQueue->changeBits |= MSG_JournalPlayBackMsg();
1205 /* Now find a hardware event */
1207 if (MSG_PeekHardwareMsg( msg, hwnd, first, last, flags & PM_REMOVE ))
1209 /* Got one */
1210 msgQueue->GetMessageTimeVal = msg->time;
1211 CONV_POINT32TO16(&msg->pt, &pt16);
1212 msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
1213 msgQueue->GetMessageExtraInfoVal = 0; /* Always 0 for now */
1214 break;
1217 /* Check again for SendMessage */
1219 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1220 QUEUE_ReceiveMessage( msgQueue );
1222 /* Now find a WM_PAINT message */
1224 if ((msgQueue->wakeBits & mask) & QS_PAINT)
1226 WND* wndPtr;
1227 msg->hwnd = WIN_FindWinToRepaint( hwnd , hQueue );
1228 msg->message = WM_PAINT;
1229 msg->wParam = 0;
1230 msg->lParam = 0;
1232 if ((wndPtr = WIN_FindWndPtr(msg->hwnd)))
1234 if( wndPtr->dwStyle & WS_MINIMIZE &&
1235 (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON) )
1237 msg->message = WM_PAINTICON;
1238 msg->wParam = 1;
1241 if( !hwnd || msg->hwnd == hwnd || IsChild16(hwnd,msg->hwnd) )
1243 if( wndPtr->flags & WIN_INTERNAL_PAINT && !wndPtr->hrgnUpdate)
1245 wndPtr->flags &= ~WIN_INTERNAL_PAINT;
1246 QUEUE_DecPaintCount( hQueue );
1248 WIN_ReleaseWndPtr(wndPtr);
1249 break;
1251 WIN_ReleaseWndPtr(wndPtr);
1255 /* Check for timer messages, but yield first */
1257 if (!(flags & PM_NOYIELD))
1259 UserYield16();
1260 while (msgQueue->wakeBits & QS_SENDMESSAGE)
1261 QUEUE_ReceiveMessage( msgQueue );
1263 if ((msgQueue->wakeBits & mask) & QS_TIMER)
1265 if (TIMER_GetTimerMsg(msg, hwnd, hQueue, flags & PM_REMOVE)) break;
1268 if (peek)
1270 if (!(flags & PM_NOYIELD)) UserYield16();
1272 QUEUE_Unlock( msgQueue );
1273 WIN_RestoreWndsLock(iWndsLocks);
1274 return FALSE;
1276 msgQueue->wakeMask = mask;
1277 QUEUE_WaitBits( mask, INFINITE );
1278 QUEUE_Unlock( msgQueue );
1281 WIN_RestoreWndsLock(iWndsLocks);
1283 /* instead of unlocking queue for every break condition, all break
1284 condition will fall here */
1285 QUEUE_Unlock( msgQueue );
1287 /* We got a message */
1288 if (flags & PM_REMOVE)
1290 WORD message = msg->message;
1292 if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
1294 BYTE *p = &QueueKeyStateTable[msg->wParam & 0xff];
1296 if (!(*p & 0x80))
1297 *p ^= 0x01;
1298 *p |= 0x80;
1300 else if (message == WM_KEYUP || message == WM_SYSKEYUP)
1301 QueueKeyStateTable[msg->wParam & 0xff] &= ~0x80;
1304 if (peek)
1305 return TRUE;
1307 else
1308 return (msg->message != WM_QUIT);
1311 /***********************************************************************
1312 * MSG_InternalGetMessage
1314 * GetMessage() function for internal use. Behave like GetMessage(),
1315 * but also call message filters and optionally send WM_ENTERIDLE messages.
1316 * 'hwnd' must be the handle of the dialog or menu window.
1317 * 'code' is the message filter value (MSGF_??? codes).
1319 BOOL MSG_InternalGetMessage( int type, MSG *msg, HWND hwnd, HWND hwndOwner,
1320 WPARAM code, WORD flags, BOOL sendIdle, BOOL* idleSent )
1322 for (;;)
1324 if (sendIdle)
1326 if (!MSG_PeekMessage( type, msg, 0, 0, 0, flags, TRUE ))
1328 /* No message present -> send ENTERIDLE and wait */
1329 if (IsWindow(hwndOwner))
1331 SendMessageA( hwndOwner, WM_ENTERIDLE,
1332 code, (LPARAM)hwnd );
1334 if (idleSent!=NULL)
1335 *idleSent=TRUE;
1337 MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE );
1340 else /* Always wait for a message */
1341 MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE );
1343 /* Call message filters */
1345 if (HOOK_IsHooked( WH_SYSMSGFILTER ) || HOOK_IsHooked( WH_MSGFILTER ))
1347 MSG *pmsg = HeapAlloc( SystemHeap, 0, sizeof(MSG) );
1348 if (pmsg)
1350 BOOL ret;
1351 *pmsg = *msg;
1352 ret = (HOOK_CallHooksA( WH_SYSMSGFILTER, code, 0,
1353 (LPARAM) pmsg ) ||
1354 HOOK_CallHooksA( WH_MSGFILTER, code, 0,
1355 (LPARAM) pmsg ));
1357 HeapFree( SystemHeap, 0, pmsg );
1358 if (ret)
1360 /* Message filtered -> remove it from the queue */
1361 /* if it's still there. */
1362 if (!(flags & PM_REMOVE))
1363 MSG_PeekMessage( type, msg, 0, 0, 0, PM_REMOVE, TRUE );
1364 continue;
1369 return (msg->message != WM_QUIT);
1374 /***********************************************************************
1375 * PeekMessage32_16 (USER.819)
1377 BOOL16 WINAPI PeekMessage32_16( LPMSG16_32 lpmsg16_32, HWND16 hwnd,
1378 UINT16 first, UINT16 last, UINT16 flags,
1379 BOOL16 wHaveParamHigh )
1381 BOOL ret;
1382 MSG msg;
1384 ret = MSG_PeekMessage( QMSG_WIN16, &msg, hwnd, first, last, flags, TRUE );
1386 lpmsg16_32->msg.hwnd = msg.hwnd;
1387 lpmsg16_32->msg.message = msg.message;
1388 lpmsg16_32->msg.wParam = LOWORD(msg.wParam);
1389 lpmsg16_32->msg.lParam = msg.lParam;
1390 lpmsg16_32->msg.time = msg.time;
1391 lpmsg16_32->msg.pt.x = (INT16)msg.pt.x;
1392 lpmsg16_32->msg.pt.y = (INT16)msg.pt.y;
1394 if ( wHaveParamHigh )
1395 lpmsg16_32->wParamHigh = HIWORD(msg.wParam);
1397 return ret;
1400 /***********************************************************************
1401 * PeekMessage16 (USER.109)
1403 BOOL16 WINAPI PeekMessage16( LPMSG16 lpmsg, HWND16 hwnd,
1404 UINT16 first, UINT16 last, UINT16 flags )
1406 return PeekMessage32_16( (LPMSG16_32)lpmsg, hwnd, first, last, flags, FALSE );
1409 /***********************************************************************
1410 * PeekMessageA
1412 BOOL WINAPI PeekMessageA( LPMSG lpmsg, HWND hwnd,
1413 UINT min, UINT max, UINT wRemoveMsg)
1415 return MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
1418 /***********************************************************************
1419 * PeekMessageW Check queue for messages
1421 * Checks for a message in the thread's queue, filtered as for
1422 * GetMessage(). Returns immediately whether a message is available
1423 * or not.
1425 * Whether a retrieved message is removed from the queue is set by the
1426 * _wRemoveMsg_ flags, which should be one of the following values:
1428 * PM_NOREMOVE Do not remove the message from the queue.
1430 * PM_REMOVE Remove the message from the queue.
1432 * In addition, PM_NOYIELD may be combined into _wRemoveMsg_ to
1433 * request that the system not yield control during PeekMessage();
1434 * however applications may not rely on scheduling behavior.
1436 * RETURNS
1438 * Nonzero if a message is available and is retrieved, zero otherwise.
1440 * CONFORMANCE
1442 * ECMA-234, Win32
1445 BOOL WINAPI PeekMessageW(
1446 LPMSG lpmsg, /* buffer to receive message */
1447 HWND hwnd, /* restrict to messages for hwnd */
1448 UINT min, /* minimum message to receive */
1449 UINT max, /* maximum message to receive */
1450 UINT wRemoveMsg /* removal flags */
1453 return MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
1457 /***********************************************************************
1458 * GetMessage32_16 (USER.820)
1460 BOOL16 WINAPI GetMessage32_16( SEGPTR msg16_32, HWND16 hWnd, UINT16 first,
1461 UINT16 last, BOOL16 wHaveParamHigh )
1463 MSG32_16 *lpmsg16_32 = (MSG32_16 *)PTR_SEG_TO_LIN(msg16_32);
1464 MSG msg;
1466 MSG_PeekMessage( QMSG_WIN16, &msg, hWnd, first, last, PM_REMOVE, FALSE );
1468 lpmsg16_32->msg.hwnd = msg.hwnd;
1469 lpmsg16_32->msg.message = msg.message;
1470 lpmsg16_32->msg.wParam = LOWORD(msg.wParam);
1471 lpmsg16_32->msg.lParam = msg.lParam;
1472 lpmsg16_32->msg.time = msg.time;
1473 lpmsg16_32->msg.pt.x = (INT16)msg.pt.x;
1474 lpmsg16_32->msg.pt.y = (INT16)msg.pt.y;
1476 if ( wHaveParamHigh )
1477 lpmsg16_32->wParamHigh = HIWORD(msg.wParam);
1479 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1480 lpmsg16_32->msg.message, hWnd, first, last );
1482 HOOK_CallHooks16( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)msg16_32 );
1483 return lpmsg16_32->msg.message != WM_QUIT;
1486 /***********************************************************************
1487 * GetMessage16 (USER.108)
1489 BOOL16 WINAPI GetMessage16( SEGPTR msg, HWND16 hwnd, UINT16 first, UINT16 last)
1491 return GetMessage32_16( msg, hwnd, first, last, FALSE );
1494 /***********************************************************************
1495 * GetMessageA (USER32.270)
1497 BOOL WINAPI GetMessageA( MSG *lpmsg, HWND hwnd, UINT min, UINT max )
1499 MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
1501 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1502 lpmsg->message, hwnd, min, max );
1504 HOOK_CallHooksA( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
1505 return lpmsg->message != WM_QUIT;
1508 /***********************************************************************
1509 * GetMessageW (USER32.274) Retrieve next message
1511 * GetMessage retrieves the next event from the calling thread's
1512 * queue and deposits it in *lpmsg.
1514 * If _hwnd_ is not NULL, only messages for window _hwnd_ and its
1515 * children as specified by IsChild() are retrieved. If _hwnd_ is NULL
1516 * all application messages are retrieved.
1518 * _min_ and _max_ specify the range of messages of interest. If
1519 * min==max==0, no filtering is performed. Useful examples are
1520 * WM_KEYFIRST and WM_KEYLAST to retrieve keyboard input, and
1521 * WM_MOUSEFIRST and WM_MOUSELAST to retrieve mouse input.
1523 * WM_PAINT messages are not removed from the queue; they remain until
1524 * processed. Other messages are removed from the queue.
1526 * RETURNS
1528 * -1 on error, 0 if message is WM_QUIT, nonzero otherwise.
1530 * CONFORMANCE
1532 * ECMA-234, Win32
1535 BOOL WINAPI GetMessageW(
1536 MSG* lpmsg, /* buffer to receive message */
1537 HWND hwnd, /* restrict to messages for hwnd */
1538 UINT min, /* minimum message to receive */
1539 UINT max /* maximum message to receive */
1542 MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
1544 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1545 lpmsg->message, hwnd, min, max );
1547 HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
1548 return lpmsg->message != WM_QUIT;
1551 /***********************************************************************
1552 * MSG_PostToQueue
1554 static BOOL MSG_PostToQueue( HQUEUE16 hQueue, int type, HWND hwnd,
1555 UINT message, WPARAM wParam, LPARAM lParam )
1557 MSG msg;
1559 if ( !hQueue ) return FALSE;
1561 msg.hwnd = hwnd;
1562 msg.message = message;
1563 msg.wParam = wParam;
1564 msg.lParam = lParam;
1565 msg.time = GetTickCount();
1566 GetCursorPos(&msg.pt);
1568 return QUEUE_AddMsg( hQueue, type, &msg, 0 );
1571 /***********************************************************************
1572 * MSG_PostMessage
1574 static BOOL MSG_PostMessage( int type, HWND hwnd, UINT message,
1575 WPARAM wParam, LPARAM lParam )
1577 HQUEUE16 hQueue;
1578 WND *wndPtr;
1580 if (hwnd == HWND_BROADCAST)
1582 WND *pDesktop = WIN_GetDesktop();
1583 TRACE("HWND_BROADCAST !\n");
1585 for (wndPtr=WIN_LockWndPtr(pDesktop->child); wndPtr; WIN_UpdateWndPtr(&wndPtr,wndPtr->next))
1587 if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
1589 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n",
1590 wndPtr->hwndSelf, message, wParam, lParam);
1591 MSG_PostToQueue( wndPtr->hmemTaskQ, type,
1592 wndPtr->hwndSelf, message, wParam, lParam );
1595 WIN_ReleaseDesktop();
1596 TRACE("End of HWND_BROADCAST !\n");
1597 return TRUE;
1600 wndPtr = WIN_FindWndPtr( hwnd );
1601 hQueue = wndPtr? wndPtr->hmemTaskQ : 0;
1602 WIN_ReleaseWndPtr(wndPtr);
1604 return MSG_PostToQueue( hQueue, type, hwnd, message, wParam, lParam );
1607 /***********************************************************************
1608 * PostMessage16 (USER.110)
1610 BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam,
1611 LPARAM lParam )
1613 return (BOOL16) MSG_PostMessage( QMSG_WIN16, hwnd, message, wParam, lParam );
1616 /***********************************************************************
1617 * PostMessageA (USER32.419)
1619 BOOL WINAPI PostMessageA( HWND hwnd, UINT message, WPARAM wParam,
1620 LPARAM lParam )
1622 return MSG_PostMessage( QMSG_WIN32A, hwnd, message, wParam, lParam );
1625 /***********************************************************************
1626 * PostMessageW (USER32.420)
1628 BOOL WINAPI PostMessageW( HWND hwnd, UINT message, WPARAM wParam,
1629 LPARAM lParam )
1631 return MSG_PostMessage( QMSG_WIN32W, hwnd, message, wParam, lParam );
1634 /***********************************************************************
1635 * PostAppMessage16 (USER.116)
1637 BOOL16 WINAPI PostAppMessage16( HTASK16 hTask, UINT16 message,
1638 WPARAM16 wParam, LPARAM lParam )
1640 return MSG_PostToQueue( GetTaskQueue16(hTask), QMSG_WIN16,
1641 0, message, wParam, lParam );
1644 /**********************************************************************
1645 * PostThreadMessageA (USER32.422)
1647 BOOL WINAPI PostThreadMessageA( DWORD idThread, UINT message,
1648 WPARAM wParam, LPARAM lParam )
1650 return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32A,
1651 0, message, wParam, lParam );
1654 /**********************************************************************
1655 * PostThreadMessageW (USER32.423)
1657 BOOL WINAPI PostThreadMessageW( DWORD idThread, UINT message,
1658 WPARAM wParam, LPARAM lParam )
1660 return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32W,
1661 0, message, wParam, lParam );
1665 /************************************************************************
1666 * MSG_CallWndProcHook32
1668 static void MSG_CallWndProcHook( LPMSG pmsg, BOOL bUnicode )
1670 CWPSTRUCT cwp;
1672 cwp.lParam = pmsg->lParam;
1673 cwp.wParam = pmsg->wParam;
1674 cwp.message = pmsg->message;
1675 cwp.hwnd = pmsg->hwnd;
1677 if (bUnicode) HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1678 else HOOK_CallHooksA( WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp );
1680 pmsg->lParam = cwp.lParam;
1681 pmsg->wParam = cwp.wParam;
1682 pmsg->message = cwp.message;
1683 pmsg->hwnd = cwp.hwnd;
1687 /***********************************************************************
1688 * MSG_SendMessage
1690 * return values: 0 if timeout occurs
1691 * 1 otherwise
1693 static LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam,
1694 LPARAM lParam, DWORD timeout, WORD flags,
1695 LRESULT *pRes)
1697 WND * wndPtr = 0;
1698 WND **list, **ppWnd;
1699 LRESULT ret = 1;
1701 *pRes = 0;
1703 if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
1705 *pRes = 1;
1707 if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
1709 WIN_ReleaseDesktop();
1710 return 1;
1712 WIN_ReleaseDesktop();
1714 TRACE("HWND_BROADCAST !\n");
1715 for (ppWnd = list; *ppWnd; ppWnd++)
1717 WIN_UpdateWndPtr(&wndPtr,*ppWnd);
1718 if (!IsWindow(wndPtr->hwndSelf)) continue;
1719 if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
1721 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n",
1722 wndPtr->hwndSelf, msg, (DWORD)wParam, lParam);
1723 MSG_SendMessage( wndPtr->hwndSelf, msg, wParam, lParam,
1724 timeout, flags, pRes);
1727 WIN_ReleaseWndPtr(wndPtr);
1728 WIN_ReleaseWinArray(list);
1729 TRACE("End of HWND_BROADCAST !\n");
1730 return 1;
1733 if (HOOK_IsHooked( WH_CALLWNDPROC ))
1735 if (flags & SMSG_UNICODE)
1736 MSG_CallWndProcHook( (LPMSG)&hwnd, TRUE);
1737 else if (flags & SMSG_WIN32)
1738 MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE);
1739 else
1741 LPCWPSTRUCT16 pmsg;
1743 if ((pmsg = SEGPTR_NEW(CWPSTRUCT16)))
1745 pmsg->hwnd = hwnd & 0xffff;
1746 pmsg->message= msg & 0xffff;
1747 pmsg->wParam = wParam & 0xffff;
1748 pmsg->lParam = lParam;
1749 HOOK_CallHooks16( WH_CALLWNDPROC, HC_ACTION, 1,
1750 (LPARAM)SEGPTR_GET(pmsg) );
1751 hwnd = pmsg->hwnd;
1752 msg = pmsg->message;
1753 wParam = pmsg->wParam;
1754 lParam = pmsg->lParam;
1755 SEGPTR_FREE( pmsg );
1760 if (!(wndPtr = WIN_FindWndPtr( hwnd )))
1762 WARN("invalid hwnd %04x\n", hwnd );
1763 return 0;
1765 if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ))
1767 ret = 0; /* Don't send anything if the task is dying */
1768 goto END;
1770 if (flags & SMSG_WIN32)
1771 SPY_EnterMessage( SPY_SENDMESSAGE, hwnd, msg, wParam, lParam );
1772 else
1773 SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wParam, lParam );
1775 if (wndPtr->hmemTaskQ != GetFastQueue16())
1776 ret = MSG_SendMessageInterThread( wndPtr->hmemTaskQ, hwnd, msg,
1777 wParam, lParam, timeout, flags, pRes );
1778 else
1780 /* Call the right CallWindowProc flavor */
1781 if (flags & SMSG_UNICODE)
1782 *pRes = CallWindowProcW( (WNDPROC)wndPtr->winproc,
1783 hwnd, msg, wParam, lParam );
1784 else if (flags & SMSG_WIN32)
1785 *pRes = CallWindowProcA( (WNDPROC)wndPtr->winproc,
1786 hwnd, msg, wParam, lParam );
1787 else
1788 *pRes = CallWindowProc16( (WNDPROC16)wndPtr->winproc,
1789 (HWND16) hwnd, (UINT16) msg,
1790 (WPARAM16) wParam, lParam );
1793 if (flags & SMSG_WIN32)
1794 SPY_ExitMessage( SPY_RESULT_OK, hwnd, msg, *pRes );
1795 else
1796 SPY_ExitMessage( SPY_RESULT_OK16, hwnd, msg, *pRes );
1797 END:
1798 WIN_ReleaseWndPtr(wndPtr);
1799 return ret;
1803 /***********************************************************************
1804 * SendMessage16 (USER.111)
1806 LRESULT WINAPI SendMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
1807 LPARAM lParam)
1809 LRESULT res;
1810 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, 0, &res);
1811 return res;
1815 /***********************************************************************
1816 * SendMessageA (USER32.454)
1818 LRESULT WINAPI SendMessageA( HWND hwnd, UINT msg, WPARAM wParam,
1819 LPARAM lParam )
1821 LRESULT res;
1823 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE,
1824 SMSG_WIN32, &res);
1826 return res;
1830 /***********************************************************************
1831 * SendMessageW (USER32.459) Send Window Message
1833 * Sends a message to the window procedure of the specified window.
1834 * SendMessage() will not return until the called window procedure
1835 * either returns or calls ReplyMessage().
1837 * Use PostMessage() to send message and return immediately. A window
1838 * procedure may use InSendMessage() to detect
1839 * SendMessage()-originated messages.
1841 * Applications which communicate via HWND_BROADCAST may use
1842 * RegisterWindowMessage() to obtain a unique message to avoid conflicts
1843 * with other applications.
1845 * CONFORMANCE
1847 * ECMA-234, Win32
1849 LRESULT WINAPI SendMessageW(
1850 HWND hwnd, /* Window to send message to. If HWND_BROADCAST,
1851 the message will be sent to all top-level windows. */
1853 UINT msg, /* message */
1854 WPARAM wParam, /* message parameter */
1855 LPARAM lParam /* additional message parameter */
1857 LRESULT res;
1859 MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE,
1860 SMSG_WIN32 | SMSG_UNICODE, &res);
1862 return res;
1866 /***********************************************************************
1867 * SendMessageTimeout16 (not a WINAPI)
1869 LRESULT WINAPI SendMessageTimeout16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam,
1870 LPARAM lParam, UINT16 flags,
1871 UINT16 timeout, LPWORD resultp)
1873 LRESULT ret;
1874 LRESULT msgRet;
1876 /* FIXME: need support for SMTO_BLOCK */
1878 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, 0, &msgRet);
1879 if (resultp) *resultp = (WORD) msgRet;
1880 return ret;
1884 /***********************************************************************
1885 * SendMessageTimeoutA (USER32.457)
1887 LRESULT WINAPI SendMessageTimeoutA( 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, SMSG_WIN32,
1897 &msgRet);
1899 if (resultp) *resultp = (DWORD) msgRet;
1900 return ret;
1904 /***********************************************************************
1905 * SendMessageTimeoutW (USER32.458)
1907 LRESULT WINAPI SendMessageTimeoutW( HWND hwnd, UINT msg, WPARAM wParam,
1908 LPARAM lParam, UINT flags,
1909 UINT timeout, LPDWORD resultp)
1911 LRESULT ret;
1912 LRESULT msgRet;
1914 /* FIXME: need support for SMTO_BLOCK */
1916 ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout,
1917 SMSG_WIN32 | SMSG_UNICODE, &msgRet);
1919 if (resultp) *resultp = (DWORD) msgRet;
1920 return ret;
1924 /***********************************************************************
1925 * WaitMessage (USER.112) (USER32.578) Suspend thread pending messages
1927 * WaitMessage() suspends a thread until events appear in the thread's
1928 * queue.
1930 * BUGS
1932 * Is supposed to return BOOL under Win32.
1934 * Thread-local message queues are not supported.
1936 * CONFORMANCE
1938 * ECMA-234, Win32
1941 void WINAPI WaitMessage( void )
1943 QUEUE_WaitBits( QS_ALLINPUT, INFINITE );
1946 /***********************************************************************
1947 * MsgWaitForMultipleObjects (USER32.400)
1949 DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE *pHandles,
1950 BOOL fWaitAll, DWORD dwMilliseconds,
1951 DWORD dwWakeMask )
1953 DWORD i;
1954 HANDLE handles[MAXIMUM_WAIT_OBJECTS];
1955 DWORD ret;
1957 HQUEUE16 hQueue = GetFastQueue16();
1958 MESSAGEQUEUE *msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
1959 if (!msgQueue) return WAIT_FAILED;
1961 if (nCount > MAXIMUM_WAIT_OBJECTS-1)
1963 SetLastError( ERROR_INVALID_PARAMETER );
1964 QUEUE_Unlock( msgQueue );
1965 return WAIT_FAILED;
1968 msgQueue->changeBits = 0;
1969 msgQueue->wakeMask = dwWakeMask;
1971 if (THREAD_IsWin16(NtCurrentTeb()))
1974 * This is a temporary solution to a big problem.
1975 * You see, the main thread of all Win32 programs is created as a 16 bit
1976 * task. This means that if you wait on an event using Win32 synchronization
1977 * methods, the 16 bit scheduler is stopped and things might just stop happening.
1978 * This implements a semi-busy loop that checks the handles to wait on and
1979 * also the message queue. When either one is ready, the wait function returns.
1981 * This will all go away when the real Win32 threads are implemented for all
1982 * the threads of an applications. Including the main thread.
1984 DWORD curTime = GetCurrentTime();
1989 * Check the handles in the list.
1991 ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, 5L);
1994 * If the handles have been triggered, return.
1996 if (ret != WAIT_TIMEOUT)
1997 break;
2000 * Then, let the 16 bit scheduler do it's thing.
2002 Yield16();
2005 * If a message matching the wait mask has arrived, return.
2007 if (msgQueue->changeBits & dwWakeMask)
2009 ret = nCount;
2010 break;
2014 * And continue doing this until we hit the timeout.
2016 } while ((dwMilliseconds == INFINITE) || (GetCurrentTime()-curTime < dwMilliseconds) );
2018 else
2020 /* Add the thread event to the handle list */
2021 for (i = 0; i < nCount; i++)
2022 handles[i] = pHandles[i];
2023 handles[nCount] = msgQueue->server_queue;
2024 ret = WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds );
2026 QUEUE_Unlock( msgQueue );
2027 return ret;
2032 struct accent_char
2034 BYTE ac_accent;
2035 BYTE ac_char;
2036 BYTE ac_result;
2039 static const struct accent_char accent_chars[] =
2041 /* A good idea should be to read /usr/X11/lib/X11/locale/iso8859-x/Compose */
2042 {'`', 'A', '\300'}, {'`', 'a', '\340'},
2043 {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
2044 {'^', 'A', '\302'}, {'^', 'a', '\342'},
2045 {'~', 'A', '\303'}, {'~', 'a', '\343'},
2046 {'"', 'A', '\304'}, {'"', 'a', '\344'},
2047 {'O', 'A', '\305'}, {'o', 'a', '\345'},
2048 {'0', 'A', '\305'}, {'0', 'a', '\345'},
2049 {'A', 'A', '\305'}, {'a', 'a', '\345'},
2050 {'A', 'E', '\306'}, {'a', 'e', '\346'},
2051 {',', 'C', '\307'}, {',', 'c', '\347'},
2052 {'`', 'E', '\310'}, {'`', 'e', '\350'},
2053 {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
2054 {'^', 'E', '\312'}, {'^', 'e', '\352'},
2055 {'"', 'E', '\313'}, {'"', 'e', '\353'},
2056 {'`', 'I', '\314'}, {'`', 'i', '\354'},
2057 {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
2058 {'^', 'I', '\316'}, {'^', 'i', '\356'},
2059 {'"', 'I', '\317'}, {'"', 'i', '\357'},
2060 {'-', 'D', '\320'}, {'-', 'd', '\360'},
2061 {'~', 'N', '\321'}, {'~', 'n', '\361'},
2062 {'`', 'O', '\322'}, {'`', 'o', '\362'},
2063 {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
2064 {'^', 'O', '\324'}, {'^', 'o', '\364'},
2065 {'~', 'O', '\325'}, {'~', 'o', '\365'},
2066 {'"', 'O', '\326'}, {'"', 'o', '\366'},
2067 {'/', 'O', '\330'}, {'/', 'o', '\370'},
2068 {'`', 'U', '\331'}, {'`', 'u', '\371'},
2069 {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
2070 {'^', 'U', '\333'}, {'^', 'u', '\373'},
2071 {'"', 'U', '\334'}, {'"', 'u', '\374'},
2072 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
2073 {'T', 'H', '\336'}, {'t', 'h', '\376'},
2074 {'s', 's', '\337'}, {'"', 'y', '\377'},
2075 {'s', 'z', '\337'}, {'i', 'j', '\377'},
2076 /* iso-8859-2 uses this */
2077 {'<', 'L', '\245'}, {'<', 'l', '\265'}, /* caron */
2078 {'<', 'S', '\251'}, {'<', 's', '\271'},
2079 {'<', 'T', '\253'}, {'<', 't', '\273'},
2080 {'<', 'Z', '\256'}, {'<', 'z', '\276'},
2081 {'<', 'C', '\310'}, {'<', 'c', '\350'},
2082 {'<', 'E', '\314'}, {'<', 'e', '\354'},
2083 {'<', 'D', '\317'}, {'<', 'd', '\357'},
2084 {'<', 'N', '\322'}, {'<', 'n', '\362'},
2085 {'<', 'R', '\330'}, {'<', 'r', '\370'},
2086 {';', 'A', '\241'}, {';', 'a', '\261'}, /* ogonek */
2087 {';', 'E', '\312'}, {';', 'e', '\332'},
2088 {'\'', 'Z', '\254'}, {'\'', 'z', '\274'}, /* acute */
2089 {'\'', 'R', '\300'}, {'\'', 'r', '\340'},
2090 {'\'', 'L', '\305'}, {'\'', 'l', '\345'},
2091 {'\'', 'C', '\306'}, {'\'', 'c', '\346'},
2092 {'\'', 'N', '\321'}, {'\'', 'n', '\361'},
2093 /* collision whith S, from iso-8859-9 !!! */
2094 {',', 'S', '\252'}, {',', 's', '\272'}, /* cedilla */
2095 {',', 'T', '\336'}, {',', 't', '\376'},
2096 {'.', 'Z', '\257'}, {'.', 'z', '\277'}, /* dot above */
2097 {'/', 'L', '\243'}, {'/', 'l', '\263'}, /* slash */
2098 {'/', 'D', '\320'}, {'/', 'd', '\360'},
2099 {'(', 'A', '\303'}, {'(', 'a', '\343'}, /* breve */
2100 {'\275', 'O', '\325'}, {'\275', 'o', '\365'}, /* double acute */
2101 {'\275', 'U', '\334'}, {'\275', 'u', '\374'},
2102 {'0', 'U', '\332'}, {'0', 'u', '\372'}, /* ring above */
2103 /* iso-8859-3 uses this */
2104 {'/', 'H', '\241'}, {'/', 'h', '\261'}, /* slash */
2105 {'>', 'H', '\246'}, {'>', 'h', '\266'}, /* circumflex */
2106 {'>', 'J', '\254'}, {'>', 'j', '\274'},
2107 {'>', 'C', '\306'}, {'>', 'c', '\346'},
2108 {'>', 'G', '\330'}, {'>', 'g', '\370'},
2109 {'>', 'S', '\336'}, {'>', 's', '\376'},
2110 /* collision whith G( from iso-8859-9 !!! */
2111 {'(', 'G', '\253'}, {'(', 'g', '\273'}, /* breve */
2112 {'(', 'U', '\335'}, {'(', 'u', '\375'},
2113 /* collision whith I. from iso-8859-3 !!! */
2114 {'.', 'I', '\251'}, {'.', 'i', '\271'}, /* dot above */
2115 {'.', 'C', '\305'}, {'.', 'c', '\345'},
2116 {'.', 'G', '\325'}, {'.', 'g', '\365'},
2117 /* iso-8859-4 uses this */
2118 {',', 'R', '\243'}, {',', 'r', '\263'}, /* cedilla */
2119 {',', 'L', '\246'}, {',', 'l', '\266'},
2120 {',', 'G', '\253'}, {',', 'g', '\273'},
2121 {',', 'N', '\321'}, {',', 'n', '\361'},
2122 {',', 'K', '\323'}, {',', 'k', '\363'},
2123 {'~', 'I', '\245'}, {'~', 'i', '\265'}, /* tilde */
2124 {'-', 'E', '\252'}, {'-', 'e', '\272'}, /* macron */
2125 {'-', 'A', '\300'}, {'-', 'a', '\340'},
2126 {'-', 'I', '\317'}, {'-', 'i', '\357'},
2127 {'-', 'O', '\322'}, {'-', 'o', '\362'},
2128 {'-', 'U', '\336'}, {'-', 'u', '\376'},
2129 {'/', 'T', '\254'}, {'/', 't', '\274'}, /* slash */
2130 {'.', 'E', '\314'}, {'.', 'e', '\344'}, /* dot above */
2131 {';', 'I', '\307'}, {';', 'i', '\347'}, /* ogonek */
2132 {';', 'U', '\331'}, {';', 'u', '\371'},
2133 /* iso-8859-9 uses this */
2134 /* iso-8859-9 has really bad choosen G( S, and I. as they collide
2135 * whith the same letters on other iso-8859-x (that is they are on
2136 * different places :-( ), if you use turkish uncomment these and
2137 * comment out the lines in iso-8859-2 and iso-8859-3 sections
2138 * FIXME: should be dynamic according to chosen language
2139 * if/when Wine has turkish support.
2141 /* collision whith G( from iso-8859-3 !!! */
2142 /* {'(', 'G', '\320'}, {'(', 'g', '\360'}, */ /* breve */
2143 /* collision whith S, from iso-8859-2 !!! */
2144 /* {',', 'S', '\336'}, {',', 's', '\376'}, */ /* cedilla */
2145 /* collision whith I. from iso-8859-3 !!! */
2146 /* {'.', 'I', '\335'}, {'.', 'i', '\375'}, */ /* dot above */
2150 /***********************************************************************
2151 * MSG_DoTranslateMessage
2153 * Implementation of TranslateMessage.
2155 * TranslateMessage translates virtual-key messages into character-messages,
2156 * as follows :
2157 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
2158 * ditto replacing WM_* with WM_SYS*
2159 * This produces WM_CHAR messages only for keys mapped to ASCII characters
2160 * by the keyboard driver.
2162 static BOOL MSG_DoTranslateMessage( UINT message, HWND hwnd,
2163 WPARAM wParam, LPARAM lParam )
2165 static int dead_char;
2166 BYTE wp[2];
2168 if (message != WM_MOUSEMOVE && message != WM_TIMER)
2169 TRACE("(%s, %04X, %08lX)\n",
2170 SPY_GetMsgName(message), wParam, lParam );
2171 if(message >= WM_KEYFIRST && message <= WM_KEYLAST)
2172 TRACE_(key)("(%s, %04X, %08lX)\n",
2173 SPY_GetMsgName(message), wParam, lParam );
2175 if ((message != WM_KEYDOWN) && (message != WM_SYSKEYDOWN)) return FALSE;
2177 TRACE_(key)("Translating key %04X, scancode %04X\n",
2178 wParam, HIWORD(lParam) );
2180 /* FIXME : should handle ToAscii yielding 2 */
2181 switch (ToAscii(wParam, HIWORD(lParam),
2182 QueueKeyStateTable,(LPWORD)wp, 0))
2184 case 1 :
2185 message = (message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
2186 /* Should dead chars handling go in ToAscii ? */
2187 if (dead_char)
2189 int i;
2191 if (wp[0] == ' ') wp[0] = dead_char;
2192 if (dead_char == 0xa2) dead_char = '(';
2193 else if (dead_char == 0xa8) dead_char = '"';
2194 else if (dead_char == 0xb2) dead_char = ';';
2195 else if (dead_char == 0xb4) dead_char = '\'';
2196 else if (dead_char == 0xb7) dead_char = '<';
2197 else if (dead_char == 0xb8) dead_char = ',';
2198 else if (dead_char == 0xff) dead_char = '.';
2199 for (i = 0; i < sizeof(accent_chars)/sizeof(accent_chars[0]); i++)
2200 if ((accent_chars[i].ac_accent == dead_char) &&
2201 (accent_chars[i].ac_char == wp[0]))
2203 wp[0] = accent_chars[i].ac_result;
2204 break;
2206 dead_char = 0;
2208 TRACE_(key)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message));
2209 PostMessage16( hwnd, message, wp[0], lParam );
2210 return TRUE;
2212 case -1 :
2213 message = (message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
2214 dead_char = wp[0];
2215 TRACE_(key)("-1 -> PostMessage(%s)\n",
2216 SPY_GetMsgName(message));
2217 PostMessage16( hwnd, message, wp[0], lParam );
2218 return TRUE;
2220 return FALSE;
2224 /***********************************************************************
2225 * TranslateMessage16 (USER.113)
2227 BOOL16 WINAPI TranslateMessage16( const MSG16 *msg )
2229 return MSG_DoTranslateMessage( msg->message, msg->hwnd,
2230 msg->wParam, msg->lParam );
2234 /***********************************************************************
2235 * TranslateMessage32 (USER.821)
2237 BOOL16 WINAPI TranslateMessage32_16( const MSG32_16 *msg, BOOL16 wHaveParamHigh )
2239 WPARAM wParam;
2241 if (wHaveParamHigh)
2242 wParam = MAKELONG(msg->msg.wParam, msg->wParamHigh);
2243 else
2244 wParam = (WPARAM)msg->msg.wParam;
2246 return MSG_DoTranslateMessage( msg->msg.message, msg->msg.hwnd,
2247 wParam, msg->msg.lParam );
2250 /***********************************************************************
2251 * TranslateMessage (USER32.556)
2253 BOOL WINAPI TranslateMessage( const MSG *msg )
2255 return MSG_DoTranslateMessage( msg->message, msg->hwnd,
2256 msg->wParam, msg->lParam );
2260 /***********************************************************************
2261 * DispatchMessage16 (USER.114)
2263 LONG WINAPI DispatchMessage16( const MSG16* msg )
2265 WND * wndPtr;
2266 LONG retval;
2267 int painting;
2269 /* Process timer messages */
2270 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2272 if (msg->lParam)
2274 return CallWindowProc16( (WNDPROC16)msg->lParam, msg->hwnd,
2275 msg->message, msg->wParam, GetTickCount() );
2279 if (!msg->hwnd) return 0;
2280 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2281 if (!wndPtr->winproc)
2283 retval = 0;
2284 goto END;
2286 painting = (msg->message == WM_PAINT);
2287 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2289 SPY_EnterMessage( SPY_DISPATCHMESSAGE16, msg->hwnd, msg->message,
2290 msg->wParam, msg->lParam );
2291 retval = CallWindowProc16( (WNDPROC16)wndPtr->winproc,
2292 msg->hwnd, msg->message,
2293 msg->wParam, msg->lParam );
2294 SPY_ExitMessage( SPY_RESULT_OK16, msg->hwnd, msg->message, retval );
2296 WIN_ReleaseWndPtr(wndPtr);
2297 wndPtr = WIN_FindWndPtr(msg->hwnd);
2298 if (painting && wndPtr &&
2299 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2301 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2302 msg->hwnd);
2303 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2304 /* Validate the update region to avoid infinite WM_PAINT loop */
2305 ValidateRect( msg->hwnd, NULL );
2307 END:
2308 WIN_ReleaseWndPtr(wndPtr);
2309 return retval;
2313 /***********************************************************************
2314 * DispatchMessage32 (USER.822)
2316 LONG WINAPI DispatchMessage32_16( const MSG32_16* lpmsg16_32, BOOL16 wHaveParamHigh )
2318 if (wHaveParamHigh == FALSE)
2319 return DispatchMessage16(&(lpmsg16_32->msg));
2320 else
2322 MSG msg;
2324 msg.hwnd = lpmsg16_32->msg.hwnd;
2325 msg.message = lpmsg16_32->msg.message;
2326 msg.wParam = MAKELONG(lpmsg16_32->msg.wParam, lpmsg16_32->wParamHigh);
2327 msg.lParam = lpmsg16_32->msg.lParam;
2328 msg.time = lpmsg16_32->msg.time;
2329 msg.pt.x = (INT)lpmsg16_32->msg.pt.x;
2330 msg.pt.y = (INT)lpmsg16_32->msg.pt.y;
2331 return DispatchMessageA(&msg);
2335 /***********************************************************************
2336 * DispatchMessageA (USER32.141)
2338 LONG WINAPI DispatchMessageA( const MSG* msg )
2340 WND * wndPtr;
2341 LONG retval;
2342 int painting;
2344 /* Process timer messages */
2345 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2347 if (msg->lParam)
2349 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2350 return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
2351 msg->message, msg->wParam, GetTickCount() );
2355 if (!msg->hwnd) return 0;
2356 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2357 if (!wndPtr->winproc)
2359 retval = 0;
2360 goto END;
2362 painting = (msg->message == WM_PAINT);
2363 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2364 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2366 SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
2367 msg->wParam, msg->lParam );
2368 retval = CallWindowProcA( (WNDPROC)wndPtr->winproc,
2369 msg->hwnd, msg->message,
2370 msg->wParam, msg->lParam );
2371 SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval );
2373 WIN_ReleaseWndPtr(wndPtr);
2374 wndPtr = WIN_FindWndPtr(msg->hwnd);
2376 if (painting && wndPtr &&
2377 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2379 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2380 msg->hwnd);
2381 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2382 /* Validate the update region to avoid infinite WM_PAINT loop */
2383 PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0,
2384 RDW_FRAME | RDW_VALIDATE | RDW_NOCHILDREN | RDW_NOINTERNALPAINT, 0 );
2386 END:
2387 WIN_ReleaseWndPtr(wndPtr);
2388 return retval;
2392 /***********************************************************************
2393 * DispatchMessageW (USER32.142) Process Message
2395 * Process the message specified in the structure *_msg_.
2397 * If the lpMsg parameter points to a WM_TIMER message and the
2398 * parameter of the WM_TIMER message is not NULL, the lParam parameter
2399 * points to the function that is called instead of the window
2400 * procedure.
2402 * The message must be valid.
2404 * RETURNS
2406 * DispatchMessage() returns the result of the window procedure invoked.
2408 * CONFORMANCE
2410 * ECMA-234, Win32
2413 LONG WINAPI DispatchMessageW( const MSG* msg )
2415 WND * wndPtr;
2416 LONG retval;
2417 int painting;
2419 /* Process timer messages */
2420 if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
2422 if (msg->lParam)
2424 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2425 return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd,
2426 msg->message, msg->wParam, GetTickCount() );
2430 if (!msg->hwnd) return 0;
2431 if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
2432 if (!wndPtr->winproc)
2434 retval = 0;
2435 goto END;
2437 painting = (msg->message == WM_PAINT);
2438 if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
2439 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2441 SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message,
2442 msg->wParam, msg->lParam );
2443 retval = CallWindowProcW( (WNDPROC)wndPtr->winproc,
2444 msg->hwnd, msg->message,
2445 msg->wParam, msg->lParam );
2446 SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval );
2448 WIN_ReleaseWndPtr(wndPtr);
2449 wndPtr = WIN_FindWndPtr(msg->hwnd);
2451 if (painting && wndPtr &&
2452 (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
2454 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2455 msg->hwnd);
2456 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
2457 /* Validate the update region to avoid infinite WM_PAINT loop */
2458 ValidateRect( msg->hwnd, NULL );
2460 END:
2461 WIN_ReleaseWndPtr(wndPtr);
2462 return retval;
2466 /***********************************************************************
2467 * RegisterWindowMessageA (USER.118) (USER32.437)
2469 WORD WINAPI RegisterWindowMessageA( LPCSTR str )
2471 TRACE("%s\n", str );
2472 return GlobalAddAtomA( str );
2476 /***********************************************************************
2477 * RegisterWindowMessageW (USER32.438)
2479 WORD WINAPI RegisterWindowMessageW( LPCWSTR str )
2481 TRACE("%p\n", str );
2482 return GlobalAddAtomW( str );
2486 /***********************************************************************
2487 * GetCurrentTime16 (USER.15)
2489 * (effectively identical to GetTickCount)
2491 DWORD WINAPI GetCurrentTime16(void)
2493 return GetTickCount();
2497 /***********************************************************************
2498 * InSendMessage16 (USER.192)
2500 BOOL16 WINAPI InSendMessage16(void)
2502 return InSendMessage();
2506 /***********************************************************************
2507 * InSendMessage (USER32.320)
2509 BOOL WINAPI InSendMessage(void)
2511 MESSAGEQUEUE *queue;
2512 BOOL ret;
2514 if (!(queue = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
2515 return 0;
2516 ret = (BOOL)queue->smWaiting;
2518 QUEUE_Unlock( queue );
2519 return ret;
2522 /***********************************************************************
2523 * BroadcastSystemMessage (USER32.12)
2525 LONG WINAPI BroadcastSystemMessage(
2526 DWORD dwFlags,LPDWORD recipients,UINT uMessage,WPARAM wParam,
2527 LPARAM lParam
2529 FIXME_(sendmsg)("(%08lx,%08lx,%08x,%08x,%08lx): stub!\n",
2530 dwFlags,*recipients,uMessage,wParam,lParam
2532 return 0;
2535 /***********************************************************************
2536 * SendNotifyMessageA (USER32.460)
2537 * FIXME
2538 * The message sended with PostMessage has to be put in the queue
2539 * with a higher priority as the other "Posted" messages.
2540 * QUEUE_AddMsg has to be modifyed.
2542 BOOL WINAPI SendNotifyMessageA(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
2543 { BOOL ret = TRUE;
2544 FIXME("(%04x,%08x,%08x,%08lx) not complete\n",
2545 hwnd, msg, wParam, lParam);
2547 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL))
2548 { ret=SendMessageA ( hwnd, msg, wParam, lParam );
2550 else
2551 { PostMessageA ( hwnd, msg, wParam, lParam );
2553 return ret;
2556 /***********************************************************************
2557 * SendNotifyMessageW (USER32.461)
2558 * FIXME
2559 * The message sended with PostMessage has to be put in the queue
2560 * with a higher priority as the other "Posted" messages.
2561 * QUEUE_AddMsg has to be modifyed.
2563 BOOL WINAPI SendNotifyMessageW(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
2564 { BOOL ret = TRUE;
2565 FIXME("(%04x,%08x,%08x,%08lx) not complete\n",
2566 hwnd, msg, wParam, lParam);
2568 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd, NULL))
2569 { ret=SendMessageW ( hwnd, msg, wParam, lParam );
2571 else
2572 { PostMessageW ( hwnd, msg, wParam, lParam );
2574 return ret;
2577 /***********************************************************************
2578 * SendMessageCallbackA
2579 * FIXME: It's like PostMessage. The callback gets called when the message
2580 * is processed. We have to modify the message processing for a exact
2581 * implementation...
2583 BOOL WINAPI SendMessageCallbackA(
2584 HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam,
2585 FARPROC lpResultCallBack,DWORD dwData)
2587 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2588 hWnd,Msg,wParam,lParam,lpResultCallBack,dwData);
2589 if ( hWnd == HWND_BROADCAST)
2590 { PostMessageA( hWnd, Msg, wParam, lParam);
2591 FIXME("Broadcast: Callback will not be called!\n");
2592 return TRUE;
2594 (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam ));
2595 return TRUE;
2597 /***********************************************************************
2598 * SendMessageCallbackW
2599 * FIXME: It's like PostMessage. The callback gets called when the message
2600 * is processed. We have to modify the message processing for a exact
2601 * implementation...
2603 BOOL WINAPI SendMessageCallbackW(
2604 HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam,
2605 FARPROC lpResultCallBack,DWORD dwData)
2607 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2608 hWnd,Msg,wParam,lParam,lpResultCallBack,dwData);
2609 if ( hWnd == HWND_BROADCAST)
2610 { PostMessageW( hWnd, Msg, wParam, lParam);
2611 FIXME("Broadcast: Callback will not be called!\n");
2612 return TRUE;
2614 (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam ));
2615 return TRUE;