2 * Message queues related functions
4 * Copyright 1993, 1994 Alexandre Julliard
11 #include <sys/types.h>
16 #include "sysmetrics.h"
33 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
34 #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
36 typedef enum { SYSQ_MSG_ABANDON
, SYSQ_MSG_SKIP
,
37 SYSQ_MSG_ACCEPT
, SYSQ_MSG_CONTINUE
} SYSQ_STATUS
;
39 extern MESSAGEQUEUE
*pCursorQueue
; /* queue.c */
40 extern MESSAGEQUEUE
*pActiveQueue
;
42 DWORD MSG_WineStartTicks
; /* Ticks at Wine startup */
44 static UINT32 doubleClickSpeed
= 452;
45 static INT32 debugSMRL
= 0; /* intertask SendMessage() recursion level */
47 /***********************************************************************
50 BOOL32
MSG_CheckFilter(WORD uMsg
, DWORD filter
)
53 return (uMsg
>= LOWORD(filter
) && uMsg
<= HIWORD(filter
));
57 /***********************************************************************
58 * MSG_SendParentNotify
60 * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
61 * the window has the WS_EX_NOPARENTNOTIFY style.
63 static void MSG_SendParentNotify(WND
* wndPtr
, WORD event
, WORD idChild
, LPARAM lValue
)
65 #define lppt ((LPPOINT16)&lValue)
67 /* pt has to be in the client coordinates of the parent window */
69 MapWindowPoints16( 0, wndPtr
->hwndSelf
, lppt
, 1 );
72 if (!(wndPtr
->dwStyle
& WS_CHILD
) || (wndPtr
->dwExStyle
& WS_EX_NOPARENTNOTIFY
)) break;
73 lppt
->x
+= wndPtr
->rectClient
.left
;
74 lppt
->y
+= wndPtr
->rectClient
.top
;
75 wndPtr
= wndPtr
->parent
;
76 SendMessage32A( wndPtr
->hwndSelf
, WM_PARENTNOTIFY
,
77 MAKEWPARAM( event
, idChild
), lValue
);
83 /***********************************************************************
84 * MSG_TranslateMouseMsg
86 * Translate an mouse hardware event into a real mouse message.
87 * Return value indicates whether the translated message must be passed
88 * to the user, left in the queue, or skipped entirely (in this case
89 * HIWORD contains hit test code).
91 static DWORD
MSG_TranslateMouseMsg( HWND16 hTopWnd
, DWORD filter
,
92 MSG16
*msg
, BOOL32 remove
, WND
* pWndScope
)
94 static DWORD dblclk_time_limit
= 0;
95 static UINT16 clk_message
= 0;
96 static HWND16 clk_hwnd
= 0;
97 static POINT16 clk_pos
= { 0, 0 };
101 INT16 ht
, hittest
, sendSC
= 0;
102 UINT16 message
= msg
->message
;
103 POINT16 screen_pt
, pt
;
104 HANDLE16 hQ
= GetTaskQueue(0);
105 MESSAGEQUEUE
*queue
= (MESSAGEQUEUE
*)GlobalLock16(hQ
);
106 BOOL32 eatMsg
= FALSE
;
107 BOOL32 mouseClick
= ((message
== WM_LBUTTONDOWN
) ||
108 (message
== WM_RBUTTONDOWN
) ||
109 (message
== WM_MBUTTONDOWN
))?1:0;
112 /* Find the window */
114 ht
= hittest
= HTCLIENT
;
115 hWnd
= GetCapture16();
118 ht
= hittest
= WINPOS_WindowFromPoint( pWndScope
, msg
->pt
, &pWnd
);
119 if( !pWnd
) pWnd
= WIN_GetDesktop();
120 hWnd
= pWnd
->hwndSelf
;
125 pWnd
= WIN_FindWndPtr(hWnd
);
126 ht
= EVENT_GetCaptureInfo();
129 /* stop if not the right queue */
131 if (pWnd
->hmemTaskQ
!= hQ
)
133 /* Not for the current task */
134 if (queue
) QUEUE_ClearWakeBit( queue
, QS_MOUSE
);
135 /* Wake up the other task */
136 queue
= (MESSAGEQUEUE
*)GlobalLock16( pWnd
->hmemTaskQ
);
137 if (queue
) QUEUE_SetWakeBit( queue
, QS_MOUSE
);
138 return SYSQ_MSG_ABANDON
;
141 /* check if hWnd is within hWndScope */
143 if( hTopWnd
&& hWnd
!= hTopWnd
)
144 if( !IsChild16(hTopWnd
, hWnd
) ) return SYSQ_MSG_CONTINUE
;
148 /* translate double clicks -
149 * note that ...MOUSEMOVEs can slip in between
150 * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
152 if( pWnd
->class->style
& CS_DBLCLKS
|| ht
!= HTCLIENT
)
154 if ((message
== clk_message
) && (hWnd
== clk_hwnd
) &&
155 (msg
->time
- dblclk_time_limit
< doubleClickSpeed
) &&
156 (abs(msg
->pt
.x
- clk_pos
.x
) < SYSMETRICS_CXDOUBLECLK
/2) &&
157 (abs(msg
->pt
.y
- clk_pos
.y
) < SYSMETRICS_CYDOUBLECLK
/2))
159 message
+= (WM_LBUTTONDBLCLK
- WM_LBUTTONDOWN
);
160 mouseClick
++; /* == 2 */
164 screen_pt
= pt
= msg
->pt
;
166 if (hittest
!= HTCLIENT
)
168 message
+= ((INT16
)WM_NCMOUSEMOVE
- WM_MOUSEMOVE
);
169 msg
->wParam
= hittest
;
171 else ScreenToClient16( hWnd
, &pt
);
173 /* check message filter */
175 if (!MSG_CheckFilter(message
, filter
)) return SYSQ_MSG_CONTINUE
;
177 pCursorQueue
= queue
;
181 if (HOOK_IsHooked( WH_MOUSE
))
183 MOUSEHOOKSTRUCT16
*hook
= SEGPTR_NEW(MOUSEHOOKSTRUCT16
);
186 hook
->pt
= screen_pt
;
188 hook
->wHitTestCode
= hittest
;
189 hook
->dwExtraInfo
= 0;
190 ret
= HOOK_CallHooks16( WH_MOUSE
, remove
? HC_ACTION
: HC_NOREMOVE
,
191 message
, (LPARAM
)SEGPTR_GET(hook
) );
194 if( ret
) return MAKELONG((INT16
)SYSQ_MSG_SKIP
, hittest
);
197 if ((hittest
== HTERROR
) || (hittest
== HTNOWHERE
))
199 else if( remove
&& mouseClick
)
201 HWND32 hwndTop
= WIN_GetTopParent( hWnd
);
203 if( mouseClick
== 1 )
206 dblclk_time_limit
= msg
->time
;
207 clk_message
= msg
->message
;
211 /* got double click - zero them out */
212 dblclk_time_limit
= clk_hwnd
= 0;
216 /* Send the WM_PARENTNOTIFY,
217 * note that even for double/nonclient clicks
218 * notification message is still WM_L/M/RBUTTONDOWN.
221 MSG_SendParentNotify( pWnd
, msg
->message
, 0, MAKELPARAM(screen_pt
.x
, screen_pt
.y
) );
223 /* Activate the window if needed */
225 if (hWnd
!= GetActiveWindow16() && hWnd
!= GetDesktopWindow16())
227 LONG ret
= SendMessage16( hWnd
, WM_MOUSEACTIVATE
, hwndTop
,
228 MAKELONG( hittest
, message
) );
230 if ((ret
== MA_ACTIVATEANDEAT
) || (ret
== MA_NOACTIVATEANDEAT
))
233 if (((ret
== MA_ACTIVATE
) || (ret
== MA_ACTIVATEANDEAT
))
234 && hwndTop
!= GetActiveWindow16() )
235 if (!WINPOS_SetActiveWindow( hwndTop
, TRUE
, TRUE
))
239 } else sendSC
= (remove
&& sendSC
);
241 /* Send the WM_SETCURSOR message */
244 SendMessage16( hWnd
, WM_SETCURSOR
, (WPARAM16
)hWnd
,
245 MAKELONG( hittest
, message
));
246 if (eatMsg
) return MAKELONG( (UINT16
)SYSQ_MSG_SKIP
, hittest
);
249 msg
->message
= message
;
250 msg
->lParam
= MAKELONG( pt
.x
, pt
.y
);
251 return SYSQ_MSG_ACCEPT
;
255 /***********************************************************************
256 * MSG_TranslateKbdMsg
258 * Translate an keyboard hardware event into a real message.
260 static DWORD
MSG_TranslateKbdMsg( HWND16 hTopWnd
, DWORD filter
,
261 MSG16
*msg
, BOOL32 remove
)
263 WORD message
= msg
->message
;
264 HWND16 hWnd
= GetFocus16();
267 /* Should check Ctrl-Esc and PrintScreen here */
271 /* Send the message to the active window instead, */
272 /* translating messages to their WM_SYS equivalent */
274 hWnd
= GetActiveWindow16();
276 if( message
< WM_SYSKEYDOWN
)
277 message
+= WM_SYSKEYDOWN
- WM_KEYDOWN
;
279 pWnd
= WIN_FindWndPtr( hWnd
);
280 if (pWnd
&& (pWnd
->hmemTaskQ
!= GetTaskQueue(0)))
282 /* Not for the current task */
283 MESSAGEQUEUE
*queue
= (MESSAGEQUEUE
*)GlobalLock16( GetTaskQueue(0) );
284 if (queue
) QUEUE_ClearWakeBit( queue
, QS_KEY
);
285 /* Wake up the other task */
286 queue
= (MESSAGEQUEUE
*)GlobalLock16( pWnd
->hmemTaskQ
);
287 if (queue
) QUEUE_SetWakeBit( queue
, QS_KEY
);
288 return SYSQ_MSG_ABANDON
;
291 if (hTopWnd
&& hWnd
!= hTopWnd
)
292 if (!IsChild16(hTopWnd
, hWnd
)) return SYSQ_MSG_CONTINUE
;
293 if (!MSG_CheckFilter(message
, filter
)) return SYSQ_MSG_CONTINUE
;
296 msg
->message
= message
;
298 return (HOOK_CallHooks16( WH_KEYBOARD
, remove
? HC_ACTION
: HC_NOREMOVE
,
299 msg
->wParam
, msg
->lParam
)
300 ? SYSQ_MSG_SKIP
: SYSQ_MSG_ACCEPT
);
304 /***********************************************************************
305 * MSG_JournalRecordMsg
307 * Build an EVENTMSG structure and call JOURNALRECORD hook
309 static void MSG_JournalRecordMsg( MSG16
*msg
)
311 EVENTMSG16
*event
= SEGPTR_NEW(EVENTMSG16
);
313 event
->message
= msg
->message
;
314 event
->time
= msg
->time
;
315 if ((msg
->message
>= WM_KEYFIRST
) && (msg
->message
<= WM_KEYLAST
))
317 event
->paramL
= (msg
->wParam
& 0xFF) | (HIWORD(msg
->lParam
) << 8);
318 event
->paramH
= msg
->lParam
& 0x7FFF;
319 if (HIWORD(msg
->lParam
) & 0x0100)
320 event
->paramH
|= 0x8000; /* special_key - bit */
321 HOOK_CallHooks16( WH_JOURNALRECORD
, HC_ACTION
, 0,
322 (LPARAM
)SEGPTR_GET(event
) );
324 else if ((msg
->message
>= WM_MOUSEFIRST
) && (msg
->message
<= WM_MOUSELAST
))
326 event
->paramL
= LOWORD(msg
->lParam
); /* X pos */
327 event
->paramH
= HIWORD(msg
->lParam
); /* Y pos */
328 ClientToScreen16( msg
->hwnd
, (LPPOINT16
)&event
->paramL
);
329 HOOK_CallHooks16( WH_JOURNALRECORD
, HC_ACTION
, 0,
330 (LPARAM
)SEGPTR_GET(event
) );
332 else if ((msg
->message
>= WM_NCMOUSEFIRST
) &&
333 (msg
->message
<= WM_NCMOUSELAST
))
335 event
->paramL
= LOWORD(msg
->lParam
); /* X pos */
336 event
->paramH
= HIWORD(msg
->lParam
); /* Y pos */
337 event
->message
+= WM_MOUSEMOVE
-WM_NCMOUSEMOVE
;/* give no info about NC area */
338 HOOK_CallHooks16( WH_JOURNALRECORD
, HC_ACTION
, 0,
339 (LPARAM
)SEGPTR_GET(event
) );
344 /***********************************************************************
345 * MSG_JournalPlayBackMsg
347 * Get an EVENTMSG struct via call JOURNALPLAYBACK hook function
349 static int MSG_JournalPlayBackMsg(void)
353 WORD keyDown
,i
,wParam
,result
=0;
355 if ( HOOK_IsHooked( WH_JOURNALPLAYBACK
) )
357 tmpMsg
= SEGPTR_NEW(EVENTMSG16
);
358 wtime
=HOOK_CallHooks16( WH_JOURNALPLAYBACK
, HC_GETNEXT
, 0,
359 (LPARAM
)SEGPTR_GET(tmpMsg
));
360 /* TRACE(msg,"Playback wait time =%ld\n",wtime); */
364 if ((tmpMsg
->message
>= WM_KEYFIRST
) && (tmpMsg
->message
<= WM_KEYLAST
))
366 wParam
=tmpMsg
->paramL
& 0xFF;
367 lParam
=MAKELONG(tmpMsg
->paramH
&0x7ffff,tmpMsg
->paramL
>>8);
368 if (tmpMsg
->message
== WM_KEYDOWN
|| tmpMsg
->message
== WM_SYSKEYDOWN
)
370 for (keyDown
=i
=0; i
<256 && !keyDown
; i
++)
371 if (InputKeyStateTable
[i
] & 0x80)
374 lParam
|= 0x40000000;
375 AsyncKeyStateTable
[wParam
]=InputKeyStateTable
[wParam
] |= 0x80;
377 else /* WM_KEYUP, WM_SYSKEYUP */
379 lParam
|= 0xC0000000;
380 AsyncKeyStateTable
[wParam
]=InputKeyStateTable
[wParam
] &= ~0x80;
382 if (InputKeyStateTable
[VK_MENU
] & 0x80)
383 lParam
|= 0x20000000;
384 if (tmpMsg
->paramH
& 0x8000) /*special_key bit*/
385 lParam
|= 0x01000000;
386 hardware_event( tmpMsg
->message
, wParam
, lParam
,0, 0, tmpMsg
->time
, 0 );
390 if ((tmpMsg
->message
>= WM_MOUSEFIRST
) && (tmpMsg
->message
<= WM_MOUSELAST
))
392 switch (tmpMsg
->message
)
395 MouseButtonsStates
[0]=AsyncMouseButtonsStates
[0]=TRUE
;break;
397 MouseButtonsStates
[0]=AsyncMouseButtonsStates
[0]=FALSE
;break;
399 MouseButtonsStates
[1]=AsyncMouseButtonsStates
[1]=TRUE
;break;
401 MouseButtonsStates
[1]=AsyncMouseButtonsStates
[1]=FALSE
;break;
403 MouseButtonsStates
[2]=AsyncMouseButtonsStates
[2]=TRUE
;break;
405 MouseButtonsStates
[2]=AsyncMouseButtonsStates
[2]=FALSE
;break;
407 AsyncKeyStateTable
[VK_LBUTTON
]= InputKeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0] ? 0x80 : 0;
408 AsyncKeyStateTable
[VK_MBUTTON
]= InputKeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1] ? 0x80 : 0;
409 AsyncKeyStateTable
[VK_RBUTTON
]= InputKeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2] ? 0x80 : 0;
410 SetCursorPos32(tmpMsg
->paramL
,tmpMsg
->paramH
);
411 lParam
=MAKELONG(tmpMsg
->paramL
,tmpMsg
->paramH
);
413 if (MouseButtonsStates
[0]) wParam
|= MK_LBUTTON
;
414 if (MouseButtonsStates
[1]) wParam
|= MK_MBUTTON
;
415 if (MouseButtonsStates
[2]) wParam
|= MK_RBUTTON
;
416 hardware_event( tmpMsg
->message
, wParam
, lParam
,
417 tmpMsg
->paramL
, tmpMsg
->paramH
, tmpMsg
->time
, 0 );
420 HOOK_CallHooks16( WH_JOURNALPLAYBACK
, HC_SKIP
, 0,
421 (LPARAM
)SEGPTR_GET(tmpMsg
));
425 if( tmpMsg
->message
== WM_QUEUESYNC
)
426 if (HOOK_IsHooked( WH_CBT
))
427 HOOK_CallHooks16( WH_CBT
, HCBT_QS
, 0, 0L);
429 result
= QS_MOUSE
| QS_KEY
; /* ? */
436 /***********************************************************************
437 * MSG_PeekHardwareMsg
439 * Peek for a hardware message matching the hwnd and message filters.
441 static BOOL32
MSG_PeekHardwareMsg( MSG16
*msg
, HWND16 hwnd
, DWORD filter
,
444 DWORD status
= SYSQ_MSG_ACCEPT
;
445 MESSAGEQUEUE
*sysMsgQueue
= QUEUE_GetSysQueue();
446 int i
, kbd_msg
, pos
= sysMsgQueue
->nextMessage
;
448 /* FIXME: there has to be a better way to do this */
451 /* If the queue is empty, attempt to fill it */
452 if (!sysMsgQueue
->msgCount
&& THREAD_IsWin16( THREAD_Current() )
453 && TSXPending(display
))
454 EVENT_WaitNetEvent( FALSE
, FALSE
);
456 for (i
= kbd_msg
= 0; i
< sysMsgQueue
->msgCount
; i
++, pos
++)
458 if (pos
>= sysMsgQueue
->queueSize
) pos
= 0;
459 *msg
= sysMsgQueue
->messages
[pos
].msg
;
461 /* Translate message */
463 if ((msg
->message
>= WM_MOUSEFIRST
) && (msg
->message
<= WM_MOUSELAST
))
465 HWND32 hWndScope
= (HWND32
)sysMsgQueue
->messages
[pos
].extraInfo
;
467 status
= MSG_TranslateMouseMsg(hwnd
, filter
, msg
, remove
,
468 (Options
.managed
&& IsWindow32(hWndScope
) )
469 ? WIN_FindWndPtr(hWndScope
) : WIN_GetDesktop() );
472 else if ((msg
->message
>= WM_KEYFIRST
) && (msg
->message
<= WM_KEYLAST
))
474 status
= MSG_TranslateKbdMsg(hwnd
, filter
, msg
, remove
);
477 else /* Non-standard hardware event */
479 HARDWAREHOOKSTRUCT16
*hook
;
480 if ((hook
= SEGPTR_NEW(HARDWAREHOOKSTRUCT16
)))
483 hook
->hWnd
= msg
->hwnd
;
484 hook
->wMessage
= msg
->message
;
485 hook
->wParam
= msg
->wParam
;
486 hook
->lParam
= msg
->lParam
;
487 ret
= HOOK_CallHooks16( WH_HARDWARE
,
488 remove
? HC_ACTION
: HC_NOREMOVE
,
489 0, (LPARAM
)SEGPTR_GET(hook
) );
493 QUEUE_RemoveMsg( sysMsgQueue
, pos
);
496 status
= SYSQ_MSG_ACCEPT
;
500 switch (LOWORD(status
))
502 case SYSQ_MSG_ACCEPT
:
506 if (HOOK_IsHooked( WH_CBT
))
509 HOOK_CallHooks16( WH_CBT
, HCBT_KEYSKIPPED
,
510 msg
->wParam
, msg
->lParam
);
513 MOUSEHOOKSTRUCT16
*hook
= SEGPTR_NEW(MOUSEHOOKSTRUCT16
);
517 hook
->hwnd
= msg
->hwnd
;
518 hook
->wHitTestCode
= HIWORD(status
);
519 hook
->dwExtraInfo
= 0;
520 HOOK_CallHooks16( WH_CBT
, HCBT_CLICKSKIPPED
,msg
->message
,
521 (LPARAM
)SEGPTR_GET(hook
) );
528 QUEUE_RemoveMsg( sysMsgQueue
, pos
);
531 case SYSQ_MSG_CONTINUE
:
534 case SYSQ_MSG_ABANDON
:
540 if (HOOK_IsHooked( WH_JOURNALRECORD
)) MSG_JournalRecordMsg( msg
);
541 QUEUE_RemoveMsg( sysMsgQueue
, pos
);
549 /**********************************************************************
550 * SetDoubleClickTime16 (USER.20)
552 void WINAPI
SetDoubleClickTime16( UINT16 interval
)
554 SetDoubleClickTime32( interval
);
558 /**********************************************************************
559 * SetDoubleClickTime32 (USER32.480)
561 BOOL32 WINAPI
SetDoubleClickTime32( UINT32 interval
)
563 doubleClickSpeed
= interval
? interval
: 500;
568 /**********************************************************************
569 * GetDoubleClickTime16 (USER.21)
571 UINT16 WINAPI
GetDoubleClickTime16(void)
573 return doubleClickSpeed
;
577 /**********************************************************************
578 * GetDoubleClickTime32 (USER32.239)
580 UINT32 WINAPI
GetDoubleClickTime32(void)
582 return doubleClickSpeed
;
586 /***********************************************************************
589 * Implementation of an inter-task SendMessage.
591 static LRESULT
MSG_SendMessage( HQUEUE16 hDestQueue
, HWND16 hwnd
, UINT16 msg
,
592 WPARAM32 wParam
, LPARAM lParam
, WORD flags
)
594 INT32 prevSMRL
= debugSMRL
;
595 QSMCTRL qCtrl
= { 0, 1};
596 MESSAGEQUEUE
*queue
, *destQ
;
598 if (!(queue
= (MESSAGEQUEUE
*)GlobalLock16( GetTaskQueue(0) ))) return 0;
599 if (!(destQ
= (MESSAGEQUEUE
*)GlobalLock16( hDestQueue
))) return 0;
601 if (IsTaskLocked() || !IsWindow32(hwnd
)) return 0;
604 TRACE(sendmsg
,"%*sSM: %s [%04x] (%04x -> %04x)\n",
605 prevSMRL
, "", SPY_GetMsgName(msg
), msg
, queue
->self
, hDestQueue
);
607 if( !(queue
->wakeBits
& QS_SMPARAMSFREE
) )
609 TRACE(sendmsg
,"\tIntertask SendMessage: sleeping since unreplied SendMessage pending\n");
610 queue
->changeBits
&= ~QS_SMPARAMSFREE
;
611 QUEUE_WaitBits( QS_SMPARAMSFREE
);
618 queue
->wParam
= LOWORD(wParam
);
619 queue
->wParamHigh
= HIWORD(wParam
);
620 queue
->lParam
= lParam
;
621 queue
->hPrevSendingTask
= destQ
->hSendingTask
;
622 destQ
->hSendingTask
= GetTaskQueue(0);
624 queue
->wakeBits
&= ~QS_SMPARAMSFREE
;
625 queue
->flags
= (queue
->flags
& ~(QUEUE_SM_WIN32
|QUEUE_SM_UNICODE
)) | flags
;
627 TRACE(sendmsg
,"%*ssm: smResultInit = %08x\n", prevSMRL
, "", (unsigned)&qCtrl
);
629 queue
->smResultInit
= &qCtrl
;
631 QUEUE_SetWakeBit( destQ
, QS_SENDMESSAGE
);
633 /* perform task switch and wait for the result */
635 while( qCtrl
.bPending
)
637 if (!(queue
->wakeBits
& QS_SMRESULT
))
639 queue
->changeBits
&= ~QS_SMRESULT
;
640 if (THREAD_IsWin16( THREAD_Current() ))
641 DirectedYield( destQ
->hTask
);
643 QUEUE_Signal( destQ
->hTask
);
644 QUEUE_WaitBits( QS_SMRESULT
);
645 TRACE(sendmsg
,"\tsm: have result!\n");
649 TRACE(sendmsg
,"%*ssm: smResult = %08x\n", prevSMRL
, "", (unsigned)queue
->smResult
);
651 if (queue
->smResult
) { /* FIXME, smResult should always be set */
652 queue
->smResult
->lResult
= queue
->SendMessageReturn
;
653 queue
->smResult
->bPending
= FALSE
;
655 queue
->wakeBits
&= ~QS_SMRESULT
;
657 if( queue
->smResult
!= &qCtrl
)
658 ERR(sendmsg
, "%*ssm: weird scenes inside the goldmine!\n", prevSMRL
, "");
660 queue
->smResultInit
= NULL
;
662 TRACE(sendmsg
,"%*sSM: [%04x] returning %08lx\n", prevSMRL
, "", msg
, qCtrl
.lResult
);
665 return qCtrl
.lResult
;
669 /***********************************************************************
670 * ReplyMessage16 (USER.115)
672 void WINAPI
ReplyMessage16( LRESULT result
)
674 MESSAGEQUEUE
*senderQ
;
677 if (!(queue
= (MESSAGEQUEUE
*)GlobalLock16( GetTaskQueue(0) ))) return;
679 TRACE(msg
,"ReplyMessage, queue %04x\n", queue
->self
);
681 while( (senderQ
= (MESSAGEQUEUE
*)GlobalLock16( queue
->InSendMessageHandle
)))
683 TRACE(msg
,"\trpm: replying to %04x (%04x -> %04x)\n",
684 queue
->msg
, queue
->self
, senderQ
->self
);
686 if( queue
->wakeBits
& QS_SENDMESSAGE
)
688 QUEUE_ReceiveMessage( queue
);
689 continue; /* ReceiveMessage() already called us */
692 if(!(senderQ
->wakeBits
& QS_SMRESULT
) ) break;
693 if (THREAD_IsWin16(THREAD_Current())) OldYield();
695 if( !senderQ
) { TRACE(msg
,"\trpm: done\n"); return; }
697 senderQ
->SendMessageReturn
= result
;
698 TRACE(msg
,"\trpm: smResult = %08x, result = %08lx\n",
699 (unsigned)queue
->smResultCurrent
, result
);
701 senderQ
->smResult
= queue
->smResultCurrent
;
702 queue
->InSendMessageHandle
= 0;
704 QUEUE_SetWakeBit( senderQ
, QS_SMRESULT
);
705 if (THREAD_IsWin16(THREAD_Current())) DirectedYield( queue
->hSendingTask
);
709 /***********************************************************************
712 static BOOL32
MSG_PeekMessage( LPMSG16 msg
, HWND16 hwnd
, WORD first
, WORD last
,
713 WORD flags
, BOOL32 peek
)
716 MESSAGEQUEUE
*msgQueue
;
720 DDE_TestDDE(hwnd
); /* do we have dde handling in the window ?*/
721 DDE_GetRemoteMessage();
722 #endif /* CONFIG_IPC */
724 mask
= QS_POSTMESSAGE
| QS_SENDMESSAGE
; /* Always selected */
727 if ((first
<= WM_KEYLAST
) && (last
>= WM_KEYFIRST
)) mask
|= QS_KEY
;
728 if ( ((first
<= WM_MOUSELAST
) && (last
>= WM_MOUSEFIRST
)) ||
729 ((first
<= WM_NCMOUSELAST
) && (last
>= WM_NCMOUSEFIRST
)) ) mask
|= QS_MOUSE
;
730 if ((first
<= WM_TIMER
) && (last
>= WM_TIMER
)) mask
|= QS_TIMER
;
731 if ((first
<= WM_SYSTIMER
) && (last
>= WM_SYSTIMER
)) mask
|= QS_TIMER
;
732 if ((first
<= WM_PAINT
) && (last
>= WM_PAINT
)) mask
|= QS_PAINT
;
734 else mask
|= QS_MOUSE
| QS_KEY
| QS_TIMER
| QS_PAINT
;
736 if (IsTaskLocked()) flags
|= PM_NOYIELD
;
738 /* Never yield on Win32 threads */
739 if (!THREAD_IsWin16(THREAD_Current())) flags
|= PM_NOYIELD
;
743 hQueue
= GetTaskQueue(0);
744 msgQueue
= (MESSAGEQUEUE
*)GlobalLock16( hQueue
);
745 if (!msgQueue
) return FALSE
;
746 msgQueue
->changeBits
= 0;
748 /* First handle a message put by SendMessage() */
750 while (msgQueue
->wakeBits
& QS_SENDMESSAGE
)
751 QUEUE_ReceiveMessage( msgQueue
);
753 /* Now handle a WM_QUIT message */
755 if (msgQueue
->wPostQMsg
&&
756 (!first
|| WM_QUIT
>= first
) &&
757 (!last
|| WM_QUIT
<= last
) )
760 msg
->message
= WM_QUIT
;
761 msg
->wParam
= msgQueue
->wExitCode
;
763 if (flags
& PM_REMOVE
) msgQueue
->wPostQMsg
= 0;
767 /* Now find a normal message */
769 if (((msgQueue
->wakeBits
& mask
) & QS_POSTMESSAGE
) &&
770 ((pos
= QUEUE_FindMsg( msgQueue
, hwnd
, first
, last
)) != -1))
772 QMSG
*qmsg
= &msgQueue
->messages
[pos
];
774 msgQueue
->GetMessageTimeVal
= msg
->time
;
775 msgQueue
->GetMessagePosVal
= *(DWORD
*)&msg
->pt
;
776 msgQueue
->GetMessageExtraInfoVal
= qmsg
->extraInfo
;
778 if (flags
& PM_REMOVE
) QUEUE_RemoveMsg( msgQueue
, pos
);
782 msgQueue
->changeBits
|= MSG_JournalPlayBackMsg();
784 /* Now find a hardware event */
786 if (((msgQueue
->wakeBits
& mask
) & (QS_MOUSE
| QS_KEY
)) &&
787 MSG_PeekHardwareMsg( msg
, hwnd
, MAKELONG(first
,last
), flags
& PM_REMOVE
))
790 msgQueue
->GetMessageTimeVal
= msg
->time
;
791 msgQueue
->GetMessagePosVal
= *(DWORD
*)&msg
->pt
;
792 msgQueue
->GetMessageExtraInfoVal
= 0; /* Always 0 for now */
796 /* Check again for SendMessage */
798 while (msgQueue
->wakeBits
& QS_SENDMESSAGE
)
799 QUEUE_ReceiveMessage( msgQueue
);
801 /* Now find a WM_PAINT message */
803 if ((msgQueue
->wakeBits
& mask
) & QS_PAINT
)
806 msg
->hwnd
= WIN_FindWinToRepaint( hwnd
, hQueue
);
807 msg
->message
= WM_PAINT
;
811 if ((wndPtr
= WIN_FindWndPtr(msg
->hwnd
)))
813 if( wndPtr
->dwStyle
& WS_MINIMIZE
&&
814 wndPtr
->class->hIcon
)
816 msg
->message
= WM_PAINTICON
;
820 if( !hwnd
|| msg
->hwnd
== hwnd
|| IsChild16(hwnd
,msg
->hwnd
) )
822 if( wndPtr
->flags
& WIN_INTERNAL_PAINT
&& !wndPtr
->hrgnUpdate
)
824 wndPtr
->flags
&= ~WIN_INTERNAL_PAINT
;
825 QUEUE_DecPaintCount( hQueue
);
832 /* Check for timer messages, but yield first */
834 if (!(flags
& PM_NOYIELD
))
837 while (msgQueue
->wakeBits
& QS_SENDMESSAGE
)
838 QUEUE_ReceiveMessage( msgQueue
);
840 if ((msgQueue
->wakeBits
& mask
) & QS_TIMER
)
842 if (TIMER_GetTimerMsg(msg
, hwnd
, hQueue
, flags
& PM_REMOVE
)) break;
847 if (!(flags
& PM_NOYIELD
)) UserYield();
850 msgQueue
->wakeMask
= mask
;
851 QUEUE_WaitBits( mask
);
854 /* We got a message */
855 if (flags
& PM_REMOVE
)
857 WORD message
= msg
->message
;
859 if (message
== WM_KEYDOWN
|| message
== WM_SYSKEYDOWN
)
861 BYTE
*p
= &QueueKeyStateTable
[msg
->wParam
& 0xff];
867 else if (message
== WM_KEYUP
|| message
== WM_SYSKEYUP
)
868 QueueKeyStateTable
[msg
->wParam
& 0xff] &= ~0x80;
870 if (peek
) return TRUE
;
871 else return (msg
->message
!= WM_QUIT
);
875 /***********************************************************************
876 * MSG_InternalGetMessage
878 * GetMessage() function for internal use. Behave like GetMessage(),
879 * but also call message filters and optionally send WM_ENTERIDLE messages.
880 * 'hwnd' must be the handle of the dialog or menu window.
881 * 'code' is the message filter value (MSGF_??? codes).
883 BOOL32
MSG_InternalGetMessage( MSG16
*msg
, HWND32 hwnd
, HWND32 hwndOwner
,
884 WPARAM32 code
, WORD flags
, BOOL32 sendIdle
)
890 if (!MSG_PeekMessage( msg
, 0, 0, 0, flags
, TRUE
))
892 /* No message present -> send ENTERIDLE and wait */
893 if (IsWindow32(hwndOwner
))
894 SendMessage16( hwndOwner
, WM_ENTERIDLE
,
895 code
, (LPARAM
)hwnd
);
896 MSG_PeekMessage( msg
, 0, 0, 0, flags
, FALSE
);
899 else /* Always wait for a message */
900 MSG_PeekMessage( msg
, 0, 0, 0, flags
, FALSE
);
902 /* Call message filters */
904 if (HOOK_IsHooked( WH_SYSMSGFILTER
) || HOOK_IsHooked( WH_MSGFILTER
))
906 MSG16
*pmsg
= SEGPTR_NEW(MSG16
);
911 ret
= ((BOOL16
)HOOK_CallHooks16( WH_SYSMSGFILTER
, code
, 0,
912 (LPARAM
)SEGPTR_GET(pmsg
) ) ||
913 (BOOL16
)HOOK_CallHooks16( WH_MSGFILTER
, code
, 0,
914 (LPARAM
)SEGPTR_GET(pmsg
) ));
918 /* Message filtered -> remove it from the queue */
919 /* if it's still there. */
920 if (!(flags
& PM_REMOVE
))
921 MSG_PeekMessage( msg
, 0, 0, 0, PM_REMOVE
, TRUE
);
927 return (msg
->message
!= WM_QUIT
);
932 /***********************************************************************
933 * PeekMessage16 (USER.109)
935 BOOL16 WINAPI
PeekMessage16( LPMSG16 msg
, HWND16 hwnd
, UINT16 first
,
936 UINT16 last
, UINT16 flags
)
938 return MSG_PeekMessage( msg
, hwnd
, first
, last
, flags
, TRUE
);
941 /***********************************************************************
944 BOOL32 WINAPI
PeekMessage32A( LPMSG32 lpmsg
, HWND32 hwnd
,
945 UINT32 min
,UINT32 max
,UINT32 wRemoveMsg
)
949 ret
=PeekMessage16(&msg
,hwnd
,min
,max
,wRemoveMsg
);
950 /* FIXME: should translate the message to Win32 */
951 STRUCT32_MSG16to32(&msg
,lpmsg
);
955 /***********************************************************************
956 * PeekMessageW Check queue for messages
958 * Checks for a message in the thread's queue, filtered as for
959 * GetMessage(). Returns immediately whether a message is available
962 * Whether a retrieved message is removed from the queue is set by the
963 * _wRemoveMsg_ flags, which should be one of the following values:
965 * PM_NOREMOVE Do not remove the message from the queue.
967 * PM_REMOVE Remove the message from the queue.
969 * In addition, PM_NOYIELD may be combined into _wRemoveMsg_ to
970 * request that the system not yield control during PeekMessage();
971 * however applications may not rely on scheduling behavior.
975 * Nonzero if a message is available and is retrieved, zero otherwise.
982 BOOL32 WINAPI
PeekMessage32W(
983 LPMSG32 lpmsg
, /* buffer to receive message */
984 HWND32 hwnd
, /* restrict to messages for hwnd */
985 UINT32 min
, /* minimum message to receive */
986 UINT32 max
, /* maximum message to receive */
987 UINT32 wRemoveMsg
/* removal flags */
989 /* FIXME: Should perform Unicode translation on specific messages */
990 return PeekMessage32A(lpmsg
,hwnd
,min
,max
,wRemoveMsg
);
993 /***********************************************************************
994 * GetMessage16 (USER.108)
996 BOOL16 WINAPI
GetMessage16( SEGPTR msg
, HWND16 hwnd
, UINT16 first
, UINT16 last
)
998 MSG16
*lpmsg
= (MSG16
*)PTR_SEG_TO_LIN(msg
);
999 MSG_PeekMessage( lpmsg
,
1000 hwnd
, first
, last
, PM_REMOVE
, FALSE
);
1002 TRACE(msg
,"message %04x, hwnd %04x, filter(%04x - %04x)\n", lpmsg
->message
,
1003 hwnd
, first
, last
);
1004 HOOK_CallHooks16( WH_GETMESSAGE
, HC_ACTION
, 0, (LPARAM
)msg
);
1005 return (lpmsg
->message
!= WM_QUIT
);
1008 /***********************************************************************
1009 * GetMessage32A (USER32.270)
1011 BOOL32 WINAPI
GetMessage32A(MSG32
* lpmsg
,HWND32 hwnd
,UINT32 min
,UINT32 max
)
1014 MSG16
*msg
= SEGPTR_NEW(MSG16
);
1016 ret
=GetMessage16(SEGPTR_GET(msg
),(HWND16
)hwnd
,min
,max
);
1018 STRUCT32_MSG16to32(msg
,lpmsg
);
1023 /***********************************************************************
1024 * GetMessage32W (USER32.274) Retrieve next message
1026 * GetMessage retrieves the next event from the calling thread's
1027 * queue and deposits it in *lpmsg.
1029 * If _hwnd_ is not NULL, only messages for window _hwnd_ and its
1030 * children as specified by IsChild() are retrieved. If _hwnd_ is NULL
1031 * all application messages are retrieved.
1033 * _min_ and _max_ specify the range of messages of interest. If
1034 * min==max==0, no filtering is performed. Useful examples are
1035 * WM_KEYFIRST and WM_KEYLAST to retrieve keyboard input, and
1036 * WM_MOUSEFIRST and WM_MOUSELAST to retrieve mouse input.
1038 * WM_PAINT messages are not removed from the queue; they remain until
1039 * processed. Other messages are removed from the queue.
1043 * -1 on error, 0 if message is WM_QUIT, nonzero otherwise.
1050 BOOL32 WINAPI
GetMessage32W(
1051 MSG32
* lpmsg
, /* buffer to receive message */
1052 HWND32 hwnd
, /* restrict to messages for hwnd */
1053 UINT32 min
, /* minimum message to receive */
1054 UINT32 max
/* maximum message to receive */
1057 MSG16
*msg
= SEGPTR_NEW(MSG16
);
1059 ret
=GetMessage16(SEGPTR_GET(msg
),(HWND16
)hwnd
,min
,max
);
1061 STRUCT32_MSG16to32(msg
,lpmsg
);
1067 /***********************************************************************
1068 * PostMessage16 (USER.110)
1070 BOOL16 WINAPI
PostMessage16( HWND16 hwnd
, UINT16 message
, WPARAM16 wParam
,
1077 msg
.message
= message
;
1078 msg
.wParam
= wParam
;
1079 msg
.lParam
= lParam
;
1080 msg
.time
= GetTickCount();
1085 if (DDE_PostMessage(&msg
))
1087 #endif /* CONFIG_IPC */
1089 if (hwnd
== HWND_BROADCAST
)
1091 TRACE(msg
,"HWND_BROADCAST !\n");
1092 for (wndPtr
= WIN_GetDesktop()->child
; wndPtr
; wndPtr
= wndPtr
->next
)
1094 if (wndPtr
->dwStyle
& WS_POPUP
|| wndPtr
->dwStyle
& WS_CAPTION
)
1096 TRACE(msg
,"BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n",
1097 wndPtr
->hwndSelf
, message
, wParam
, lParam
);
1098 PostMessage16( wndPtr
->hwndSelf
, message
, wParam
, lParam
);
1101 TRACE(msg
,"End of HWND_BROADCAST !\n");
1105 wndPtr
= WIN_FindWndPtr( hwnd
);
1106 if (!wndPtr
|| !wndPtr
->hmemTaskQ
) return FALSE
;
1108 return QUEUE_AddMsg( wndPtr
->hmemTaskQ
, &msg
, 0 );
1112 /***********************************************************************
1113 * PostMessage32A (USER32.419)
1115 BOOL32 WINAPI
PostMessage32A( HWND32 hwnd
, UINT32 message
, WPARAM32 wParam
,
1119 if (message
&0xffff0000)
1120 FIXME(msg
,"message is truncated from %d to %d\n", message
, message
&0xffff);
1121 if (wParam
&0xffff0000)
1122 FIXME(msg
,"wParam is truncated from %d to %d\n", wParam
, wParam
&0xffff);
1123 return PostMessage16( hwnd
, message
, wParam
, lParam
);
1127 /***********************************************************************
1128 * PostMessage32W (USER32.420)
1130 BOOL32 WINAPI
PostMessage32W( HWND32 hwnd
, UINT32 message
, WPARAM32 wParam
,
1134 if (message
&0xffff0000)
1135 FIXME(msg
,"message is truncated from %d to %d\n", message
, message
&0xffff);
1136 if (wParam
&0xffff0000)
1137 FIXME(msg
,"wParam is truncated from %d to %d\n", wParam
, wParam
&0xffff);
1138 return PostMessage16( hwnd
, message
, wParam
, lParam
);
1142 /***********************************************************************
1143 * PostAppMessage16 (USER.116)
1145 BOOL16 WINAPI
PostAppMessage16( HTASK16 hTask
, UINT16 message
, WPARAM16 wParam
,
1150 if (GetTaskQueue(hTask
) == 0) return FALSE
;
1152 msg
.message
= message
;
1153 msg
.wParam
= wParam
;
1154 msg
.lParam
= lParam
;
1155 msg
.time
= GetTickCount();
1159 return QUEUE_AddMsg( GetTaskQueue(hTask
), &msg
, 0 );
1163 /***********************************************************************
1164 * SendMessage16 (USER.111)
1166 LRESULT WINAPI
SendMessage16( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
,
1170 WND
**list
, **ppWnd
;
1174 MSG16 DDE_msg
= { hwnd
, msg
, wParam
, lParam
};
1175 if (DDE_SendMessage(&DDE_msg
)) return TRUE
;
1176 #endif /* CONFIG_IPC */
1178 if (hwnd
== HWND_BROADCAST
)
1180 if (!(list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1182 TRACE(msg
,"HWND_BROADCAST !\n");
1183 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1186 if (!IsWindow32(wndPtr
->hwndSelf
)) continue;
1187 if (wndPtr
->dwStyle
& WS_POPUP
|| wndPtr
->dwStyle
& WS_CAPTION
)
1189 TRACE(msg
,"BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n",
1190 wndPtr
->hwndSelf
, msg
, (DWORD
)wParam
, lParam
);
1191 SendMessage16( wndPtr
->hwndSelf
, msg
, wParam
, lParam
);
1194 HeapFree( SystemHeap
, 0, list
);
1195 TRACE(msg
,"End of HWND_BROADCAST !\n");
1199 if (HOOK_IsHooked( WH_CALLWNDPROC
))
1203 if ((pmsg
= SEGPTR_NEW(CWPSTRUCT16
)))
1207 pmsg
->wParam
= wParam
;
1208 pmsg
->lParam
= lParam
;
1209 HOOK_CallHooks16( WH_CALLWNDPROC
, HC_ACTION
, 1,
1210 (LPARAM
)SEGPTR_GET(pmsg
) );
1212 msg
= pmsg
->message
;
1213 wParam
= pmsg
->wParam
;
1214 lParam
= pmsg
->lParam
;
1215 SEGPTR_FREE( pmsg
);
1219 if (!(wndPtr
= WIN_FindWndPtr( hwnd
)))
1221 WARN(msg
, "invalid hwnd %04x\n", hwnd
);
1224 if (QUEUE_IsExitingQueue(wndPtr
->hmemTaskQ
))
1225 return 0; /* Don't send anything if the task is dying */
1227 SPY_EnterMessage( SPY_SENDMESSAGE16
, hwnd
, msg
, wParam
, lParam
);
1229 if (wndPtr
->hmemTaskQ
!= GetTaskQueue(0))
1230 ret
= MSG_SendMessage( wndPtr
->hmemTaskQ
, hwnd
, msg
,
1231 wParam
, lParam
, 0 );
1233 ret
= CallWindowProc16( (WNDPROC16
)wndPtr
->winproc
,
1234 hwnd
, msg
, wParam
, lParam
);
1236 SPY_ExitMessage( SPY_RESULT_OK16
, hwnd
, msg
, ret
);
1240 /************************************************************************
1241 * MSG_CallWndProcHook32
1243 static void MSG_CallWndProcHook32( LPMSG32 pmsg
, BOOL32 bUnicode
)
1247 cwp
.lParam
= pmsg
->lParam
;
1248 cwp
.wParam
= pmsg
->wParam
;
1249 cwp
.message
= pmsg
->message
;
1250 cwp
.hwnd
= pmsg
->hwnd
;
1252 if (bUnicode
) HOOK_CallHooks32W(WH_CALLWNDPROC
, HC_ACTION
, 1, (LPARAM
)&cwp
);
1253 else HOOK_CallHooks32A( WH_CALLWNDPROC
, HC_ACTION
, 1, (LPARAM
)&cwp
);
1255 pmsg
->lParam
= cwp
.lParam
;
1256 pmsg
->wParam
= cwp
.wParam
;
1257 pmsg
->message
= cwp
.message
;
1258 pmsg
->hwnd
= cwp
.hwnd
;
1261 /**********************************************************************
1262 * PostThreadMessage32A (USER32.422)
1266 * Thread-local message queues are not supported.
1269 BOOL32 WINAPI
PostThreadMessage32A(DWORD idThread
, UINT32 message
,
1270 WPARAM32 wParam
, LPARAM lParam
)
1272 THDB
*thdb
= THREAD_ID_TO_THDB(idThread
);
1273 if (!thdb
|| !thdb
->process
) return FALSE
;
1275 FIXME(sendmsg
, "(...): Should use thread-local message queue!\n");
1276 return PostAppMessage16(thdb
->process
->task
, message
, wParam
, lParam
);
1279 /**********************************************************************
1280 * PostThreadMessage32W (USER32.423)
1284 * Thread-local message queues are not supported.
1287 BOOL32 WINAPI
PostThreadMessage32W(DWORD idThread
, UINT32 message
,
1288 WPARAM32 wParam
, LPARAM lParam
)
1290 THDB
*thdb
= THREAD_ID_TO_THDB(idThread
);
1291 if (!thdb
|| !thdb
->process
) return FALSE
;
1293 FIXME(sendmsg
, "(...): Should use thread-local message queue!\n");
1294 return PostAppMessage16(thdb
->process
->task
, message
, wParam
, lParam
);
1297 /***********************************************************************
1298 * SendMessage32A (USER32.454)
1300 LRESULT WINAPI
SendMessage32A( HWND32 hwnd
, UINT32 msg
, WPARAM32 wParam
,
1304 WND
**list
, **ppWnd
;
1307 if (hwnd
== HWND_BROADCAST
|| hwnd
== HWND_TOPMOST
)
1309 if (!(list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1311 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1314 if (!IsWindow32(wndPtr
->hwndSelf
)) continue;
1315 if (wndPtr
->dwStyle
& WS_POPUP
|| wndPtr
->dwStyle
& WS_CAPTION
)
1316 SendMessage32A( wndPtr
->hwndSelf
, msg
, wParam
, lParam
);
1318 HeapFree( SystemHeap
, 0, list
);
1322 if (HOOK_IsHooked( WH_CALLWNDPROC
))
1323 MSG_CallWndProcHook32( (LPMSG32
)&hwnd
, FALSE
);
1325 if (!(wndPtr
= WIN_FindWndPtr( hwnd
)))
1327 WARN(msg
, "invalid hwnd %08x\n", hwnd
);
1331 if (QUEUE_IsExitingQueue(wndPtr
->hmemTaskQ
))
1332 return 0; /* Don't send anything if the task is dying */
1334 SPY_EnterMessage( SPY_SENDMESSAGE32
, hwnd
, msg
, wParam
, lParam
);
1336 if (wndPtr
->hmemTaskQ
!= GetTaskQueue(0))
1337 ret
= MSG_SendMessage( wndPtr
->hmemTaskQ
, hwnd
, msg
, wParam
, lParam
,
1340 ret
= CallWindowProc32A( (WNDPROC32
)wndPtr
->winproc
,
1341 hwnd
, msg
, wParam
, lParam
);
1343 SPY_ExitMessage( SPY_RESULT_OK32
, hwnd
, msg
, ret
);
1348 /***********************************************************************
1349 * SendMessage32W (USER32.459) Send Window Message
1351 * Sends a message to the window procedure of the specified window.
1352 * SendMessage() will not return until the called window procedure
1353 * either returns or calls ReplyMessage().
1355 * Use PostMessage() to send message and return immediately. A window
1356 * procedure may use InSendMessage() to detect
1357 * SendMessage()-originated messages.
1359 * Applications which communicate via HWND_BROADCAST may use
1360 * RegisterWindowMessage() to obtain a unique message to avoid conflicts
1361 * with other applications.
1367 LRESULT WINAPI
SendMessage32W(
1368 HWND32 hwnd
, /* Window to send message to. If HWND_BROADCAST,
1369 the message will be sent to all top-level windows. */
1371 UINT32 msg
, /* message */
1372 WPARAM32 wParam
, /* message parameter */
1373 LPARAM lParam
/* additional message parameter */
1376 WND
**list
, **ppWnd
;
1379 if (hwnd
== HWND_BROADCAST
|| hwnd
== HWND_TOPMOST
)
1381 if (!(list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1383 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1386 if (!IsWindow32(wndPtr
->hwndSelf
)) continue;
1387 if (wndPtr
->dwStyle
& WS_POPUP
|| wndPtr
->dwStyle
& WS_CAPTION
)
1388 SendMessage32W( wndPtr
->hwndSelf
, msg
, wParam
, lParam
);
1390 HeapFree( SystemHeap
, 0, list
);
1394 if (HOOK_IsHooked( WH_CALLWNDPROC
))
1395 MSG_CallWndProcHook32( (LPMSG32
)&hwnd
, TRUE
);
1397 if (!(wndPtr
= WIN_FindWndPtr( hwnd
)))
1399 WARN(msg
, "invalid hwnd %08x\n", hwnd
);
1402 if (QUEUE_IsExitingQueue(wndPtr
->hmemTaskQ
))
1403 return 0; /* Don't send anything if the task is dying */
1405 SPY_EnterMessage( SPY_SENDMESSAGE32
, hwnd
, msg
, wParam
, lParam
);
1407 if (wndPtr
->hmemTaskQ
!= GetTaskQueue(0))
1408 ret
= MSG_SendMessage( wndPtr
->hmemTaskQ
, hwnd
, msg
, wParam
, lParam
,
1409 QUEUE_SM_WIN32
| QUEUE_SM_UNICODE
);
1411 ret
= CallWindowProc32W( (WNDPROC32
)wndPtr
->winproc
,
1412 hwnd
, msg
, wParam
, lParam
);
1414 SPY_ExitMessage( SPY_RESULT_OK32
, hwnd
, msg
, ret
);
1419 /***********************************************************************
1420 * SendMessageTimeout16 (not a WINAPI)
1422 LRESULT WINAPI
SendMessageTimeout16( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
,
1423 LPARAM lParam
, UINT16 flags
,
1424 UINT16 timeout
, LPWORD resultp
)
1426 FIXME(sendmsg
, "(...): semistub\n");
1427 return SendMessage16 (hwnd
, msg
, wParam
, lParam
);
1431 /***********************************************************************
1432 * SendMessageTimeout32A (USER32.457)
1434 LRESULT WINAPI
SendMessageTimeout32A( HWND32 hwnd
, UINT32 msg
, WPARAM32 wParam
,
1435 LPARAM lParam
, UINT32 flags
,
1436 UINT32 timeout
, LPDWORD resultp
)
1438 FIXME(sendmsg
, "(...): semistub\n");
1439 return SendMessage32A (hwnd
, msg
, wParam
, lParam
);
1443 /***********************************************************************
1444 * SendMessageTimeout32W (USER32.458)
1446 LRESULT WINAPI
SendMessageTimeout32W( HWND32 hwnd
, UINT32 msg
, WPARAM32 wParam
,
1447 LPARAM lParam
, UINT32 flags
,
1448 UINT32 timeout
, LPDWORD resultp
)
1450 FIXME(sendmsg
, "(...): semistub\n");
1451 return SendMessage32W (hwnd
, msg
, wParam
, lParam
);
1455 /***********************************************************************
1456 * WaitMessage (USER.112) (USER32.578) Suspend thread pending messages
1458 * WaitMessage() suspends a thread until events appear in the thread's
1463 * Is supposed to return BOOL under Win32.
1465 * Thread-local message queues are not supported.
1472 void WINAPI
WaitMessage( void )
1474 QUEUE_WaitBits( QS_ALLINPUT
);
1477 /***********************************************************************
1478 * MsgWaitForMultipleObjects (USER32.400)
1480 DWORD WINAPI
MsgWaitForMultipleObjects( DWORD nCount
, HANDLE32
*pHandles
,
1481 BOOL32 fWaitAll
, DWORD dwMilliseconds
,
1486 TDB
*currTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
1487 HQUEUE16 hQueue
= currTask
? currTask
->hQueue
: 0;
1488 MESSAGEQUEUE
*msgQueue
= (MESSAGEQUEUE
*)GlobalLock16( hQueue
);
1489 if (!msgQueue
) return 0xFFFFFFFF;
1491 msgQueue
->changeBits
= 0;
1492 msgQueue
->wakeMask
= dwWakeMask
;
1494 retv
= SYNC_DoWait( nCount
, pHandles
, fWaitAll
, dwMilliseconds
, FALSE
, TRUE
);
1508 static const struct accent_char accent_chars
[] =
1510 /* A good idea should be to read /usr/X11/lib/X11/locale/iso8859-x/Compose */
1511 {'`', 'A', '\300'}, {'`', 'a', '\340'},
1512 {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
1513 {'^', 'A', '\302'}, {'^', 'a', '\342'},
1514 {'~', 'A', '\303'}, {'~', 'a', '\343'},
1515 {'"', 'A', '\304'}, {'"', 'a', '\344'},
1516 {'O', 'A', '\305'}, {'o', 'a', '\345'},
1517 {'0', 'A', '\305'}, {'0', 'a', '\345'},
1518 {'A', 'A', '\305'}, {'a', 'a', '\345'},
1519 {'A', 'E', '\306'}, {'a', 'e', '\346'},
1520 {',', 'C', '\307'}, {',', 'c', '\347'},
1521 {'`', 'E', '\310'}, {'`', 'e', '\350'},
1522 {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
1523 {'^', 'E', '\312'}, {'^', 'e', '\352'},
1524 {'"', 'E', '\313'}, {'"', 'e', '\353'},
1525 {'`', 'I', '\314'}, {'`', 'i', '\354'},
1526 {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
1527 {'^', 'I', '\316'}, {'^', 'i', '\356'},
1528 {'"', 'I', '\317'}, {'"', 'i', '\357'},
1529 {'-', 'D', '\320'}, {'-', 'd', '\360'},
1530 {'~', 'N', '\321'}, {'~', 'n', '\361'},
1531 {'`', 'O', '\322'}, {'`', 'o', '\362'},
1532 {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
1533 {'^', 'O', '\324'}, {'^', 'o', '\364'},
1534 {'~', 'O', '\325'}, {'~', 'o', '\365'},
1535 {'"', 'O', '\326'}, {'"', 'o', '\366'},
1536 {'/', 'O', '\330'}, {'/', 'o', '\370'},
1537 {'`', 'U', '\331'}, {'`', 'u', '\371'},
1538 {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
1539 {'^', 'U', '\333'}, {'^', 'u', '\373'},
1540 {'"', 'U', '\334'}, {'"', 'u', '\374'},
1541 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
1542 {'T', 'H', '\336'}, {'t', 'h', '\376'},
1543 {'s', 's', '\337'}, {'"', 'y', '\377'},
1544 {'s', 'z', '\337'}, {'i', 'j', '\377'},
1545 /* iso-8859-2 uses this */
1546 {'<', 'L', '\245'}, {'<', 'l', '\265'}, /* caron */
1547 {'<', 'S', '\251'}, {'<', 's', '\271'},
1548 {'<', 'T', '\253'}, {'<', 't', '\273'},
1549 {'<', 'Z', '\256'}, {'<', 'z', '\276'},
1550 {'<', 'C', '\310'}, {'<', 'c', '\350'},
1551 {'<', 'E', '\314'}, {'<', 'e', '\354'},
1552 {'<', 'D', '\317'}, {'<', 'd', '\357'},
1553 {'<', 'N', '\322'}, {'<', 'n', '\362'},
1554 {'<', 'R', '\330'}, {'<', 'r', '\370'},
1555 {';', 'A', '\241'}, {';', 'a', '\261'}, /* ogonek */
1556 {';', 'E', '\312'}, {';', 'e', '\332'},
1557 {'\'', 'Z', '\254'}, {'\'', 'z', '\274'}, /* acute */
1558 {'\'', 'R', '\300'}, {'\'', 'r', '\340'},
1559 {'\'', 'L', '\305'}, {'\'', 'l', '\345'},
1560 {'\'', 'C', '\306'}, {'\'', 'c', '\346'},
1561 {'\'', 'N', '\321'}, {'\'', 'n', '\361'},
1562 /* collision whith S, from iso-8859-9 !!! */
1563 {',', 'S', '\252'}, {',', 's', '\272'}, /* cedilla */
1564 {',', 'T', '\336'}, {',', 't', '\376'},
1565 {'.', 'Z', '\257'}, {'.', 'z', '\277'}, /* dot above */
1566 {'/', 'L', '\243'}, {'/', 'l', '\263'}, /* slash */
1567 {'/', 'D', '\320'}, {'/', 'd', '\360'},
1568 {'(', 'A', '\303'}, {'(', 'a', '\343'}, /* breve */
1569 {'\275', 'O', '\325'}, {'\275', 'o', '\365'}, /* double acute */
1570 {'\275', 'U', '\334'}, {'\275', 'u', '\374'},
1571 {'0', 'U', '\332'}, {'0', 'u', '\372'}, /* ring above */
1572 /* iso-8859-3 uses this */
1573 {'/', 'H', '\241'}, {'/', 'h', '\261'}, /* slash */
1574 {'>', 'H', '\246'}, {'>', 'h', '\266'}, /* circumflex */
1575 {'>', 'J', '\254'}, {'>', 'j', '\274'},
1576 {'>', 'C', '\306'}, {'>', 'c', '\346'},
1577 {'>', 'G', '\330'}, {'>', 'g', '\370'},
1578 {'>', 'S', '\336'}, {'>', 's', '\376'},
1579 /* collision whith G( from iso-8859-9 !!! */
1580 {'(', 'G', '\253'}, {'(', 'g', '\273'}, /* breve */
1581 {'(', 'U', '\335'}, {'(', 'u', '\375'},
1582 /* collision whith I. from iso-8859-3 !!! */
1583 {'.', 'I', '\251'}, {'.', 'i', '\271'}, /* dot above */
1584 {'.', 'C', '\305'}, {'.', 'c', '\345'},
1585 {'.', 'G', '\325'}, {'.', 'g', '\365'},
1586 /* iso-8859-4 uses this */
1587 {',', 'R', '\243'}, {',', 'r', '\263'}, /* cedilla */
1588 {',', 'L', '\246'}, {',', 'l', '\266'},
1589 {',', 'G', '\253'}, {',', 'g', '\273'},
1590 {',', 'N', '\321'}, {',', 'n', '\361'},
1591 {',', 'K', '\323'}, {',', 'k', '\363'},
1592 {'~', 'I', '\245'}, {'~', 'i', '\265'}, /* tilde */
1593 {'-', 'E', '\252'}, {'-', 'e', '\272'}, /* macron */
1594 {'-', 'A', '\300'}, {'-', 'a', '\340'},
1595 {'-', 'I', '\317'}, {'-', 'i', '\357'},
1596 {'-', 'O', '\322'}, {'-', 'o', '\362'},
1597 {'-', 'U', '\336'}, {'-', 'u', '\376'},
1598 {'/', 'T', '\254'}, {'/', 't', '\274'}, /* slash */
1599 {'.', 'E', '\314'}, {'.', 'e', '\344'}, /* dot above */
1600 {';', 'I', '\307'}, {';', 'i', '\347'}, /* ogonek */
1601 {';', 'U', '\331'}, {';', 'u', '\371'},
1602 /* iso-8859-9 uses this */
1603 /* iso-8859-9 has really bad choosen G( S, and I. as they collide
1604 * whith the same letters on other iso-8859-x (that is they are on
1605 * different places :-( ), if you use turkish uncomment these and
1606 * comment out the lines in iso-8859-2 and iso-8859-3 sections
1607 * FIXME: should be dynamic according to chosen language
1608 * if/when Wine has turkish support.
1610 /* collision whith G( from iso-8859-3 !!! */
1611 /* {'(', 'G', '\320'}, {'(', 'g', '\360'}, */ /* breve */
1612 /* collision whith S, from iso-8859-2 !!! */
1613 /* {',', 'S', '\336'}, {',', 's', '\376'}, */ /* cedilla */
1614 /* collision whith I. from iso-8859-3 !!! */
1615 /* {'.', 'I', '\335'}, {'.', 'i', '\375'}, */ /* dot above */
1619 /***********************************************************************
1620 * MSG_DoTranslateMessage
1622 * Implementation of TranslateMessage.
1624 * TranslateMessage translates virtual-key messages into character-messages,
1626 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
1627 * ditto replacing WM_* with WM_SYS*
1628 * This produces WM_CHAR messages only for keys mapped to ASCII characters
1629 * by the keyboard driver.
1631 static BOOL32
MSG_DoTranslateMessage( UINT32 message
, HWND32 hwnd
,
1632 WPARAM32 wParam
, LPARAM lParam
)
1634 static int dead_char
;
1637 if (message
!= WM_MOUSEMOVE
&& message
!= WM_TIMER
)
1638 TRACE(msg
, "(%s, %04X, %08lX)\n",
1639 SPY_GetMsgName(message
), wParam
, lParam
);
1640 if(message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
)
1641 TRACE(key
, "(%s, %04X, %08lX)\n",
1642 SPY_GetMsgName(message
), wParam
, lParam
);
1644 if ((message
!= WM_KEYDOWN
) && (message
!= WM_SYSKEYDOWN
)) return FALSE
;
1646 TRACE(key
, "Translating key %04X, scancode %04X\n",
1647 wParam
, HIWORD(lParam
) );
1649 /* FIXME : should handle ToAscii yielding 2 */
1650 switch (ToAscii32(wParam
, HIWORD(lParam
),
1651 QueueKeyStateTable
,(LPWORD
)wp
, 0))
1654 message
= (message
== WM_KEYDOWN
) ? WM_CHAR
: WM_SYSCHAR
;
1655 /* Should dead chars handling go in ToAscii ? */
1660 if (wp
[0] == ' ') wp
[0] = dead_char
;
1661 if (dead_char
== 0xa2) dead_char
= '(';
1662 else if (dead_char
== 0xa8) dead_char
= '"';
1663 else if (dead_char
== 0xb2) dead_char
= ';';
1664 else if (dead_char
== 0xb4) dead_char
= '\'';
1665 else if (dead_char
== 0xb7) dead_char
= '<';
1666 else if (dead_char
== 0xb8) dead_char
= ',';
1667 else if (dead_char
== 0xff) dead_char
= '.';
1668 for (i
= 0; i
< sizeof(accent_chars
)/sizeof(accent_chars
[0]); i
++)
1669 if ((accent_chars
[i
].ac_accent
== dead_char
) &&
1670 (accent_chars
[i
].ac_char
== wp
[0]))
1672 wp
[0] = accent_chars
[i
].ac_result
;
1677 TRACE(key
, "1 -> PostMessage(%s)\n", SPY_GetMsgName(message
));
1678 PostMessage16( hwnd
, message
, wp
[0], lParam
);
1682 message
= (message
== WM_KEYDOWN
) ? WM_DEADCHAR
: WM_SYSDEADCHAR
;
1684 TRACE(key
, "-1 -> PostMessage(%s)\n",
1685 SPY_GetMsgName(message
));
1686 PostMessage16( hwnd
, message
, wp
[0], lParam
);
1693 /***********************************************************************
1694 * TranslateMessage16 (USER.113)
1696 BOOL16 WINAPI
TranslateMessage16( const MSG16
*msg
)
1698 return MSG_DoTranslateMessage( msg
->message
, msg
->hwnd
,
1699 msg
->wParam
, msg
->lParam
);
1703 /***********************************************************************
1704 * TranslateMessage32 (USER32.556)
1706 BOOL32 WINAPI
TranslateMessage32( const MSG32
*msg
)
1708 return MSG_DoTranslateMessage( msg
->message
, msg
->hwnd
,
1709 msg
->wParam
, msg
->lParam
);
1713 /***********************************************************************
1714 * DispatchMessage16 (USER.114)
1716 LONG WINAPI
DispatchMessage16( const MSG16
* msg
)
1722 /* Process timer messages */
1723 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
1727 return CallWindowProc16( (WNDPROC16
)msg
->lParam
, msg
->hwnd
,
1728 msg
->message
, msg
->wParam
, GetTickCount() );
1732 if (!msg
->hwnd
) return 0;
1733 if (!(wndPtr
= WIN_FindWndPtr( msg
->hwnd
))) return 0;
1734 if (!wndPtr
->winproc
) return 0;
1735 painting
= (msg
->message
== WM_PAINT
);
1736 if (painting
) wndPtr
->flags
|= WIN_NEEDS_BEGINPAINT
;
1738 SPY_EnterMessage( SPY_DISPATCHMESSAGE16
, msg
->hwnd
, msg
->message
,
1739 msg
->wParam
, msg
->lParam
);
1740 retval
= CallWindowProc16( (WNDPROC16
)wndPtr
->winproc
,
1741 msg
->hwnd
, msg
->message
,
1742 msg
->wParam
, msg
->lParam
);
1743 SPY_ExitMessage( SPY_RESULT_OK16
, msg
->hwnd
, msg
->message
, retval
);
1745 if (painting
&& (wndPtr
= WIN_FindWndPtr( msg
->hwnd
)) &&
1746 (wndPtr
->flags
& WIN_NEEDS_BEGINPAINT
) && wndPtr
->hrgnUpdate
)
1748 ERR(msg
, "BeginPaint not called on WM_PAINT for hwnd %04x!\n",
1750 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
1751 /* Validate the update region to avoid infinite WM_PAINT loop */
1752 ValidateRect32( msg
->hwnd
, NULL
);
1758 /***********************************************************************
1759 * DispatchMessage32A (USER32.141)
1761 LONG WINAPI
DispatchMessage32A( const MSG32
* msg
)
1767 /* Process timer messages */
1768 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
1772 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
1773 return CallWindowProc32A( (WNDPROC32
)msg
->lParam
, msg
->hwnd
,
1774 msg
->message
, msg
->wParam
, GetTickCount() );
1778 if (!msg
->hwnd
) return 0;
1779 if (!(wndPtr
= WIN_FindWndPtr( msg
->hwnd
))) return 0;
1780 if (!wndPtr
->winproc
) return 0;
1781 painting
= (msg
->message
== WM_PAINT
);
1782 if (painting
) wndPtr
->flags
|= WIN_NEEDS_BEGINPAINT
;
1783 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
1785 SPY_EnterMessage( SPY_DISPATCHMESSAGE32
, msg
->hwnd
, msg
->message
,
1786 msg
->wParam
, msg
->lParam
);
1787 retval
= CallWindowProc32A( (WNDPROC32
)wndPtr
->winproc
,
1788 msg
->hwnd
, msg
->message
,
1789 msg
->wParam
, msg
->lParam
);
1790 SPY_ExitMessage( SPY_RESULT_OK32
, msg
->hwnd
, msg
->message
, retval
);
1792 if (painting
&& (wndPtr
= WIN_FindWndPtr( msg
->hwnd
)) &&
1793 (wndPtr
->flags
& WIN_NEEDS_BEGINPAINT
) && wndPtr
->hrgnUpdate
)
1795 ERR(msg
, "BeginPaint not called on WM_PAINT for hwnd %04x!\n",
1797 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
1798 /* Validate the update region to avoid infinite WM_PAINT loop */
1799 ValidateRect32( msg
->hwnd
, NULL
);
1805 /***********************************************************************
1806 * DispatchMessage32W (USER32.142) Process Message
1808 * Process the message specified in the structure *_msg_.
1810 * If the lpMsg parameter points to a WM_TIMER message and the
1811 * parameter of the WM_TIMER message is not NULL, the lParam parameter
1812 * points to the function that is called instead of the window
1815 * The message must be valid.
1819 * DispatchMessage() returns the result of the window procedure invoked.
1826 LONG WINAPI
DispatchMessage32W( const MSG32
* msg
)
1832 /* Process timer messages */
1833 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
1837 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
1838 return CallWindowProc32W( (WNDPROC32
)msg
->lParam
, msg
->hwnd
,
1839 msg
->message
, msg
->wParam
, GetTickCount() );
1843 if (!msg
->hwnd
) return 0;
1844 if (!(wndPtr
= WIN_FindWndPtr( msg
->hwnd
))) return 0;
1845 if (!wndPtr
->winproc
) return 0;
1846 painting
= (msg
->message
== WM_PAINT
);
1847 if (painting
) wndPtr
->flags
|= WIN_NEEDS_BEGINPAINT
;
1848 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
1850 SPY_EnterMessage( SPY_DISPATCHMESSAGE32
, msg
->hwnd
, msg
->message
,
1851 msg
->wParam
, msg
->lParam
);
1852 retval
= CallWindowProc32W( (WNDPROC32
)wndPtr
->winproc
,
1853 msg
->hwnd
, msg
->message
,
1854 msg
->wParam
, msg
->lParam
);
1855 SPY_ExitMessage( SPY_RESULT_OK32
, msg
->hwnd
, msg
->message
, retval
);
1857 if (painting
&& (wndPtr
= WIN_FindWndPtr( msg
->hwnd
)) &&
1858 (wndPtr
->flags
& WIN_NEEDS_BEGINPAINT
) && wndPtr
->hrgnUpdate
)
1860 ERR(msg
, "BeginPaint not called on WM_PAINT for hwnd %04x!\n",
1862 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
1863 /* Validate the update region to avoid infinite WM_PAINT loop */
1864 ValidateRect32( msg
->hwnd
, NULL
);
1870 /***********************************************************************
1871 * RegisterWindowMessage16 (USER.118)
1873 WORD WINAPI
RegisterWindowMessage16( SEGPTR str
)
1875 TRACE(msg
, "%08lx\n", (DWORD
)str
);
1876 return GlobalAddAtom16( str
);
1880 /***********************************************************************
1881 * RegisterWindowMessage32A (USER32.437)
1883 WORD WINAPI
RegisterWindowMessage32A( LPCSTR str
)
1885 TRACE(msg
, "%s\n", str
);
1886 return GlobalAddAtom32A( str
);
1890 /***********************************************************************
1891 * RegisterWindowMessage32W (USER32.438)
1893 WORD WINAPI
RegisterWindowMessage32W( LPCWSTR str
)
1895 TRACE(msg
, "%p\n", str
);
1896 return GlobalAddAtom32W( str
);
1900 /***********************************************************************
1901 * GetTickCount (USER.13) (KERNEL32.299) System Time
1902 * Returns the number of milliseconds, modulo 2^32, since the start
1903 * of the current session.
1909 DWORD WINAPI
GetTickCount(void)
1912 gettimeofday( &t
, NULL
);
1913 /* make extremely compatible: granularity is 25 msec */
1914 return ((t
.tv_sec
* 1000) + (t
.tv_usec
/ 25000) * 25) - MSG_WineStartTicks
;
1918 /***********************************************************************
1919 * GetCurrentTime16 (USER.15)
1921 * (effectively identical to GetTickCount)
1923 DWORD WINAPI
GetCurrentTime16(void)
1925 return GetTickCount();
1929 /***********************************************************************
1930 * InSendMessage16 (USER.192)
1932 BOOL16 WINAPI
InSendMessage16(void)
1934 return InSendMessage32();
1938 /***********************************************************************
1939 * InSendMessage32 (USER32.320)
1941 BOOL32 WINAPI
InSendMessage32(void)
1943 MESSAGEQUEUE
*queue
;
1945 if (!(queue
= (MESSAGEQUEUE
*)GlobalLock16( GetTaskQueue(0) )))
1947 return (BOOL32
)queue
->InSendMessageHandle
;
1950 /***********************************************************************
1951 * BroadcastSystemMessage (USER32.12)
1953 LONG WINAPI
BroadcastSystemMessage(
1954 DWORD dwFlags
,LPDWORD recipients
,UINT32 uMessage
,WPARAM32 wParam
,
1957 FIXME(sendmsg
,"(%08lx,%08lx,%08x,%08x,%08lx): stub!\n",
1958 dwFlags
,*recipients
,uMessage
,wParam
,lParam
1963 /***********************************************************************
1964 * SendNotifyMessageA (USER32.460)
1966 * The message sended with PostMessage has to be put in the queue
1967 * with a higher priority as the other "Posted" messages.
1968 * QUEUE_AddMsg has to be modifyed.
1970 LONG WINAPI
SendNotifyMessage32A(HWND32 hwnd
,UINT32 msg
,WPARAM32 wParam
,LPARAM lParam
)
1971 { BOOL32 ret
= TRUE
;
1972 FIXME(msg
,"(%04x,%08x,%08x,%08lx) not complete\n",
1973 hwnd
, msg
, wParam
, lParam
);
1975 if ( GetCurrentThreadId() == GetWindowThreadProcessId ( hwnd
, NULL
))
1976 { ret
=SendMessage32A ( hwnd
, msg
, wParam
, lParam
);
1979 { PostMessage32A ( hwnd
, msg
, wParam
, lParam
);
1983 /***********************************************************************
1984 * SendMessageCallBack32A
1985 * FIXME: It's like PostMessage. The callback gets called when the message
1986 * is processed. We have to modify the message processing for a exact
1989 BOOL32 WINAPI
SendMessageCallBack32A(
1990 HWND32 hWnd
,UINT32 Msg
,WPARAM32 wParam
,LPARAM lParam
,
1991 FARPROC32 lpResultCallBack
,DWORD dwData
)
1993 FIXME(msg
,"(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
1994 hWnd
,Msg
,wParam
,lParam
,lpResultCallBack
,dwData
);
1995 if ( hWnd
== HWND_BROADCAST
)
1996 { PostMessage32A( hWnd
, Msg
, wParam
, lParam
);
1997 FIXME(msg
,"Broadcast: Callback will not be called!\n");
2000 (lpResultCallBack
)( hWnd
, Msg
, dwData
, SendMessage32A ( hWnd
, Msg
, wParam
, lParam
));