2 * Window messaging support
4 * Copyright 2001 Alexandre Julliard
5 * Copyright 2008 Maarten Lankhorst
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
29 #define WIN32_NO_STATUS
40 #include "wine/unicode.h"
41 #include "wine/server.h"
42 #include "user_private.h"
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(msg
);
48 WINE_DECLARE_DEBUG_CHANNEL(relay
);
49 WINE_DECLARE_DEBUG_CHANNEL(key
);
51 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
52 #define WM_NCMOUSELAST (WM_NCMOUSEFIRST+(WM_MOUSELAST-WM_MOUSEFIRST))
54 #define MAX_PACK_COUNT 4
56 #define SYS_TIMER_RATE 55 /* min. timer rate in ms (actually 54.925)*/
58 /* description of the data fields that need to be packed along with a sent message */
62 const void *data
[MAX_PACK_COUNT
];
63 size_t size
[MAX_PACK_COUNT
];
66 /* info about the message currently being received by the current thread */
67 struct received_message_info
69 enum message_type type
;
71 UINT flags
; /* InSendMessageEx return flags */
74 /* structure to group all parameters for sent messages of the various kinds */
75 struct send_message_info
77 enum message_type type
;
83 UINT flags
; /* flags for SendMessageTimeout */
84 UINT timeout
; /* timeout for SendMessageTimeout */
85 SENDASYNCPROC callback
; /* callback function for SendMessageCallback */
86 ULONG_PTR data
; /* callback data */
87 enum wm_char_mapping wm_char
;
91 /* Message class descriptor */
92 static const WCHAR messageW
[] = {'M','e','s','s','a','g','e',0};
93 static LRESULT WINAPI
message_winproc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
);
94 const struct builtin_class_descr MESSAGE_builtin_class
=
98 NULL
, /* procA (winproc is Unicode only) */
99 message_winproc
, /* procW */
101 IDC_ARROW
, /* cursor */
107 /* flag for messages that contain pointers */
108 /* 32 messages per entry, messages 0..31 map to bits 0..31 */
110 #define SET(msg) (1 << ((msg) & 31))
112 static const unsigned int message_pointer_flags
[] =
115 SET(WM_CREATE
) | SET(WM_SETTEXT
) | SET(WM_GETTEXT
) |
116 SET(WM_WININICHANGE
) | SET(WM_DEVMODECHANGE
),
118 SET(WM_GETMINMAXINFO
) | SET(WM_DRAWITEM
) | SET(WM_MEASUREITEM
) | SET(WM_DELETEITEM
) |
121 SET(WM_WINDOWPOSCHANGING
) | SET(WM_WINDOWPOSCHANGED
) | SET(WM_COPYDATA
) |
122 SET(WM_NOTIFY
) | SET(WM_HELP
),
124 SET(WM_STYLECHANGING
) | SET(WM_STYLECHANGED
),
126 SET(WM_NCCREATE
) | SET(WM_NCCALCSIZE
) | SET(WM_GETDLGCODE
),
128 SET(EM_GETSEL
) | SET(EM_GETRECT
) | SET(EM_SETRECT
) | SET(EM_SETRECTNP
),
130 SET(EM_REPLACESEL
) | SET(EM_GETLINE
) | SET(EM_SETTABSTOPS
),
132 SET(SBM_GETRANGE
) | SET(SBM_SETSCROLLINFO
) | SET(SBM_GETSCROLLINFO
) | SET(SBM_GETSCROLLBARINFO
),
138 SET(CB_GETEDITSEL
) | SET(CB_ADDSTRING
) | SET(CB_DIR
) | SET(CB_GETLBTEXT
) |
139 SET(CB_INSERTSTRING
) | SET(CB_FINDSTRING
) | SET(CB_SELECTSTRING
) |
140 SET(CB_GETDROPPEDCONTROLRECT
) | SET(CB_FINDSTRINGEXACT
),
144 SET(LB_ADDSTRING
) | SET(LB_INSERTSTRING
) | SET(LB_GETTEXT
) | SET(LB_SELECTSTRING
) |
145 SET(LB_DIR
) | SET(LB_FINDSTRING
) |
146 SET(LB_GETSELITEMS
) | SET(LB_SETTABSTOPS
) | SET(LB_ADDFILE
) | SET(LB_GETITEMRECT
),
148 SET(LB_FINDSTRINGEXACT
),
154 SET(WM_NEXTMENU
) | SET(WM_SIZING
) | SET(WM_MOVING
) | SET(WM_DEVICECHANGE
),
156 SET(WM_MDICREATE
) | SET(WM_MDIGETACTIVE
) | SET(WM_DROPOBJECT
) |
157 SET(WM_QUERYDROPOBJECT
) | SET(WM_DRAGLOOP
) | SET(WM_DRAGSELECT
) | SET(WM_DRAGMOVE
),
171 SET(WM_ASKCBFORMATNAME
)
174 /* flags for messages that contain Unicode strings */
175 static const unsigned int message_unicode_flags
[] =
178 SET(WM_CREATE
) | SET(WM_SETTEXT
) | SET(WM_GETTEXT
) | SET(WM_GETTEXTLENGTH
) |
179 SET(WM_WININICHANGE
) | SET(WM_DEVMODECHANGE
),
191 SET(EM_REPLACESEL
) | SET(EM_GETLINE
) | SET(EM_SETPASSWORDCHAR
),
195 SET(WM_CHAR
) | SET(WM_DEADCHAR
) | SET(WM_SYSCHAR
) | SET(WM_SYSDEADCHAR
),
199 SET(CB_ADDSTRING
) | SET(CB_DIR
) | SET(CB_GETLBTEXT
) | SET(CB_GETLBTEXTLEN
) |
200 SET(CB_INSERTSTRING
) | SET(CB_FINDSTRING
) | SET(CB_SELECTSTRING
) | SET(CB_FINDSTRINGEXACT
),
204 SET(LB_ADDSTRING
) | SET(LB_INSERTSTRING
) | SET(LB_GETTEXT
) | SET(LB_GETTEXTLEN
) |
205 SET(LB_SELECTSTRING
) | SET(LB_DIR
) | SET(LB_FINDSTRING
) | SET(LB_ADDFILE
),
207 SET(LB_FINDSTRINGEXACT
),
229 SET(WM_PAINTCLIPBOARD
) | SET(WM_SIZECLIPBOARD
) | SET(WM_ASKCBFORMATNAME
)
232 /* check whether a given message type includes pointers */
233 static inline int is_pointer_message( UINT message
)
235 if (message
>= 8*sizeof(message_pointer_flags
)) return FALSE
;
236 return (message_pointer_flags
[message
/ 32] & SET(message
)) != 0;
239 /* check whether a given message type contains Unicode (or ASCII) chars */
240 static inline int is_unicode_message( UINT message
)
242 if (message
>= 8*sizeof(message_unicode_flags
)) return FALSE
;
243 return (message_unicode_flags
[message
/ 32] & SET(message
)) != 0;
248 /* add a data field to a packed message */
249 static inline void push_data( struct packed_message
*data
, const void *ptr
, size_t size
)
251 data
->data
[data
->count
] = ptr
;
252 data
->size
[data
->count
] = size
;
256 /* add a string to a packed message */
257 static inline void push_string( struct packed_message
*data
, LPCWSTR str
)
259 push_data( data
, str
, (strlenW(str
) + 1) * sizeof(WCHAR
) );
262 /* make sure that the buffer contains a valid null-terminated Unicode string */
263 static inline BOOL
check_string( LPCWSTR str
, size_t size
)
265 for (size
/= sizeof(WCHAR
); size
; size
--, str
++)
266 if (!*str
) return TRUE
;
270 /* make sure that there is space for 'size' bytes in buffer, growing it if needed */
271 static inline void *get_buffer_space( void **buffer
, size_t size
)
277 if (!(ret
= HeapReAlloc( GetProcessHeap(), 0, *buffer
, size
)))
278 HeapFree( GetProcessHeap(), 0, *buffer
);
280 else ret
= HeapAlloc( GetProcessHeap(), 0, size
);
286 /* check whether a combobox expects strings or ids in CB_ADDSTRING/CB_INSERTSTRING */
287 static inline BOOL
combobox_has_strings( HWND hwnd
)
289 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
290 return (!(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) || (style
& CBS_HASSTRINGS
));
293 /* check whether a listbox expects strings or ids in LB_ADDSTRING/LB_INSERTSTRING */
294 static inline BOOL
listbox_has_strings( HWND hwnd
)
296 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
297 return (!(style
& (LBS_OWNERDRAWFIXED
| LBS_OWNERDRAWVARIABLE
)) || (style
& LBS_HASSTRINGS
));
300 /* check whether message is in the range of keyboard messages */
301 static inline BOOL
is_keyboard_message( UINT message
)
303 return (message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
);
306 /* check whether message is in the range of mouse messages */
307 static inline BOOL
is_mouse_message( UINT message
)
309 return ((message
>= WM_NCMOUSEFIRST
&& message
<= WM_NCMOUSELAST
) ||
310 (message
>= WM_MOUSEFIRST
&& message
<= WM_MOUSELAST
));
313 /* check whether message matches the specified hwnd filter */
314 static inline BOOL
check_hwnd_filter( const MSG
*msg
, HWND hwnd_filter
)
316 if (!hwnd_filter
|| hwnd_filter
== GetDesktopWindow()) return TRUE
;
317 return (msg
->hwnd
== hwnd_filter
|| IsChild( hwnd_filter
, msg
->hwnd
));
320 /* check for pending WM_CHAR message with DBCS trailing byte */
321 static inline BOOL
get_pending_wmchar( MSG
*msg
, UINT first
, UINT last
, BOOL remove
)
323 struct wm_char_mapping_data
*data
= get_user_thread_info()->wmchar_data
;
325 if (!data
|| !data
->get_msg
.message
) return FALSE
;
326 if ((first
|| last
) && (first
> WM_CHAR
|| last
< WM_CHAR
)) return FALSE
;
327 if (!msg
) return FALSE
;
328 *msg
= data
->get_msg
;
329 if (remove
) data
->get_msg
.message
= 0;
334 /***********************************************************************
337 * Window procedure for "Message" windows (HWND_MESSAGE parent).
339 static LRESULT WINAPI
message_winproc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
341 if (message
== WM_NCCREATE
) return TRUE
;
342 return 0; /* all other messages are ignored */
346 /***********************************************************************
347 * broadcast_message_callback
349 * Helper callback for broadcasting messages.
351 static BOOL CALLBACK
broadcast_message_callback( HWND hwnd
, LPARAM lparam
)
353 struct send_message_info
*info
= (struct send_message_info
*)lparam
;
354 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & (WS_POPUP
|WS_CAPTION
))) return TRUE
;
358 SendMessageTimeoutW( hwnd
, info
->msg
, info
->wparam
, info
->lparam
,
359 info
->flags
, info
->timeout
, NULL
);
362 SendMessageTimeoutA( hwnd
, info
->msg
, info
->wparam
, info
->lparam
,
363 info
->flags
, info
->timeout
, NULL
);
366 SendNotifyMessageW( hwnd
, info
->msg
, info
->wparam
, info
->lparam
);
369 SendMessageCallbackW( hwnd
, info
->msg
, info
->wparam
, info
->lparam
,
370 info
->callback
, info
->data
);
373 PostMessageW( hwnd
, info
->msg
, info
->wparam
, info
->lparam
);
376 ERR( "bad type %d\n", info
->type
);
383 /***********************************************************************
386 * Convert the wparam of an ASCII message to Unicode.
388 BOOL
map_wparam_AtoW( UINT message
, WPARAM
*wparam
, enum wm_char_mapping mapping
)
397 /* WM_CHAR is magic: a DBCS char can be sent/posted as two consecutive WM_CHAR
398 * messages, in which case the first char is stored, and the conversion
399 * to Unicode only takes place once the second char is sent/posted.
401 if (mapping
!= WMCHAR_MAP_NOMAPPING
)
403 struct wm_char_mapping_data
*data
= get_user_thread_info()->wmchar_data
;
404 BYTE low
= LOBYTE(*wparam
);
409 ch
[1] = HIBYTE(*wparam
);
410 RtlMultiByteToUnicodeN( wch
, sizeof(wch
), NULL
, ch
, 2 );
411 TRACE( "map %02x,%02x -> %04x mapping %u\n", (BYTE
)ch
[0], (BYTE
)ch
[1], wch
[0], mapping
);
412 if (data
) data
->lead_byte
[mapping
] = 0;
414 else if (data
&& data
->lead_byte
[mapping
])
416 ch
[0] = data
->lead_byte
[mapping
];
418 RtlMultiByteToUnicodeN( wch
, sizeof(wch
), NULL
, ch
, 2 );
419 TRACE( "map stored %02x,%02x -> %04x mapping %u\n", (BYTE
)ch
[0], (BYTE
)ch
[1], wch
[0], mapping
);
420 data
->lead_byte
[mapping
] = 0;
422 else if (!IsDBCSLeadByte( low
))
425 RtlMultiByteToUnicodeN( wch
, sizeof(wch
), NULL
, ch
, 1 );
426 TRACE( "map %02x -> %04x\n", (BYTE
)ch
[0], wch
[0] );
427 if (data
) data
->lead_byte
[mapping
] = 0;
429 else /* store it and wait for trail byte */
433 if (!(data
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*data
) )))
435 get_user_thread_info()->wmchar_data
= data
;
437 TRACE( "storing lead byte %02x mapping %u\n", low
, mapping
);
438 data
->lead_byte
[mapping
] = low
;
441 *wparam
= MAKEWPARAM(wch
[0], wch
[1]);
444 /* else fall through */
446 case EM_SETPASSWORDCHAR
:
451 ch
[0] = LOBYTE(*wparam
);
452 ch
[1] = HIBYTE(*wparam
);
453 RtlMultiByteToUnicodeN( wch
, sizeof(wch
), NULL
, ch
, 2 );
454 *wparam
= MAKEWPARAM(wch
[0], wch
[1]);
457 ch
[0] = HIBYTE(*wparam
);
458 ch
[1] = LOBYTE(*wparam
);
459 if (ch
[0]) RtlMultiByteToUnicodeN( wch
, sizeof(wch
[0]), NULL
, ch
, 2 );
460 else RtlMultiByteToUnicodeN( wch
, sizeof(wch
[0]), NULL
, ch
+ 1, 1 );
461 *wparam
= MAKEWPARAM(wch
[0], HIWORD(*wparam
));
468 /***********************************************************************
471 * Convert the wparam of a Unicode message to ASCII.
473 static void map_wparam_WtoA( MSG
*msg
, BOOL remove
)
482 if (!HIWORD(msg
->wParam
))
484 wch
[0] = LOWORD(msg
->wParam
);
486 RtlUnicodeToMultiByteN( (LPSTR
)ch
, 2, &len
, wch
, sizeof(wch
[0]) );
487 if (len
== 2) /* DBCS char */
489 struct wm_char_mapping_data
*data
= get_user_thread_info()->wmchar_data
;
492 if (!(data
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*data
) ))) return;
493 get_user_thread_info()->wmchar_data
= data
;
497 data
->get_msg
= *msg
;
498 data
->get_msg
.wParam
= ch
[1];
504 /* else fall through */
506 case EM_SETPASSWORDCHAR
:
511 wch
[0] = LOWORD(msg
->wParam
);
512 wch
[1] = HIWORD(msg
->wParam
);
514 RtlUnicodeToMultiByteN( (LPSTR
)ch
, 2, NULL
, wch
, sizeof(wch
) );
515 msg
->wParam
= MAKEWPARAM( ch
[0] | (ch
[1] << 8), 0 );
518 wch
[0] = LOWORD(msg
->wParam
);
520 RtlUnicodeToMultiByteN( (LPSTR
)ch
, 2, &len
, wch
, sizeof(wch
[0]) );
522 msg
->wParam
= MAKEWPARAM( (ch
[0] << 8) | ch
[1], HIWORD(msg
->wParam
) );
524 msg
->wParam
= MAKEWPARAM( ch
[0], HIWORD(msg
->wParam
) );
530 /***********************************************************************
533 * Pack a message for sending to another process.
534 * Return the size of the data we expect in the message reply.
535 * Set data->count to -1 if there is an error.
537 static size_t pack_message( HWND hwnd
, UINT message
, WPARAM wparam
, LPARAM lparam
,
538 struct packed_message
*data
)
546 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lparam
;
547 push_data( data
, cs
, sizeof(*cs
) );
548 if (HIWORD(cs
->lpszName
)) push_string( data
, cs
->lpszName
);
549 if (HIWORD(cs
->lpszClass
)) push_string( data
, cs
->lpszClass
);
553 case WM_ASKCBFORMATNAME
:
554 return wparam
* sizeof(WCHAR
);
555 case WM_WININICHANGE
:
556 if (lparam
) push_string(data
, (LPWSTR
)lparam
);
559 case WM_DEVMODECHANGE
:
564 push_string( data
, (LPWSTR
)lparam
);
566 case WM_GETMINMAXINFO
:
567 push_data( data
, (MINMAXINFO
*)lparam
, sizeof(MINMAXINFO
) );
568 return sizeof(MINMAXINFO
);
570 push_data( data
, (DRAWITEMSTRUCT
*)lparam
, sizeof(DRAWITEMSTRUCT
) );
573 push_data( data
, (MEASUREITEMSTRUCT
*)lparam
, sizeof(MEASUREITEMSTRUCT
) );
574 return sizeof(MEASUREITEMSTRUCT
);
576 push_data( data
, (DELETEITEMSTRUCT
*)lparam
, sizeof(DELETEITEMSTRUCT
) );
579 push_data( data
, (COMPAREITEMSTRUCT
*)lparam
, sizeof(COMPAREITEMSTRUCT
) );
581 case WM_WINDOWPOSCHANGING
:
582 case WM_WINDOWPOSCHANGED
:
583 push_data( data
, (WINDOWPOS
*)lparam
, sizeof(WINDOWPOS
) );
584 return sizeof(WINDOWPOS
);
587 COPYDATASTRUCT
*cp
= (COPYDATASTRUCT
*)lparam
;
588 push_data( data
, cp
, sizeof(*cp
) );
589 if (cp
->lpData
) push_data( data
, cp
->lpData
, cp
->cbData
);
593 /* WM_NOTIFY cannot be sent across processes (MSDN) */
597 push_data( data
, (HELPINFO
*)lparam
, sizeof(HELPINFO
) );
599 case WM_STYLECHANGING
:
600 case WM_STYLECHANGED
:
601 push_data( data
, (STYLESTRUCT
*)lparam
, sizeof(STYLESTRUCT
) );
606 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
611 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lparam
;
612 push_data( data
, nc
, sizeof(*nc
) );
613 push_data( data
, nc
->lppos
, sizeof(*nc
->lppos
) );
614 return sizeof(*nc
) + sizeof(*nc
->lppos
);
617 if (lparam
) push_data( data
, (MSG
*)lparam
, sizeof(MSG
) );
619 case SBM_SETSCROLLINFO
:
620 push_data( data
, (SCROLLINFO
*)lparam
, sizeof(SCROLLINFO
) );
622 case SBM_GETSCROLLINFO
:
623 push_data( data
, (SCROLLINFO
*)lparam
, sizeof(SCROLLINFO
) );
624 return sizeof(SCROLLINFO
);
625 case SBM_GETSCROLLBARINFO
:
627 const SCROLLBARINFO
*info
= (const SCROLLBARINFO
*)lparam
;
628 size_t size
= min( info
->cbSize
, sizeof(SCROLLBARINFO
) );
629 push_data( data
, info
, size
);
637 if (wparam
) size
+= sizeof(DWORD
);
638 if (lparam
) size
+= sizeof(DWORD
);
643 case CB_GETDROPPEDCONTROLRECT
:
647 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
651 WORD
*pw
= (WORD
*)lparam
;
652 push_data( data
, pw
, sizeof(*pw
) );
653 return *pw
* sizeof(WCHAR
);
657 if (wparam
) push_data( data
, (UINT
*)lparam
, sizeof(UINT
) * wparam
);
660 case CB_INSERTSTRING
:
662 case CB_FINDSTRINGEXACT
:
663 case CB_SELECTSTRING
:
664 if (combobox_has_strings( hwnd
)) push_string( data
, (LPWSTR
)lparam
);
667 if (!combobox_has_strings( hwnd
)) return sizeof(ULONG_PTR
);
668 return (SendMessageW( hwnd
, CB_GETLBTEXTLEN
, wparam
, 0 ) + 1) * sizeof(WCHAR
);
670 case LB_INSERTSTRING
:
672 case LB_FINDSTRINGEXACT
:
673 case LB_SELECTSTRING
:
674 if (listbox_has_strings( hwnd
)) push_string( data
, (LPWSTR
)lparam
);
677 if (!listbox_has_strings( hwnd
)) return sizeof(ULONG_PTR
);
678 return (SendMessageW( hwnd
, LB_GETTEXTLEN
, wparam
, 0 ) + 1) * sizeof(WCHAR
);
680 return wparam
* sizeof(UINT
);
682 push_data( data
, (MDINEXTMENU
*)lparam
, sizeof(MDINEXTMENU
) );
683 return sizeof(MDINEXTMENU
);
686 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
690 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lparam
;
691 push_data( data
, cs
, sizeof(*cs
) );
692 if (HIWORD(cs
->szTitle
)) push_string( data
, cs
->szTitle
);
693 if (HIWORD(cs
->szClass
)) push_string( data
, cs
->szClass
);
696 case WM_MDIGETACTIVE
:
697 if (lparam
) return sizeof(BOOL
);
699 case WM_DEVICECHANGE
:
701 DEV_BROADCAST_HDR
*header
= (DEV_BROADCAST_HDR
*)lparam
;
702 push_data( data
, header
, header
->dbch_size
);
705 case WM_WINE_SETWINDOWPOS
:
706 push_data( data
, (WINDOWPOS
*)lparam
, sizeof(WINDOWPOS
) );
708 case WM_WINE_KEYBOARD_LL_HOOK
:
710 struct hook_extra_info
*h_extra
= (struct hook_extra_info
*)lparam
;
711 push_data( data
, h_extra
, sizeof(*h_extra
) );
712 push_data( data
, (LPVOID
)h_extra
->lparam
, sizeof(KBDLLHOOKSTRUCT
) );
715 case WM_WINE_MOUSE_LL_HOOK
:
717 struct hook_extra_info
*h_extra
= (struct hook_extra_info
*)lparam
;
718 push_data( data
, h_extra
, sizeof(*h_extra
) );
719 push_data( data
, (LPVOID
)h_extra
->lparam
, sizeof(MSLLHOOKSTRUCT
) );
723 if (wparam
<= 1) return 0;
724 FIXME( "WM_NCPAINT hdc packing not supported yet\n" );
728 if (!wparam
) return 0;
731 /* these contain an HFONT */
734 /* these contain an HDC */
736 case WM_ICONERASEBKGND
:
737 case WM_CTLCOLORMSGBOX
:
738 case WM_CTLCOLOREDIT
:
739 case WM_CTLCOLORLISTBOX
:
742 case WM_CTLCOLORSCROLLBAR
:
743 case WM_CTLCOLORSTATIC
:
746 /* these contain an HGLOBAL */
747 case WM_PAINTCLIPBOARD
:
748 case WM_SIZECLIPBOARD
:
749 /* these contain HICON */
752 case WM_QUERYDRAGICON
:
753 case WM_QUERYPARKICON
:
754 /* these contain pointers */
756 case WM_QUERYDROPOBJECT
:
760 FIXME( "msg %x (%s) not supported yet\n", message
, SPY_GetMsgName(message
, hwnd
) );
768 /***********************************************************************
771 * Unpack a message received from another process.
773 static BOOL
unpack_message( HWND hwnd
, UINT message
, WPARAM
*wparam
, LPARAM
*lparam
,
774 void **buffer
, size_t size
)
783 CREATESTRUCTW
*cs
= *buffer
;
784 WCHAR
*str
= (WCHAR
*)(cs
+ 1);
785 if (size
< sizeof(*cs
)) return FALSE
;
787 if (HIWORD(cs
->lpszName
))
789 if (!check_string( str
, size
)) return FALSE
;
791 size
-= (strlenW(str
) + 1) * sizeof(WCHAR
);
792 str
+= strlenW(str
) + 1;
794 if (HIWORD(cs
->lpszClass
))
796 if (!check_string( str
, size
)) return FALSE
;
802 case WM_ASKCBFORMATNAME
:
803 if (!get_buffer_space( buffer
, (*wparam
* sizeof(WCHAR
)) )) return FALSE
;
805 case WM_WININICHANGE
:
806 if (!*lparam
) return TRUE
;
809 case WM_DEVMODECHANGE
:
814 if (!check_string( *buffer
, size
)) return FALSE
;
816 case WM_GETMINMAXINFO
:
817 minsize
= sizeof(MINMAXINFO
);
820 minsize
= sizeof(DRAWITEMSTRUCT
);
823 minsize
= sizeof(MEASUREITEMSTRUCT
);
826 minsize
= sizeof(DELETEITEMSTRUCT
);
829 minsize
= sizeof(COMPAREITEMSTRUCT
);
831 case WM_WINDOWPOSCHANGING
:
832 case WM_WINDOWPOSCHANGED
:
833 case WM_WINE_SETWINDOWPOS
:
834 minsize
= sizeof(WINDOWPOS
);
838 COPYDATASTRUCT
*cp
= *buffer
;
839 if (size
< sizeof(*cp
)) return FALSE
;
842 minsize
= sizeof(*cp
) + cp
->cbData
;
848 /* WM_NOTIFY cannot be sent across processes (MSDN) */
851 minsize
= sizeof(HELPINFO
);
853 case WM_STYLECHANGING
:
854 case WM_STYLECHANGED
:
855 minsize
= sizeof(STYLESTRUCT
);
858 if (!*wparam
) minsize
= sizeof(RECT
);
861 NCCALCSIZE_PARAMS
*nc
= *buffer
;
862 if (size
< sizeof(*nc
) + sizeof(*nc
->lppos
)) return FALSE
;
863 nc
->lppos
= (WINDOWPOS
*)(nc
+ 1);
867 if (!*lparam
) return TRUE
;
868 minsize
= sizeof(MSG
);
870 case SBM_SETSCROLLINFO
:
871 minsize
= sizeof(SCROLLINFO
);
873 case SBM_GETSCROLLINFO
:
874 if (!get_buffer_space( buffer
, sizeof(SCROLLINFO
))) return FALSE
;
876 case SBM_GETSCROLLBARINFO
:
877 if (!get_buffer_space( buffer
, sizeof(SCROLLBARINFO
))) return FALSE
;
882 if (*wparam
|| *lparam
)
884 if (!get_buffer_space( buffer
, 2*sizeof(DWORD
) )) return FALSE
;
885 if (*wparam
) *wparam
= (WPARAM
)*buffer
;
886 if (*lparam
) *lparam
= (LPARAM
)((DWORD
*)*buffer
+ 1);
891 case CB_GETDROPPEDCONTROLRECT
:
892 if (!get_buffer_space( buffer
, sizeof(RECT
) )) return FALSE
;
896 minsize
= sizeof(RECT
);
901 if (size
< sizeof(WORD
)) return FALSE
;
902 len
= *(WORD
*)*buffer
;
903 if (!get_buffer_space( buffer
, (len
+ 1) * sizeof(WCHAR
) )) return FALSE
;
904 *lparam
= (LPARAM
)*buffer
+ sizeof(WORD
); /* don't erase WORD at start of buffer */
909 if (!*wparam
) return TRUE
;
910 minsize
= *wparam
* sizeof(UINT
);
913 case CB_INSERTSTRING
:
915 case CB_FINDSTRINGEXACT
:
916 case CB_SELECTSTRING
:
918 case LB_INSERTSTRING
:
920 case LB_FINDSTRINGEXACT
:
921 case LB_SELECTSTRING
:
922 if (!*buffer
) return TRUE
;
923 if (!check_string( *buffer
, size
)) return FALSE
;
927 size
= sizeof(ULONG_PTR
);
928 if (combobox_has_strings( hwnd
))
929 size
= (SendMessageW( hwnd
, CB_GETLBTEXTLEN
, *wparam
, 0 ) + 1) * sizeof(WCHAR
);
930 if (!get_buffer_space( buffer
, size
)) return FALSE
;
935 size
= sizeof(ULONG_PTR
);
936 if (listbox_has_strings( hwnd
))
937 size
= (SendMessageW( hwnd
, LB_GETTEXTLEN
, *wparam
, 0 ) + 1) * sizeof(WCHAR
);
938 if (!get_buffer_space( buffer
, size
)) return FALSE
;
942 if (!get_buffer_space( buffer
, *wparam
* sizeof(UINT
) )) return FALSE
;
945 minsize
= sizeof(MDINEXTMENU
);
946 if (!get_buffer_space( buffer
, sizeof(MDINEXTMENU
) )) return FALSE
;
950 minsize
= sizeof(RECT
);
951 if (!get_buffer_space( buffer
, sizeof(RECT
) )) return FALSE
;
955 MDICREATESTRUCTW
*cs
= *buffer
;
956 WCHAR
*str
= (WCHAR
*)(cs
+ 1);
957 if (size
< sizeof(*cs
)) return FALSE
;
959 if (HIWORD(cs
->szTitle
))
961 if (!check_string( str
, size
)) return FALSE
;
963 size
-= (strlenW(str
) + 1) * sizeof(WCHAR
);
964 str
+= strlenW(str
) + 1;
966 if (HIWORD(cs
->szClass
))
968 if (!check_string( str
, size
)) return FALSE
;
973 case WM_MDIGETACTIVE
:
974 if (!*lparam
) return TRUE
;
975 if (!get_buffer_space( buffer
, sizeof(BOOL
) )) return FALSE
;
977 case WM_DEVICECHANGE
:
978 minsize
= sizeof(DEV_BROADCAST_HDR
);
980 case WM_WINE_KEYBOARD_LL_HOOK
:
981 case WM_WINE_MOUSE_LL_HOOK
:
983 struct hook_extra_info
*h_extra
= *buffer
;
985 minsize
= sizeof(struct hook_extra_info
) +
986 (message
== WM_WINE_KEYBOARD_LL_HOOK
? sizeof(KBDLLHOOKSTRUCT
)
987 : sizeof(MSLLHOOKSTRUCT
));
988 if (size
< minsize
) return FALSE
;
989 h_extra
->lparam
= (LPARAM
)(h_extra
+ 1);
993 if (*wparam
<= 1) return TRUE
;
994 FIXME( "WM_NCPAINT hdc unpacking not supported\n" );
997 if (!*wparam
) return TRUE
;
1000 /* these contain an HFONT */
1003 /* these contain an HDC */
1005 case WM_ICONERASEBKGND
:
1006 case WM_CTLCOLORMSGBOX
:
1007 case WM_CTLCOLOREDIT
:
1008 case WM_CTLCOLORLISTBOX
:
1009 case WM_CTLCOLORBTN
:
1010 case WM_CTLCOLORDLG
:
1011 case WM_CTLCOLORSCROLLBAR
:
1012 case WM_CTLCOLORSTATIC
:
1014 case WM_PRINTCLIENT
:
1015 /* these contain an HGLOBAL */
1016 case WM_PAINTCLIPBOARD
:
1017 case WM_SIZECLIPBOARD
:
1018 /* these contain HICON */
1021 case WM_QUERYDRAGICON
:
1022 case WM_QUERYPARKICON
:
1023 /* these contain pointers */
1025 case WM_QUERYDROPOBJECT
:
1029 FIXME( "msg %x (%s) not supported yet\n", message
, SPY_GetMsgName(message
, hwnd
) );
1033 return TRUE
; /* message doesn't need any unpacking */
1036 /* default exit for most messages: check minsize and store buffer in lparam */
1037 if (size
< minsize
) return FALSE
;
1038 *lparam
= (LPARAM
)*buffer
;
1043 /***********************************************************************
1046 * Pack a reply to a message for sending to another process.
1048 static void pack_reply( HWND hwnd
, UINT message
, WPARAM wparam
, LPARAM lparam
,
1049 LRESULT res
, struct packed_message
*data
)
1056 push_data( data
, (CREATESTRUCTW
*)lparam
, sizeof(CREATESTRUCTW
) );
1061 push_data( data
, (WCHAR
*)lparam
, (res
+ 1) * sizeof(WCHAR
) );
1063 case WM_GETMINMAXINFO
:
1064 push_data( data
, (MINMAXINFO
*)lparam
, sizeof(MINMAXINFO
) );
1066 case WM_MEASUREITEM
:
1067 push_data( data
, (MEASUREITEMSTRUCT
*)lparam
, sizeof(MEASUREITEMSTRUCT
) );
1069 case WM_WINDOWPOSCHANGING
:
1070 case WM_WINDOWPOSCHANGED
:
1071 push_data( data
, (WINDOWPOS
*)lparam
, sizeof(WINDOWPOS
) );
1074 if (lparam
) push_data( data
, (MSG
*)lparam
, sizeof(MSG
) );
1076 case SBM_GETSCROLLINFO
:
1077 push_data( data
, (SCROLLINFO
*)lparam
, sizeof(SCROLLINFO
) );
1080 case LB_GETITEMRECT
:
1081 case CB_GETDROPPEDCONTROLRECT
:
1084 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
1088 WORD
*ptr
= (WORD
*)lparam
;
1089 push_data( data
, ptr
, ptr
[-1] * sizeof(WCHAR
) );
1092 case LB_GETSELITEMS
:
1093 push_data( data
, (UINT
*)lparam
, wparam
* sizeof(UINT
) );
1095 case WM_MDIGETACTIVE
:
1096 if (lparam
) push_data( data
, (BOOL
*)lparam
, sizeof(BOOL
) );
1100 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
1103 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lparam
;
1104 push_data( data
, nc
, sizeof(*nc
) );
1105 push_data( data
, nc
->lppos
, sizeof(*nc
->lppos
) );
1111 if (wparam
) push_data( data
, (DWORD
*)wparam
, sizeof(DWORD
) );
1112 if (lparam
) push_data( data
, (DWORD
*)lparam
, sizeof(DWORD
) );
1115 push_data( data
, (MDINEXTMENU
*)lparam
, sizeof(MDINEXTMENU
) );
1118 push_data( data
, (MDICREATESTRUCTW
*)lparam
, sizeof(MDICREATESTRUCTW
) );
1120 case WM_ASKCBFORMATNAME
:
1121 push_data( data
, (WCHAR
*)lparam
, (strlenW((WCHAR
*)lparam
) + 1) * sizeof(WCHAR
) );
1127 /***********************************************************************
1130 * Unpack a message reply received from another process.
1132 static void unpack_reply( HWND hwnd
, UINT message
, WPARAM wparam
, LPARAM lparam
,
1133 void *buffer
, size_t size
)
1140 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lparam
;
1141 LPCWSTR name
= cs
->lpszName
, class = cs
->lpszClass
;
1142 memcpy( cs
, buffer
, min( sizeof(*cs
), size
));
1143 cs
->lpszName
= name
; /* restore the original pointers */
1144 cs
->lpszClass
= class;
1148 case WM_ASKCBFORMATNAME
:
1149 memcpy( (WCHAR
*)lparam
, buffer
, min( wparam
*sizeof(WCHAR
), size
));
1151 case WM_GETMINMAXINFO
:
1152 memcpy( (MINMAXINFO
*)lparam
, buffer
, min( sizeof(MINMAXINFO
), size
));
1154 case WM_MEASUREITEM
:
1155 memcpy( (MEASUREITEMSTRUCT
*)lparam
, buffer
, min( sizeof(MEASUREITEMSTRUCT
), size
));
1157 case WM_WINDOWPOSCHANGING
:
1158 case WM_WINDOWPOSCHANGED
:
1159 memcpy( (WINDOWPOS
*)lparam
, buffer
, min( sizeof(WINDOWPOS
), size
));
1162 if (lparam
) memcpy( (MSG
*)lparam
, buffer
, min( sizeof(MSG
), size
));
1164 case SBM_GETSCROLLINFO
:
1165 memcpy( (SCROLLINFO
*)lparam
, buffer
, min( sizeof(SCROLLINFO
), size
));
1167 case SBM_GETSCROLLBARINFO
:
1168 memcpy( (SCROLLBARINFO
*)lparam
, buffer
, min( sizeof(SCROLLBARINFO
), size
));
1171 case CB_GETDROPPEDCONTROLRECT
:
1172 case LB_GETITEMRECT
:
1175 memcpy( (RECT
*)lparam
, buffer
, min( sizeof(RECT
), size
));
1178 size
= min( size
, (size_t)*(WORD
*)lparam
);
1179 memcpy( (WCHAR
*)lparam
, buffer
, size
);
1181 case LB_GETSELITEMS
:
1182 memcpy( (UINT
*)lparam
, buffer
, min( wparam
*sizeof(UINT
), size
));
1186 memcpy( (WCHAR
*)lparam
, buffer
, size
);
1189 memcpy( (MDINEXTMENU
*)lparam
, buffer
, min( sizeof(MDINEXTMENU
), size
));
1191 case WM_MDIGETACTIVE
:
1192 if (lparam
) memcpy( (BOOL
*)lparam
, buffer
, min( sizeof(BOOL
), size
));
1196 memcpy( (RECT
*)lparam
, buffer
, min( sizeof(RECT
), size
));
1199 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lparam
;
1200 WINDOWPOS
*wp
= nc
->lppos
;
1201 memcpy( nc
, buffer
, min( sizeof(*nc
), size
));
1202 if (size
> sizeof(*nc
))
1204 size
-= sizeof(*nc
);
1205 memcpy( wp
, (NCCALCSIZE_PARAMS
*)buffer
+ 1, min( sizeof(*wp
), size
));
1207 nc
->lppos
= wp
; /* restore the original pointer */
1215 memcpy( (DWORD
*)wparam
, buffer
, min( sizeof(DWORD
), size
));
1216 if (size
<= sizeof(DWORD
)) break;
1217 size
-= sizeof(DWORD
);
1218 buffer
= (DWORD
*)buffer
+ 1;
1220 if (lparam
) memcpy( (DWORD
*)lparam
, buffer
, min( sizeof(DWORD
), size
));
1224 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lparam
;
1225 LPCWSTR title
= cs
->szTitle
, class = cs
->szClass
;
1226 memcpy( cs
, buffer
, min( sizeof(*cs
), size
));
1227 cs
->szTitle
= title
; /* restore the original pointers */
1228 cs
->szClass
= class;
1232 ERR( "should not happen: unexpected message %x\n", message
);
1238 /***********************************************************************
1241 * Send a reply to a sent message.
1243 static void reply_message( struct received_message_info
*info
, LRESULT result
, BOOL remove
)
1245 struct packed_message data
;
1246 int i
, replied
= info
->flags
& ISMEX_REPLIED
;
1248 if (info
->flags
& ISMEX_NOTIFY
) return; /* notify messages don't get replies */
1249 if (!remove
&& replied
) return; /* replied already */
1252 info
->flags
|= ISMEX_REPLIED
;
1254 if (info
->type
== MSG_OTHER_PROCESS
&& !replied
)
1256 pack_reply( info
->msg
.hwnd
, info
->msg
.message
, info
->msg
.wParam
,
1257 info
->msg
.lParam
, result
, &data
);
1260 SERVER_START_REQ( reply_message
)
1262 req
->result
= result
;
1263 req
->remove
= remove
;
1264 for (i
= 0; i
< data
.count
; i
++) wine_server_add_data( req
, data
.data
[i
], data
.size
[i
] );
1265 wine_server_call( req
);
1271 /***********************************************************************
1272 * handle_internal_message
1274 * Handle an internal Wine message instead of calling the window proc.
1276 static LRESULT
handle_internal_message( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1280 case WM_WINE_DESTROYWINDOW
:
1281 return WIN_DestroyWindow( hwnd
);
1282 case WM_WINE_SETWINDOWPOS
:
1283 if (is_desktop_window( hwnd
)) return 0;
1284 return USER_SetWindowPos( (WINDOWPOS
*)lparam
);
1285 case WM_WINE_SHOWWINDOW
:
1286 if (is_desktop_window( hwnd
)) return 0;
1287 return ShowWindow( hwnd
, wparam
);
1288 case WM_WINE_SETPARENT
:
1289 if (is_desktop_window( hwnd
)) return 0;
1290 return (LRESULT
)SetParent( hwnd
, (HWND
)wparam
);
1291 case WM_WINE_SETWINDOWLONG
:
1292 return WIN_SetWindowLong( hwnd
, (short)LOWORD(wparam
), HIWORD(wparam
), lparam
, TRUE
);
1293 case WM_WINE_ENABLEWINDOW
:
1294 if (is_desktop_window( hwnd
)) return 0;
1295 return EnableWindow( hwnd
, wparam
);
1296 case WM_WINE_SETACTIVEWINDOW
:
1297 if (is_desktop_window( hwnd
)) return 0;
1298 return (LRESULT
)SetActiveWindow( (HWND
)wparam
);
1299 case WM_WINE_KEYBOARD_LL_HOOK
:
1300 case WM_WINE_MOUSE_LL_HOOK
:
1302 struct hook_extra_info
*h_extra
= (struct hook_extra_info
*)lparam
;
1304 return call_current_hook( h_extra
->handle
, HC_ACTION
, wparam
, h_extra
->lparam
);
1307 if (msg
>= WM_WINE_FIRST_DRIVER_MSG
&& msg
<= WM_WINE_LAST_DRIVER_MSG
)
1308 return USER_Driver
->pWindowMessage( hwnd
, msg
, wparam
, lparam
);
1309 FIXME( "unknown internal message %x\n", msg
);
1314 /* since the WM_DDE_ACK response to a WM_DDE_EXECUTE message should contain the handle
1315 * to the memory handle, we keep track (in the server side) of all pairs of handle
1316 * used (the client passes its value and the content of the memory handle), and
1317 * the server stored both values (the client, and the local one, created after the
1318 * content). When a ACK message is generated, the list of pair is searched for a
1319 * matching pair, so that the client memory handle can be returned.
1322 HGLOBAL client_hMem
;
1323 HGLOBAL server_hMem
;
1326 static struct DDE_pair
* dde_pairs
;
1327 static int dde_num_alloc
;
1328 static int dde_num_used
;
1330 static CRITICAL_SECTION dde_crst
;
1331 static CRITICAL_SECTION_DEBUG critsect_debug
=
1334 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
1335 0, 0, { (DWORD_PTR
)(__FILE__
": dde_crst") }
1337 static CRITICAL_SECTION dde_crst
= { &critsect_debug
, -1, 0, 0, 0, 0 };
1339 static BOOL
dde_add_pair(HGLOBAL chm
, HGLOBAL shm
)
1344 EnterCriticalSection(&dde_crst
);
1346 /* now remember the pair of hMem on both sides */
1347 if (dde_num_used
== dde_num_alloc
)
1349 struct DDE_pair
* tmp
;
1351 tmp
= HeapReAlloc( GetProcessHeap(), 0, dde_pairs
,
1352 (dde_num_alloc
+ GROWBY
) * sizeof(struct DDE_pair
));
1354 tmp
= HeapAlloc( GetProcessHeap(), 0,
1355 (dde_num_alloc
+ GROWBY
) * sizeof(struct DDE_pair
));
1359 LeaveCriticalSection(&dde_crst
);
1363 /* zero out newly allocated part */
1364 memset(&dde_pairs
[dde_num_alloc
], 0, GROWBY
* sizeof(struct DDE_pair
));
1365 dde_num_alloc
+= GROWBY
;
1368 for (i
= 0; i
< dde_num_alloc
; i
++)
1370 if (dde_pairs
[i
].server_hMem
== 0)
1372 dde_pairs
[i
].client_hMem
= chm
;
1373 dde_pairs
[i
].server_hMem
= shm
;
1378 LeaveCriticalSection(&dde_crst
);
1382 static HGLOBAL
dde_get_pair(HGLOBAL shm
)
1387 EnterCriticalSection(&dde_crst
);
1388 for (i
= 0; i
< dde_num_alloc
; i
++)
1390 if (dde_pairs
[i
].server_hMem
== shm
)
1392 /* free this pair */
1393 dde_pairs
[i
].server_hMem
= 0;
1395 ret
= dde_pairs
[i
].client_hMem
;
1399 LeaveCriticalSection(&dde_crst
);
1403 /***********************************************************************
1406 * Post a DDE message
1408 static BOOL
post_dde_message( struct packed_message
*data
, const struct send_message_info
*info
)
1412 UINT_PTR uiLo
, uiHi
;
1414 HGLOBAL hunlock
= 0;
1418 if (!UnpackDDElParam( info
->msg
, info
->lparam
, &uiLo
, &uiHi
))
1424 /* DDE messages which don't require packing are:
1433 /* uiHi should contain a hMem from WM_DDE_EXECUTE */
1434 HGLOBAL h
= dde_get_pair( (HANDLE
)uiHi
);
1437 /* send back the value of h on the other side */
1438 push_data( data
, &h
, sizeof(HGLOBAL
) );
1440 TRACE( "send dde-ack %lx %08lx => %p\n", uiLo
, uiHi
, h
);
1445 /* uiHi should contain either an atom or 0 */
1446 TRACE( "send dde-ack %lx atom=%lx\n", uiLo
, uiHi
);
1447 lp
= MAKELONG( uiLo
, uiHi
);
1456 size
= GlobalSize( (HGLOBAL
)uiLo
) ;
1457 if ((info
->msg
== WM_DDE_ADVISE
&& size
< sizeof(DDEADVISE
)) ||
1458 (info
->msg
== WM_DDE_DATA
&& size
< FIELD_OFFSET(DDEDATA
, Value
)) ||
1459 (info
->msg
== WM_DDE_POKE
&& size
< FIELD_OFFSET(DDEPOKE
, Value
))
1463 else if (info
->msg
!= WM_DDE_DATA
) return FALSE
;
1468 if ((ptr
= GlobalLock( (HGLOBAL
)uiLo
) ))
1470 DDEDATA
*dde_data
= ptr
;
1471 TRACE("unused %d, fResponse %d, fRelease %d, fDeferUpd %d, fAckReq %d, cfFormat %d\n",
1472 dde_data
->unused
, dde_data
->fResponse
, dde_data
->fRelease
,
1473 dde_data
->reserved
, dde_data
->fAckReq
, dde_data
->cfFormat
);
1474 push_data( data
, ptr
, size
);
1475 hunlock
= (HGLOBAL
)uiLo
;
1478 TRACE( "send ddepack %u %lx\n", size
, uiHi
);
1480 case WM_DDE_EXECUTE
:
1483 if ((ptr
= GlobalLock( (HGLOBAL
)info
->lparam
) ))
1485 push_data(data
, ptr
, GlobalSize( (HGLOBAL
)info
->lparam
));
1486 /* so that the other side can send it back on ACK */
1488 hunlock
= (HGLOBAL
)info
->lparam
;
1493 SERVER_START_REQ( send_message
)
1495 req
->id
= info
->dest_tid
;
1496 req
->type
= info
->type
;
1498 req
->win
= wine_server_user_handle( info
->hwnd
);
1499 req
->msg
= info
->msg
;
1500 req
->wparam
= info
->wparam
;
1502 req
->timeout
= TIMEOUT_INFINITE
;
1503 for (i
= 0; i
< data
->count
; i
++)
1504 wine_server_add_data( req
, data
->data
[i
], data
->size
[i
] );
1505 if ((res
= wine_server_call( req
)))
1507 if (res
== STATUS_INVALID_PARAMETER
)
1508 /* FIXME: find a STATUS_ value for this one */
1509 SetLastError( ERROR_INVALID_THREAD_ID
);
1511 SetLastError( RtlNtStatusToDosError(res
) );
1514 FreeDDElParam(info
->msg
, info
->lparam
);
1517 if (hunlock
) GlobalUnlock(hunlock
);
1522 /***********************************************************************
1523 * unpack_dde_message
1525 * Unpack a posted DDE message received from another process.
1527 static BOOL
unpack_dde_message( HWND hwnd
, UINT message
, WPARAM
*wparam
, LPARAM
*lparam
,
1528 void **buffer
, size_t size
)
1530 UINT_PTR uiLo
, uiHi
;
1539 /* hMem is being passed */
1540 if (size
!= sizeof(HGLOBAL
)) return FALSE
;
1541 if (!buffer
|| !*buffer
) return FALSE
;
1543 memcpy( &hMem
, *buffer
, size
);
1544 uiHi
= (UINT_PTR
)hMem
;
1545 TRACE("recv dde-ack %lx mem=%lx[%lx]\n", uiLo
, uiHi
, GlobalSize( hMem
));
1549 uiLo
= LOWORD( *lparam
);
1550 uiHi
= HIWORD( *lparam
);
1551 TRACE("recv dde-ack %lx atom=%lx\n", uiLo
, uiHi
);
1553 *lparam
= PackDDElParam( WM_DDE_ACK
, uiLo
, uiHi
);
1558 if ((!buffer
|| !*buffer
) && message
!= WM_DDE_DATA
) return FALSE
;
1562 if (!(hMem
= GlobalAlloc( GMEM_MOVEABLE
|GMEM_DDESHARE
, size
)))
1564 if ((ptr
= GlobalLock( hMem
)))
1566 memcpy( ptr
, *buffer
, size
);
1567 GlobalUnlock( hMem
);
1575 uiLo
= (UINT_PTR
)hMem
;
1577 *lparam
= PackDDElParam( message
, uiLo
, uiHi
);
1579 case WM_DDE_EXECUTE
:
1582 if (!buffer
|| !*buffer
) return FALSE
;
1583 if (!(hMem
= GlobalAlloc( GMEM_MOVEABLE
|GMEM_DDESHARE
, size
))) return FALSE
;
1584 if ((ptr
= GlobalLock( hMem
)))
1586 memcpy( ptr
, *buffer
, size
);
1587 GlobalUnlock( hMem
);
1588 TRACE( "exec: pairing c=%08lx s=%p\n", *lparam
, hMem
);
1589 if (!dde_add_pair( (HGLOBAL
)*lparam
, hMem
))
1600 } else return FALSE
;
1601 *lparam
= (LPARAM
)hMem
;
1607 /***********************************************************************
1610 * Call a window procedure and the corresponding hooks.
1612 static LRESULT
call_window_proc( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
1613 BOOL unicode
, BOOL same_thread
, enum wm_char_mapping mapping
)
1617 CWPRETSTRUCT cwpret
;
1619 if (msg
& 0x80000000)
1621 result
= handle_internal_message( hwnd
, msg
, wparam
, lparam
);
1625 /* first the WH_CALLWNDPROC hook */
1626 hwnd
= WIN_GetFullHandle( hwnd
);
1627 cwp
.lParam
= lparam
;
1628 cwp
.wParam
= wparam
;
1631 HOOK_CallHooks( WH_CALLWNDPROC
, HC_ACTION
, same_thread
, (LPARAM
)&cwp
, unicode
);
1633 /* now call the window procedure */
1634 if (!WINPROC_call_window( hwnd
, msg
, wparam
, lparam
, &result
, unicode
, mapping
)) goto done
;
1636 /* and finally the WH_CALLWNDPROCRET hook */
1637 cwpret
.lResult
= result
;
1638 cwpret
.lParam
= lparam
;
1639 cwpret
.wParam
= wparam
;
1640 cwpret
.message
= msg
;
1642 HOOK_CallHooks( WH_CALLWNDPROCRET
, HC_ACTION
, same_thread
, (LPARAM
)&cwpret
, unicode
);
1648 /***********************************************************************
1649 * send_parent_notify
1651 * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
1652 * the window has the WS_EX_NOPARENTNOTIFY style.
1654 static void send_parent_notify( HWND hwnd
, WORD event
, WORD idChild
, POINT pt
)
1656 /* pt has to be in the client coordinates of the parent window */
1657 MapWindowPoints( 0, hwnd
, &pt
, 1 );
1662 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)) break;
1663 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_NOPARENTNOTIFY
) break;
1664 if (!(parent
= GetParent(hwnd
))) break;
1665 if (parent
== GetDesktopWindow()) break;
1666 MapWindowPoints( hwnd
, parent
, &pt
, 1 );
1668 SendMessageW( hwnd
, WM_PARENTNOTIFY
,
1669 MAKEWPARAM( event
, idChild
), MAKELPARAM( pt
.x
, pt
.y
) );
1674 /***********************************************************************
1675 * accept_hardware_message
1677 * Tell the server we have passed the message to the app
1678 * (even though we may end up dropping it later on)
1680 static void accept_hardware_message( UINT hw_id
, BOOL remove
, HWND new_hwnd
)
1682 SERVER_START_REQ( accept_hardware_message
)
1685 req
->remove
= remove
;
1686 req
->new_win
= wine_server_user_handle( new_hwnd
);
1687 if (wine_server_call( req
))
1688 FIXME("Failed to reply to MSG_HARDWARE message. Message may not be removed from queue.\n");
1694 /***********************************************************************
1695 * process_keyboard_message
1697 * returns TRUE if the contents of 'msg' should be passed to the application
1699 static BOOL
process_keyboard_message( MSG
*msg
, UINT hw_id
, HWND hwnd_filter
,
1700 UINT first
, UINT last
, BOOL remove
)
1704 if (msg
->message
== WM_KEYDOWN
|| msg
->message
== WM_SYSKEYDOWN
||
1705 msg
->message
== WM_KEYUP
|| msg
->message
== WM_SYSKEYUP
)
1706 switch (msg
->wParam
)
1708 case VK_LSHIFT
: case VK_RSHIFT
:
1709 msg
->wParam
= VK_SHIFT
;
1711 case VK_LCONTROL
: case VK_RCONTROL
:
1712 msg
->wParam
= VK_CONTROL
;
1714 case VK_LMENU
: case VK_RMENU
:
1715 msg
->wParam
= VK_MENU
;
1719 /* FIXME: is this really the right place for this hook? */
1720 event
.message
= msg
->message
;
1721 event
.hwnd
= msg
->hwnd
;
1722 event
.time
= msg
->time
;
1723 event
.paramL
= (msg
->wParam
& 0xFF) | (HIWORD(msg
->lParam
) << 8);
1724 event
.paramH
= msg
->lParam
& 0x7FFF;
1725 if (HIWORD(msg
->lParam
) & 0x0100) event
.paramH
|= 0x8000; /* special_key - bit */
1726 HOOK_CallHooks( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
, TRUE
);
1728 /* check message filters */
1729 if (msg
->message
< first
|| msg
->message
> last
) return FALSE
;
1730 if (!check_hwnd_filter( msg
, hwnd_filter
)) return FALSE
;
1734 if((msg
->message
== WM_KEYDOWN
) &&
1735 (msg
->hwnd
!= GetDesktopWindow()))
1737 /* Handle F1 key by sending out WM_HELP message */
1738 if (msg
->wParam
== VK_F1
)
1740 PostMessageW( msg
->hwnd
, WM_KEYF1
, 0, 0 );
1742 else if(msg
->wParam
>= VK_BROWSER_BACK
&&
1743 msg
->wParam
<= VK_LAUNCH_APP2
)
1745 /* FIXME: Process keystate */
1746 SendMessageW(msg
->hwnd
, WM_APPCOMMAND
, (WPARAM
)msg
->hwnd
, MAKELPARAM(0, (FAPPCOMMAND_KEY
| (msg
->wParam
- VK_BROWSER_BACK
+ 1))));
1749 else if (msg
->message
== WM_KEYUP
)
1751 /* Handle VK_APPS key by posting a WM_CONTEXTMENU message */
1752 if (msg
->wParam
== VK_APPS
&& !MENU_IsMenuActive())
1753 PostMessageW(msg
->hwnd
, WM_CONTEXTMENU
, (WPARAM
)msg
->hwnd
, (LPARAM
)-1);
1757 if (HOOK_CallHooks( WH_KEYBOARD
, remove
? HC_ACTION
: HC_NOREMOVE
,
1758 LOWORD(msg
->wParam
), msg
->lParam
, TRUE
))
1760 /* skip this message */
1761 HOOK_CallHooks( WH_CBT
, HCBT_KEYSKIPPED
, LOWORD(msg
->wParam
), msg
->lParam
, TRUE
);
1762 accept_hardware_message( hw_id
, TRUE
, 0 );
1765 accept_hardware_message( hw_id
, remove
, 0 );
1767 if ( msg
->message
== WM_KEYDOWN
|| msg
->message
== WM_KEYUP
)
1768 if ( ImmProcessKey(msg
->hwnd
, GetKeyboardLayout(0), msg
->wParam
, msg
->lParam
, 0) )
1769 msg
->wParam
= VK_PROCESSKEY
;
1775 /***********************************************************************
1776 * process_mouse_message
1778 * returns TRUE if the contents of 'msg' should be passed to the application
1780 static BOOL
process_mouse_message( MSG
*msg
, UINT hw_id
, ULONG_PTR extra_info
, HWND hwnd_filter
,
1781 UINT first
, UINT last
, BOOL remove
)
1790 MOUSEHOOKSTRUCT hook
;
1793 /* find the window to dispatch this mouse message to */
1795 GetGUIThreadInfo( GetCurrentThreadId(), &info
);
1796 if (info
.hwndCapture
)
1799 msg
->hwnd
= info
.hwndCapture
;
1803 msg
->hwnd
= WINPOS_WindowFromPoint( msg
->hwnd
, msg
->pt
, &hittest
);
1806 if (!msg
->hwnd
|| !WIN_IsCurrentThread( msg
->hwnd
))
1808 accept_hardware_message( hw_id
, TRUE
, msg
->hwnd
);
1812 /* FIXME: is this really the right place for this hook? */
1813 event
.message
= msg
->message
;
1814 event
.time
= msg
->time
;
1815 event
.hwnd
= msg
->hwnd
;
1816 event
.paramL
= msg
->pt
.x
;
1817 event
.paramH
= msg
->pt
.y
;
1818 HOOK_CallHooks( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
, TRUE
);
1820 if (!check_hwnd_filter( msg
, hwnd_filter
)) return FALSE
;
1823 message
= msg
->message
;
1824 /* Note: windows has no concept of a non-client wheel message */
1825 if (message
!= WM_MOUSEWHEEL
)
1827 if (hittest
!= HTCLIENT
)
1829 message
+= WM_NCMOUSEMOVE
- WM_MOUSEMOVE
;
1830 msg
->wParam
= hittest
;
1834 /* coordinates don't get translated while tracking a menu */
1835 /* FIXME: should differentiate popups and top-level menus */
1836 if (!(info
.flags
& GUI_INMENUMODE
))
1837 ScreenToClient( msg
->hwnd
, &pt
);
1840 msg
->lParam
= MAKELONG( pt
.x
, pt
.y
);
1842 /* translate double clicks */
1844 if ((msg
->message
== WM_LBUTTONDOWN
) ||
1845 (msg
->message
== WM_RBUTTONDOWN
) ||
1846 (msg
->message
== WM_MBUTTONDOWN
) ||
1847 (msg
->message
== WM_XBUTTONDOWN
))
1849 BOOL update
= remove
;
1851 /* translate double clicks -
1852 * note that ...MOUSEMOVEs can slip in between
1853 * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
1855 if ((info
.flags
& (GUI_INMENUMODE
|GUI_INMOVESIZE
)) ||
1856 hittest
!= HTCLIENT
||
1857 (GetClassLongA( msg
->hwnd
, GCL_STYLE
) & CS_DBLCLKS
))
1859 if ((msg
->message
== clk_msg
.message
) &&
1860 (msg
->hwnd
== clk_msg
.hwnd
) &&
1861 (msg
->wParam
== clk_msg
.wParam
) &&
1862 (msg
->time
- clk_msg
.time
< GetDoubleClickTime()) &&
1863 (abs(msg
->pt
.x
- clk_msg
.pt
.x
) < GetSystemMetrics(SM_CXDOUBLECLK
)/2) &&
1864 (abs(msg
->pt
.y
- clk_msg
.pt
.y
) < GetSystemMetrics(SM_CYDOUBLECLK
)/2))
1866 message
+= (WM_LBUTTONDBLCLK
- WM_LBUTTONDOWN
);
1869 clk_msg
.message
= 0; /* clear the double click conditions */
1874 if (message
< first
|| message
> last
) return FALSE
;
1875 /* update static double click conditions */
1876 if (update
) clk_msg
= *msg
;
1880 if (message
< first
|| message
> last
) return FALSE
;
1883 /* message is accepted now (but may still get dropped) */
1886 hook
.hwnd
= msg
->hwnd
;
1887 hook
.wHitTestCode
= hittest
;
1888 hook
.dwExtraInfo
= extra_info
;
1889 if (HOOK_CallHooks( WH_MOUSE
, remove
? HC_ACTION
: HC_NOREMOVE
,
1890 message
, (LPARAM
)&hook
, TRUE
))
1893 hook
.hwnd
= msg
->hwnd
;
1894 hook
.wHitTestCode
= hittest
;
1895 hook
.dwExtraInfo
= extra_info
;
1896 HOOK_CallHooks( WH_CBT
, HCBT_CLICKSKIPPED
, message
, (LPARAM
)&hook
, TRUE
);
1897 accept_hardware_message( hw_id
, TRUE
, 0 );
1901 if ((hittest
== HTERROR
) || (hittest
== HTNOWHERE
))
1903 SendMessageW( msg
->hwnd
, WM_SETCURSOR
, (WPARAM
)msg
->hwnd
,
1904 MAKELONG( hittest
, msg
->message
));
1905 accept_hardware_message( hw_id
, TRUE
, 0 );
1909 accept_hardware_message( hw_id
, remove
, 0 );
1911 if (!remove
|| info
.hwndCapture
)
1913 msg
->message
= message
;
1919 if ((msg
->message
== WM_LBUTTONDOWN
) ||
1920 (msg
->message
== WM_RBUTTONDOWN
) ||
1921 (msg
->message
== WM_MBUTTONDOWN
) ||
1922 (msg
->message
== WM_XBUTTONDOWN
))
1924 /* Send the WM_PARENTNOTIFY,
1925 * note that even for double/nonclient clicks
1926 * notification message is still WM_L/M/RBUTTONDOWN.
1928 send_parent_notify( msg
->hwnd
, msg
->message
, 0, msg
->pt
);
1930 /* Activate the window if needed */
1932 if (msg
->hwnd
!= info
.hwndActive
)
1934 HWND hwndTop
= msg
->hwnd
;
1937 if ((GetWindowLongW( hwndTop
, GWL_STYLE
) & (WS_POPUP
|WS_CHILD
)) != WS_CHILD
) break;
1938 hwndTop
= GetParent( hwndTop
);
1941 if (hwndTop
&& hwndTop
!= GetDesktopWindow())
1943 LONG ret
= SendMessageW( msg
->hwnd
, WM_MOUSEACTIVATE
, (WPARAM
)hwndTop
,
1944 MAKELONG( hittest
, msg
->message
) );
1947 case MA_NOACTIVATEANDEAT
:
1952 case MA_ACTIVATEANDEAT
:
1957 if (!FOCUS_MouseActivate( hwndTop
)) eatMsg
= TRUE
;
1960 WARN( "unknown WM_MOUSEACTIVATE code %d\n", ret
);
1967 /* send the WM_SETCURSOR message */
1969 /* Windows sends the normal mouse message as the message parameter
1970 in the WM_SETCURSOR message even if it's non-client mouse message */
1971 SendMessageW( msg
->hwnd
, WM_SETCURSOR
, (WPARAM
)msg
->hwnd
, MAKELONG( hittest
, msg
->message
));
1973 msg
->message
= message
;
1978 /***********************************************************************
1979 * process_hardware_message
1981 * Process a hardware message; return TRUE if message should be passed on to the app
1983 static BOOL
process_hardware_message( MSG
*msg
, UINT hw_id
, ULONG_PTR extra_info
, HWND hwnd_filter
,
1984 UINT first
, UINT last
, BOOL remove
)
1986 if (is_keyboard_message( msg
->message
))
1987 return process_keyboard_message( msg
, hw_id
, hwnd_filter
, first
, last
, remove
);
1989 if (is_mouse_message( msg
->message
))
1990 return process_mouse_message( msg
, hw_id
, extra_info
, hwnd_filter
, first
, last
, remove
);
1992 ERR( "unknown message type %x\n", msg
->message
);
1997 /***********************************************************************
1998 * call_sendmsg_callback
2000 * Call the callback function of SendMessageCallback.
2002 static inline void call_sendmsg_callback( SENDASYNCPROC callback
, HWND hwnd
, UINT msg
,
2003 ULONG_PTR data
, LRESULT result
)
2005 if (!callback
) return;
2007 if (TRACE_ON(relay
))
2008 DPRINTF( "%04x:Call message callback %p (hwnd=%p,msg=%s,data=%08lx,result=%08lx)\n",
2009 GetCurrentThreadId(), callback
, hwnd
, SPY_GetMsgName( msg
, hwnd
),
2011 callback( hwnd
, msg
, data
, result
);
2012 if (TRACE_ON(relay
))
2013 DPRINTF( "%04x:Ret message callback %p (hwnd=%p,msg=%s,data=%08lx,result=%08lx)\n",
2014 GetCurrentThreadId(), callback
, hwnd
, SPY_GetMsgName( msg
, hwnd
),
2019 /***********************************************************************
2022 * Peek for a message matching the given parameters. Return FALSE if none available.
2023 * All pending sent messages are processed before returning.
2025 static BOOL
peek_message( MSG
*msg
, HWND hwnd
, UINT first
, UINT last
, UINT flags
, UINT changed_mask
)
2028 struct user_thread_info
*thread_info
= get_user_thread_info();
2029 struct received_message_info info
, *old_info
;
2030 unsigned int hw_id
= 0; /* id of previous hardware message */
2032 size_t buffer_size
= 256;
2034 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, buffer_size
))) return FALSE
;
2036 if (!first
&& !last
) last
= ~0;
2037 if (hwnd
== HWND_BROADCAST
|| hwnd
== HWND_TOPMOST
|| hwnd
== HWND_BOTTOM
)
2044 const message_data_t
*msg_data
= buffer
;
2046 SERVER_START_REQ( get_message
)
2049 req
->get_win
= wine_server_user_handle( hwnd
);
2050 req
->get_first
= first
;
2051 req
->get_last
= last
;
2053 req
->wake_mask
= changed_mask
& (QS_SENDMESSAGE
| QS_SMRESULT
);
2054 req
->changed_mask
= changed_mask
;
2055 wine_server_set_reply( req
, buffer
, buffer_size
);
2056 if (!(res
= wine_server_call( req
)))
2058 size
= wine_server_reply_size( reply
);
2059 info
.type
= reply
->type
;
2060 info
.msg
.hwnd
= wine_server_ptr_handle( reply
->win
);
2061 info
.msg
.message
= reply
->msg
;
2062 info
.msg
.wParam
= reply
->wparam
;
2063 info
.msg
.lParam
= reply
->lparam
;
2064 info
.msg
.time
= reply
->time
;
2068 thread_info
->active_hooks
= reply
->active_hooks
;
2070 else buffer_size
= reply
->total
;
2076 HeapFree( GetProcessHeap(), 0, buffer
);
2077 if (res
!= STATUS_BUFFER_OVERFLOW
) return FALSE
;
2078 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, buffer_size
))) return FALSE
;
2082 TRACE( "got type %d msg %x (%s) hwnd %p wp %lx lp %lx\n",
2083 info
.type
, info
.msg
.message
,
2084 (info
.type
== MSG_WINEVENT
) ? "MSG_WINEVENT" : SPY_GetMsgName(info
.msg
.message
, info
.msg
.hwnd
),
2085 info
.msg
.hwnd
, info
.msg
.wParam
, info
.msg
.lParam
);
2091 info
.flags
= ISMEX_SEND
;
2094 info
.flags
= ISMEX_NOTIFY
;
2097 info
.flags
= ISMEX_CALLBACK
;
2099 case MSG_CALLBACK_RESULT
:
2100 if (size
>= sizeof(msg_data
->callback
))
2101 call_sendmsg_callback( wine_server_get_ptr(msg_data
->callback
.callback
),
2102 info
.msg
.hwnd
, info
.msg
.message
,
2103 msg_data
->callback
.data
, msg_data
->callback
.result
);
2106 if (size
>= sizeof(msg_data
->winevent
))
2108 WINEVENTPROC hook_proc
;
2110 hook_proc
= wine_server_get_ptr( msg_data
->winevent
.hook_proc
);
2111 size
-= sizeof(msg_data
->winevent
);
2114 WCHAR module
[MAX_PATH
];
2116 size
= min( size
, (MAX_PATH
- 1) * sizeof(WCHAR
) );
2117 memcpy( module
, &msg_data
->winevent
+ 1, size
);
2118 module
[size
/ sizeof(WCHAR
)] = 0;
2119 if (!(hook_proc
= get_hook_proc( hook_proc
, module
)))
2121 ERR( "invalid winevent hook module name %s\n", debugstr_w(module
) );
2126 if (TRACE_ON(relay
))
2127 DPRINTF( "%04x:Call winevent proc %p (hook=%04x,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n",
2128 GetCurrentThreadId(), hook_proc
,
2129 msg_data
->winevent
.hook
, info
.msg
.message
, info
.msg
.hwnd
, info
.msg
.wParam
,
2130 info
.msg
.lParam
, msg_data
->winevent
.tid
, info
.msg
.time
);
2132 hook_proc( wine_server_ptr_handle( msg_data
->winevent
.hook
), info
.msg
.message
,
2133 info
.msg
.hwnd
, info
.msg
.wParam
, info
.msg
.lParam
,
2134 msg_data
->winevent
.tid
, info
.msg
.time
);
2136 if (TRACE_ON(relay
))
2137 DPRINTF( "%04x:Ret winevent proc %p (hook=%04x,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n",
2138 GetCurrentThreadId(), hook_proc
,
2139 msg_data
->winevent
.hook
, info
.msg
.message
, info
.msg
.hwnd
, info
.msg
.wParam
,
2140 info
.msg
.lParam
, msg_data
->winevent
.tid
, info
.msg
.time
);
2143 case MSG_OTHER_PROCESS
:
2144 info
.flags
= ISMEX_SEND
;
2145 if (!unpack_message( info
.msg
.hwnd
, info
.msg
.message
, &info
.msg
.wParam
,
2146 &info
.msg
.lParam
, &buffer
, size
))
2149 reply_message( &info
, 0, TRUE
);
2154 if (size
>= sizeof(msg_data
->hardware
))
2156 info
.msg
.pt
.x
= msg_data
->hardware
.x
;
2157 info
.msg
.pt
.y
= msg_data
->hardware
.y
;
2158 hw_id
= msg_data
->hardware
.hw_id
;
2159 if (!process_hardware_message( &info
.msg
, hw_id
, msg_data
->hardware
.info
,
2160 hwnd
, first
, last
, flags
& PM_REMOVE
))
2162 TRACE("dropping msg %x\n", info
.msg
.message
);
2163 continue; /* ignore it */
2166 thread_info
->GetMessagePosVal
= MAKELONG( info
.msg
.pt
.x
, info
.msg
.pt
.y
);
2167 thread_info
->GetMessageTimeVal
= info
.msg
.time
;
2168 thread_info
->GetMessageExtraInfoVal
= msg_data
->hardware
.info
;
2169 HeapFree( GetProcessHeap(), 0, buffer
);
2170 HOOK_CallHooks( WH_GETMESSAGE
, HC_ACTION
, flags
& PM_REMOVE
, (LPARAM
)msg
, TRUE
);
2175 if (info
.msg
.message
& 0x80000000) /* internal message */
2177 if (flags
& PM_REMOVE
)
2179 handle_internal_message( info
.msg
.hwnd
, info
.msg
.message
,
2180 info
.msg
.wParam
, info
.msg
.lParam
);
2181 /* if this is a nested call return right away */
2182 if (first
== info
.msg
.message
&& last
== info
.msg
.message
) return FALSE
;
2185 peek_message( msg
, info
.msg
.hwnd
, info
.msg
.message
,
2186 info
.msg
.message
, flags
| PM_REMOVE
, changed_mask
);
2189 if (info
.msg
.message
>= WM_DDE_FIRST
&& info
.msg
.message
<= WM_DDE_LAST
)
2191 if (!unpack_dde_message( info
.msg
.hwnd
, info
.msg
.message
, &info
.msg
.wParam
,
2192 &info
.msg
.lParam
, &buffer
, size
))
2193 continue; /* ignore it */
2196 msg
->pt
.x
= (short)LOWORD( thread_info
->GetMessagePosVal
);
2197 msg
->pt
.y
= (short)HIWORD( thread_info
->GetMessagePosVal
);
2198 thread_info
->GetMessageTimeVal
= info
.msg
.time
;
2199 thread_info
->GetMessageExtraInfoVal
= 0;
2200 HeapFree( GetProcessHeap(), 0, buffer
);
2201 HOOK_CallHooks( WH_GETMESSAGE
, HC_ACTION
, flags
& PM_REMOVE
, (LPARAM
)msg
, TRUE
);
2205 /* if we get here, we have a sent message; call the window procedure */
2206 old_info
= thread_info
->receive_info
;
2207 thread_info
->receive_info
= &info
;
2208 result
= call_window_proc( info
.msg
.hwnd
, info
.msg
.message
, info
.msg
.wParam
,
2209 info
.msg
.lParam
, (info
.type
!= MSG_ASCII
), FALSE
,
2210 WMCHAR_MAP_RECVMESSAGE
);
2211 reply_message( &info
, result
, TRUE
);
2212 thread_info
->receive_info
= old_info
;
2214 /* if some PM_QS* flags were specified, only handle sent messages from now on */
2215 if (HIWORD(flags
) && !changed_mask
) flags
= PM_QS_SENDMESSAGE
| LOWORD(flags
);
2220 /***********************************************************************
2221 * process_sent_messages
2223 * Process all pending sent messages.
2225 static inline void process_sent_messages(void)
2228 peek_message( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
, 0 );
2232 /***********************************************************************
2233 * get_server_queue_handle
2235 * Get a handle to the server message queue for the current thread.
2237 static HANDLE
get_server_queue_handle(void)
2239 struct user_thread_info
*thread_info
= get_user_thread_info();
2242 if (!(ret
= thread_info
->server_queue
))
2244 SERVER_START_REQ( get_msg_queue
)
2246 wine_server_call( req
);
2247 ret
= wine_server_ptr_handle( reply
->handle
);
2250 thread_info
->server_queue
= ret
;
2251 if (!ret
) ERR( "Cannot get server thread queue\n" );
2257 /***********************************************************************
2258 * wait_message_reply
2260 * Wait until a sent message gets replied to.
2262 static void wait_message_reply( UINT flags
)
2264 HANDLE server_queue
= get_server_queue_handle();
2268 unsigned int wake_bits
= 0;
2271 SERVER_START_REQ( set_queue_mask
)
2273 req
->wake_mask
= QS_SMRESULT
| ((flags
& SMTO_BLOCK
) ? 0 : QS_SENDMESSAGE
);
2274 req
->changed_mask
= req
->wake_mask
;
2276 if (!wine_server_call( req
))
2277 wake_bits
= reply
->wake_bits
;
2281 if (wake_bits
& QS_SMRESULT
) return; /* got a result */
2282 if (wake_bits
& QS_SENDMESSAGE
)
2284 /* Process the sent message immediately */
2285 process_sent_messages();
2289 /* now wait for it */
2291 ReleaseThunkLock( &dwlc
);
2292 res
= USER_Driver
->pMsgWaitForMultipleObjectsEx( 1, &server_queue
,
2293 INFINITE
, QS_SENDMESSAGE
, 0 );
2294 if (dwlc
) RestoreThunkLock( dwlc
);
2298 /***********************************************************************
2299 * put_message_in_queue
2301 * Put a sent message into the destination queue.
2302 * For inter-process message, reply_size is set to expected size of reply data.
2304 static BOOL
put_message_in_queue( const struct send_message_info
*info
, size_t *reply_size
)
2306 struct packed_message data
;
2307 message_data_t msg_data
;
2310 timeout_t timeout
= TIMEOUT_INFINITE
;
2312 /* Check for INFINITE timeout for compatibility with Win9x,
2313 * although Windows >= NT does not do so
2315 if (info
->type
!= MSG_NOTIFY
&&
2316 info
->type
!= MSG_CALLBACK
&&
2317 info
->type
!= MSG_POSTED
&&
2319 info
->timeout
!= INFINITE
)
2321 /* timeout is signed despite the prototype */
2322 timeout
= (timeout_t
)max( 0, (int)info
->timeout
) * -10000;
2326 if (info
->type
== MSG_OTHER_PROCESS
)
2328 *reply_size
= pack_message( info
->hwnd
, info
->msg
, info
->wparam
, info
->lparam
, &data
);
2329 if (data
.count
== -1)
2331 WARN( "cannot pack message %x\n", info
->msg
);
2335 else if (info
->type
== MSG_CALLBACK
)
2337 msg_data
.callback
.callback
= wine_server_client_ptr( info
->callback
);
2338 msg_data
.callback
.data
= info
->data
;
2339 msg_data
.callback
.result
= 0;
2340 data
.data
[0] = &msg_data
;
2341 data
.size
[0] = sizeof(msg_data
.callback
);
2344 else if (info
->type
== MSG_POSTED
&& info
->msg
>= WM_DDE_FIRST
&& info
->msg
<= WM_DDE_LAST
)
2346 return post_dde_message( &data
, info
);
2349 SERVER_START_REQ( send_message
)
2351 req
->id
= info
->dest_tid
;
2352 req
->type
= info
->type
;
2354 req
->win
= wine_server_user_handle( info
->hwnd
);
2355 req
->msg
= info
->msg
;
2356 req
->wparam
= info
->wparam
;
2357 req
->lparam
= info
->lparam
;
2358 req
->timeout
= timeout
;
2360 if (info
->flags
& SMTO_ABORTIFHUNG
) req
->flags
|= SEND_MSG_ABORT_IF_HUNG
;
2361 for (i
= 0; i
< data
.count
; i
++) wine_server_add_data( req
, data
.data
[i
], data
.size
[i
] );
2362 if ((res
= wine_server_call( req
)))
2364 if (res
== STATUS_INVALID_PARAMETER
)
2365 /* FIXME: find a STATUS_ value for this one */
2366 SetLastError( ERROR_INVALID_THREAD_ID
);
2368 SetLastError( RtlNtStatusToDosError(res
) );
2376 /***********************************************************************
2379 * Retrieve a message reply from the server.
2381 static LRESULT
retrieve_reply( const struct send_message_info
*info
,
2382 size_t reply_size
, LRESULT
*result
)
2385 void *reply_data
= NULL
;
2389 if (!(reply_data
= HeapAlloc( GetProcessHeap(), 0, reply_size
)))
2391 WARN( "no memory for reply, will be truncated\n" );
2395 SERVER_START_REQ( get_message_reply
)
2398 if (reply_size
) wine_server_set_reply( req
, reply_data
, reply_size
);
2399 if (!(status
= wine_server_call( req
))) *result
= reply
->result
;
2400 reply_size
= wine_server_reply_size( reply
);
2403 if (!status
&& reply_size
)
2404 unpack_reply( info
->hwnd
, info
->msg
, info
->wparam
, info
->lparam
, reply_data
, reply_size
);
2406 HeapFree( GetProcessHeap(), 0, reply_data
);
2408 TRACE( "hwnd %p msg %x (%s) wp %lx lp %lx got reply %lx (err=%d)\n",
2409 info
->hwnd
, info
->msg
, SPY_GetMsgName(info
->msg
, info
->hwnd
), info
->wparam
,
2410 info
->lparam
, *result
, status
);
2412 /* MSDN states that last error is 0 on timeout, but at least NT4 returns ERROR_TIMEOUT */
2413 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
2418 /***********************************************************************
2419 * send_inter_thread_message
2421 static LRESULT
send_inter_thread_message( const struct send_message_info
*info
, LRESULT
*res_ptr
)
2423 size_t reply_size
= 0;
2425 TRACE( "hwnd %p msg %x (%s) wp %lx lp %lx\n",
2426 info
->hwnd
, info
->msg
, SPY_GetMsgName(info
->msg
, info
->hwnd
), info
->wparam
, info
->lparam
);
2428 USER_CheckNotLock();
2430 if (!put_message_in_queue( info
, &reply_size
)) return 0;
2432 /* there's no reply to wait for on notify/callback messages */
2433 if (info
->type
== MSG_NOTIFY
|| info
->type
== MSG_CALLBACK
) return 1;
2435 wait_message_reply( info
->flags
);
2436 return retrieve_reply( info
, reply_size
, res_ptr
);
2440 /***********************************************************************
2441 * send_inter_thread_callback
2443 static LRESULT
send_inter_thread_callback( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
,
2444 LRESULT
*result
, void *arg
)
2446 struct send_message_info
*info
= arg
;
2451 return send_inter_thread_message( info
, result
);
2455 /***********************************************************************
2458 * Backend implementation of the various SendMessage functions.
2460 static BOOL
send_message( struct send_message_info
*info
, DWORD_PTR
*res_ptr
, BOOL unicode
)
2466 if (is_broadcast(info
->hwnd
))
2468 EnumWindows( broadcast_message_callback
, (LPARAM
)info
);
2469 if (res_ptr
) *res_ptr
= 1;
2473 if (!(info
->dest_tid
= GetWindowThreadProcessId( info
->hwnd
, &dest_pid
))) return FALSE
;
2475 if (USER_IsExitingThread( info
->dest_tid
)) return FALSE
;
2477 SPY_EnterMessage( SPY_SENDMESSAGE
, info
->hwnd
, info
->msg
, info
->wparam
, info
->lparam
);
2479 if (info
->dest_tid
== GetCurrentThreadId())
2481 result
= call_window_proc( info
->hwnd
, info
->msg
, info
->wparam
, info
->lparam
,
2482 unicode
, TRUE
, info
->wm_char
);
2483 if (info
->type
== MSG_CALLBACK
)
2484 call_sendmsg_callback( info
->callback
, info
->hwnd
, info
->msg
, info
->data
, result
);
2489 if (dest_pid
!= GetCurrentProcessId() && (info
->type
== MSG_ASCII
|| info
->type
== MSG_UNICODE
))
2490 info
->type
= MSG_OTHER_PROCESS
;
2492 /* MSG_ASCII can be sent unconverted except for WM_CHAR; everything else needs to be Unicode */
2493 if (!unicode
&& is_unicode_message( info
->msg
) &&
2494 (info
->type
!= MSG_ASCII
|| info
->msg
== WM_CHAR
))
2495 ret
= WINPROC_CallProcAtoW( send_inter_thread_callback
, info
->hwnd
, info
->msg
,
2496 info
->wparam
, info
->lparam
, &result
, info
, info
->wm_char
);
2498 ret
= send_inter_thread_message( info
, &result
);
2501 SPY_ExitMessage( SPY_RESULT_OK
, info
->hwnd
, info
->msg
, result
, info
->wparam
, info
->lparam
);
2502 if (ret
&& res_ptr
) *res_ptr
= result
;
2507 /***********************************************************************
2508 * MSG_SendInternalMessageTimeout
2510 * Same as SendMessageTimeoutW but sends the message to a specific thread
2511 * without requiring a window handle. Only works for internal Wine messages.
2513 LRESULT
MSG_SendInternalMessageTimeout( DWORD dest_pid
, DWORD dest_tid
,
2514 UINT msg
, WPARAM wparam
, LPARAM lparam
,
2515 UINT flags
, UINT timeout
, PDWORD_PTR res_ptr
)
2517 struct send_message_info info
;
2518 LRESULT ret
, result
;
2520 assert( msg
& 0x80000000 ); /* must be an internal Wine message */
2522 info
.type
= MSG_UNICODE
;
2523 info
.dest_tid
= dest_tid
;
2526 info
.wparam
= wparam
;
2527 info
.lparam
= lparam
;
2529 info
.timeout
= timeout
;
2531 if (USER_IsExitingThread( dest_tid
)) return 0;
2533 if (dest_tid
== GetCurrentThreadId())
2535 result
= handle_internal_message( 0, msg
, wparam
, lparam
);
2540 if (dest_pid
!= GetCurrentProcessId()) info
.type
= MSG_OTHER_PROCESS
;
2541 ret
= send_inter_thread_message( &info
, &result
);
2543 if (ret
&& res_ptr
) *res_ptr
= result
;
2548 /***********************************************************************
2549 * SendMessageTimeoutW (USER32.@)
2551 LRESULT WINAPI
SendMessageTimeoutW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
2552 UINT flags
, UINT timeout
, PDWORD_PTR res_ptr
)
2554 struct send_message_info info
;
2556 info
.type
= MSG_UNICODE
;
2559 info
.wparam
= wparam
;
2560 info
.lparam
= lparam
;
2562 info
.timeout
= timeout
;
2564 return send_message( &info
, res_ptr
, TRUE
);
2567 /***********************************************************************
2568 * SendMessageTimeoutA (USER32.@)
2570 LRESULT WINAPI
SendMessageTimeoutA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
2571 UINT flags
, UINT timeout
, PDWORD_PTR res_ptr
)
2573 struct send_message_info info
;
2575 info
.type
= MSG_ASCII
;
2578 info
.wparam
= wparam
;
2579 info
.lparam
= lparam
;
2581 info
.timeout
= timeout
;
2582 info
.wm_char
= WMCHAR_MAP_SENDMESSAGETIMEOUT
;
2584 return send_message( &info
, res_ptr
, FALSE
);
2588 /***********************************************************************
2589 * SendMessageW (USER32.@)
2591 LRESULT WINAPI
SendMessageW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2594 struct send_message_info info
;
2596 info
.type
= MSG_UNICODE
;
2599 info
.wparam
= wparam
;
2600 info
.lparam
= lparam
;
2601 info
.flags
= SMTO_NORMAL
;
2604 send_message( &info
, &res
, TRUE
);
2609 /***********************************************************************
2610 * SendMessageA (USER32.@)
2612 LRESULT WINAPI
SendMessageA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2615 struct send_message_info info
;
2617 info
.type
= MSG_ASCII
;
2620 info
.wparam
= wparam
;
2621 info
.lparam
= lparam
;
2622 info
.flags
= SMTO_NORMAL
;
2624 info
.wm_char
= WMCHAR_MAP_SENDMESSAGE
;
2626 send_message( &info
, &res
, FALSE
);
2631 /***********************************************************************
2632 * SendNotifyMessageA (USER32.@)
2634 BOOL WINAPI
SendNotifyMessageA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2636 struct send_message_info info
;
2638 if (is_pointer_message(msg
))
2640 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2644 info
.type
= MSG_NOTIFY
;
2647 info
.wparam
= wparam
;
2648 info
.lparam
= lparam
;
2650 info
.wm_char
= WMCHAR_MAP_SENDMESSAGETIMEOUT
;
2652 return send_message( &info
, NULL
, FALSE
);
2656 /***********************************************************************
2657 * SendNotifyMessageW (USER32.@)
2659 BOOL WINAPI
SendNotifyMessageW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2661 struct send_message_info info
;
2663 if (is_pointer_message(msg
))
2665 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2669 info
.type
= MSG_NOTIFY
;
2672 info
.wparam
= wparam
;
2673 info
.lparam
= lparam
;
2676 return send_message( &info
, NULL
, TRUE
);
2680 /***********************************************************************
2681 * SendMessageCallbackA (USER32.@)
2683 BOOL WINAPI
SendMessageCallbackA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
2684 SENDASYNCPROC callback
, ULONG_PTR data
)
2686 struct send_message_info info
;
2688 if (is_pointer_message(msg
))
2690 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2694 info
.type
= MSG_CALLBACK
;
2697 info
.wparam
= wparam
;
2698 info
.lparam
= lparam
;
2699 info
.callback
= callback
;
2702 info
.wm_char
= WMCHAR_MAP_SENDMESSAGETIMEOUT
;
2704 return send_message( &info
, NULL
, FALSE
);
2708 /***********************************************************************
2709 * SendMessageCallbackW (USER32.@)
2711 BOOL WINAPI
SendMessageCallbackW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
2712 SENDASYNCPROC callback
, ULONG_PTR data
)
2714 struct send_message_info info
;
2716 if (is_pointer_message(msg
))
2718 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2722 info
.type
= MSG_CALLBACK
;
2725 info
.wparam
= wparam
;
2726 info
.lparam
= lparam
;
2727 info
.callback
= callback
;
2731 return send_message( &info
, NULL
, TRUE
);
2735 /***********************************************************************
2736 * ReplyMessage (USER32.@)
2738 BOOL WINAPI
ReplyMessage( LRESULT result
)
2740 struct received_message_info
*info
= get_user_thread_info()->receive_info
;
2742 if (!info
) return FALSE
;
2743 reply_message( info
, result
, FALSE
);
2748 /***********************************************************************
2749 * InSendMessage (USER32.@)
2751 BOOL WINAPI
InSendMessage(void)
2753 return (InSendMessageEx(NULL
) & (ISMEX_SEND
|ISMEX_REPLIED
)) == ISMEX_SEND
;
2757 /***********************************************************************
2758 * InSendMessageEx (USER32.@)
2760 DWORD WINAPI
InSendMessageEx( LPVOID reserved
)
2762 struct received_message_info
*info
= get_user_thread_info()->receive_info
;
2764 if (info
) return info
->flags
;
2765 return ISMEX_NOSEND
;
2769 /***********************************************************************
2770 * PostMessageA (USER32.@)
2772 BOOL WINAPI
PostMessageA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2774 if (!map_wparam_AtoW( msg
, &wparam
, WMCHAR_MAP_POSTMESSAGE
)) return TRUE
;
2775 return PostMessageW( hwnd
, msg
, wparam
, lparam
);
2779 /***********************************************************************
2780 * PostMessageW (USER32.@)
2782 BOOL WINAPI
PostMessageW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2784 struct send_message_info info
;
2786 if (is_pointer_message( msg
))
2788 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2792 TRACE( "hwnd %p msg %x (%s) wp %lx lp %lx\n",
2793 hwnd
, msg
, SPY_GetMsgName(msg
, hwnd
), wparam
, lparam
);
2795 info
.type
= MSG_POSTED
;
2798 info
.wparam
= wparam
;
2799 info
.lparam
= lparam
;
2802 if (is_broadcast(hwnd
))
2804 EnumWindows( broadcast_message_callback
, (LPARAM
)&info
);
2808 if (!hwnd
) return PostThreadMessageW( GetCurrentThreadId(), msg
, wparam
, lparam
);
2810 if (!(info
.dest_tid
= GetWindowThreadProcessId( hwnd
, NULL
))) return FALSE
;
2812 if (USER_IsExitingThread( info
.dest_tid
)) return TRUE
;
2814 return put_message_in_queue( &info
, NULL
);
2818 /**********************************************************************
2819 * PostThreadMessageA (USER32.@)
2821 BOOL WINAPI
PostThreadMessageA( DWORD thread
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2823 if (!map_wparam_AtoW( msg
, &wparam
, WMCHAR_MAP_POSTMESSAGE
)) return TRUE
;
2824 return PostThreadMessageW( thread
, msg
, wparam
, lparam
);
2828 /**********************************************************************
2829 * PostThreadMessageW (USER32.@)
2831 BOOL WINAPI
PostThreadMessageW( DWORD thread
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2833 struct send_message_info info
;
2835 if (is_pointer_message( msg
))
2837 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2840 if (USER_IsExitingThread( thread
)) return TRUE
;
2842 info
.type
= MSG_POSTED
;
2843 info
.dest_tid
= thread
;
2846 info
.wparam
= wparam
;
2847 info
.lparam
= lparam
;
2849 return put_message_in_queue( &info
, NULL
);
2853 /***********************************************************************
2854 * PostQuitMessage (USER32.@)
2856 * Posts a quit message to the current thread's message queue.
2859 * exit_code [I] Exit code to return from message loop.
2865 * This function is not the same as calling:
2866 *|PostThreadMessage(GetCurrentThreadId(), WM_QUIT, exit_code, 0);
2867 * It instead sets a flag in the message queue that signals it to generate
2868 * a WM_QUIT message when there are no other pending sent or posted messages
2871 void WINAPI
PostQuitMessage( INT exit_code
)
2873 SERVER_START_REQ( post_quit_message
)
2875 req
->exit_code
= exit_code
;
2876 wine_server_call( req
);
2882 /***********************************************************************
2883 * PeekMessageW (USER32.@)
2885 BOOL WINAPI
PeekMessageW( MSG
*msg_out
, HWND hwnd
, UINT first
, UINT last
, UINT flags
)
2889 USER_CheckNotLock();
2891 /* check for graphics events */
2892 USER_Driver
->pMsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_ALLINPUT
, 0 );
2894 if (!peek_message( &msg
, hwnd
, first
, last
, flags
, 0 ))
2896 if (!(flags
& PM_NOYIELD
))
2899 ReleaseThunkLock(&count
);
2901 if (count
) RestoreThunkLock(count
);
2906 /* copy back our internal safe copy of message data to msg_out.
2907 * msg_out is a variable from the *program*, so it can't be used
2908 * internally as it can get "corrupted" by our use of SendMessage()
2909 * (back to the program) inside the message handling itself. */
2912 SetLastError( ERROR_NOACCESS
);
2920 /***********************************************************************
2921 * PeekMessageA (USER32.@)
2923 BOOL WINAPI
PeekMessageA( MSG
*msg
, HWND hwnd
, UINT first
, UINT last
, UINT flags
)
2925 if (get_pending_wmchar( msg
, first
, last
, (flags
& PM_REMOVE
) )) return TRUE
;
2926 if (!PeekMessageW( msg
, hwnd
, first
, last
, flags
)) return FALSE
;
2927 map_wparam_WtoA( msg
, (flags
& PM_REMOVE
) );
2932 /***********************************************************************
2933 * GetMessageW (USER32.@)
2935 BOOL WINAPI
GetMessageW( MSG
*msg
, HWND hwnd
, UINT first
, UINT last
)
2937 HANDLE server_queue
= get_server_queue_handle();
2938 unsigned int mask
= QS_POSTMESSAGE
| QS_SENDMESSAGE
; /* Always selected */
2940 USER_CheckNotLock();
2942 /* check for graphics events */
2943 USER_Driver
->pMsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_ALLINPUT
, 0 );
2947 if ((first
<= WM_KEYLAST
) && (last
>= WM_KEYFIRST
)) mask
|= QS_KEY
;
2948 if ( ((first
<= WM_MOUSELAST
) && (last
>= WM_MOUSEFIRST
)) ||
2949 ((first
<= WM_NCMOUSELAST
) && (last
>= WM_NCMOUSEFIRST
)) ) mask
|= QS_MOUSE
;
2950 if ((first
<= WM_TIMER
) && (last
>= WM_TIMER
)) mask
|= QS_TIMER
;
2951 if ((first
<= WM_SYSTIMER
) && (last
>= WM_SYSTIMER
)) mask
|= QS_TIMER
;
2952 if ((first
<= WM_PAINT
) && (last
>= WM_PAINT
)) mask
|= QS_PAINT
;
2954 else mask
= QS_ALLINPUT
;
2956 while (!peek_message( msg
, hwnd
, first
, last
, PM_REMOVE
| (mask
<< 16), mask
))
2960 ReleaseThunkLock( &dwlc
);
2961 USER_Driver
->pMsgWaitForMultipleObjectsEx( 1, &server_queue
, INFINITE
, mask
, 0 );
2962 if (dwlc
) RestoreThunkLock( dwlc
);
2965 return (msg
->message
!= WM_QUIT
);
2969 /***********************************************************************
2970 * GetMessageA (USER32.@)
2972 BOOL WINAPI
GetMessageA( MSG
*msg
, HWND hwnd
, UINT first
, UINT last
)
2974 if (get_pending_wmchar( msg
, first
, last
, TRUE
)) return TRUE
;
2975 GetMessageW( msg
, hwnd
, first
, last
);
2976 map_wparam_WtoA( msg
, TRUE
);
2977 return (msg
->message
!= WM_QUIT
);
2981 /***********************************************************************
2982 * IsDialogMessageA (USER32.@)
2983 * IsDialogMessage (USER32.@)
2985 BOOL WINAPI
IsDialogMessageA( HWND hwndDlg
, LPMSG pmsg
)
2988 map_wparam_AtoW( msg
.message
, &msg
.wParam
, WMCHAR_MAP_NOMAPPING
);
2989 return IsDialogMessageW( hwndDlg
, &msg
);
2993 /***********************************************************************
2994 * TranslateMessage (USER32.@)
2996 * Implementation of TranslateMessage.
2998 * TranslateMessage translates virtual-key messages into character-messages,
3000 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
3001 * ditto replacing WM_* with WM_SYS*
3002 * This produces WM_CHAR messages only for keys mapped to ASCII characters
3003 * by the keyboard driver.
3005 * If the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, the
3006 * return value is nonzero, regardless of the translation.
3009 BOOL WINAPI
TranslateMessage( const MSG
*msg
)
3015 if (msg
->message
< WM_KEYFIRST
|| msg
->message
> WM_KEYLAST
) return FALSE
;
3016 if (msg
->message
!= WM_KEYDOWN
&& msg
->message
!= WM_SYSKEYDOWN
) return TRUE
;
3018 TRACE_(key
)("Translating key %s (%04lx), scancode %04x\n",
3019 SPY_GetVKeyName(msg
->wParam
), msg
->wParam
, HIWORD(msg
->lParam
));
3021 switch (msg
->wParam
)
3024 message
= (msg
->message
== WM_KEYDOWN
) ? WM_CHAR
: WM_SYSCHAR
;
3025 TRACE_(key
)("PostMessageW(%p,%s,%04x,%08x)\n",
3026 msg
->hwnd
, SPY_GetMsgName(message
, msg
->hwnd
), HIWORD(msg
->lParam
), LOWORD(msg
->lParam
));
3027 PostMessageW( msg
->hwnd
, message
, HIWORD(msg
->lParam
), LOWORD(msg
->lParam
));
3031 return ImmTranslateMessage(msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
3034 GetKeyboardState( state
);
3035 /* FIXME : should handle ToUnicode yielding 2 */
3036 switch (ToUnicode(msg
->wParam
, HIWORD(msg
->lParam
), state
, wp
, 2, 0))
3039 message
= (msg
->message
== WM_KEYDOWN
) ? WM_CHAR
: WM_SYSCHAR
;
3040 TRACE_(key
)("1 -> PostMessageW(%p,%s,%04x,%08lx)\n",
3041 msg
->hwnd
, SPY_GetMsgName(message
, msg
->hwnd
), wp
[0], msg
->lParam
);
3042 PostMessageW( msg
->hwnd
, message
, wp
[0], msg
->lParam
);
3046 message
= (msg
->message
== WM_KEYDOWN
) ? WM_DEADCHAR
: WM_SYSDEADCHAR
;
3047 TRACE_(key
)("-1 -> PostMessageW(%p,%s,%04x,%08lx)\n",
3048 msg
->hwnd
, SPY_GetMsgName(message
, msg
->hwnd
), wp
[0], msg
->lParam
);
3049 PostMessageW( msg
->hwnd
, message
, wp
[0], msg
->lParam
);
3056 /***********************************************************************
3057 * DispatchMessageA (USER32.@)
3059 * See DispatchMessageW.
3061 LRESULT WINAPI
DispatchMessageA( const MSG
* msg
)
3065 /* Process timer messages */
3066 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
3068 if (msg
->lParam
) return CallWindowProcA( (WNDPROC
)msg
->lParam
, msg
->hwnd
,
3069 msg
->message
, msg
->wParam
, GetTickCount() );
3071 if (!msg
->hwnd
) return 0;
3073 SPY_EnterMessage( SPY_DISPATCHMESSAGE
, msg
->hwnd
, msg
->message
,
3074 msg
->wParam
, msg
->lParam
);
3076 if (!WINPROC_call_window( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
,
3077 &retval
, FALSE
, WMCHAR_MAP_DISPATCHMESSAGE
))
3079 if (!IsWindow( msg
->hwnd
)) SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
3080 else SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
3084 SPY_ExitMessage( SPY_RESULT_OK
, msg
->hwnd
, msg
->message
, retval
,
3085 msg
->wParam
, msg
->lParam
);
3087 if (msg
->message
== WM_PAINT
)
3089 /* send a WM_NCPAINT and WM_ERASEBKGND if the non-client area is still invalid */
3090 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
3091 GetUpdateRgn( msg
->hwnd
, hrgn
, TRUE
);
3092 DeleteObject( hrgn
);
3098 /***********************************************************************
3099 * DispatchMessageW (USER32.@) Process a message
3101 * Process the message specified in the structure *_msg_.
3103 * If the lpMsg parameter points to a WM_TIMER message and the
3104 * parameter of the WM_TIMER message is not NULL, the lParam parameter
3105 * points to the function that is called instead of the window
3108 * The message must be valid.
3112 * DispatchMessage() returns the result of the window procedure invoked.
3119 LRESULT WINAPI
DispatchMessageW( const MSG
* msg
)
3123 /* Process timer messages */
3124 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
3126 if (msg
->lParam
) return CallWindowProcW( (WNDPROC
)msg
->lParam
, msg
->hwnd
,
3127 msg
->message
, msg
->wParam
, GetTickCount() );
3129 if (!msg
->hwnd
) return 0;
3131 SPY_EnterMessage( SPY_DISPATCHMESSAGE
, msg
->hwnd
, msg
->message
,
3132 msg
->wParam
, msg
->lParam
);
3134 if (!WINPROC_call_window( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
,
3135 &retval
, TRUE
, WMCHAR_MAP_DISPATCHMESSAGE
))
3137 if (!IsWindow( msg
->hwnd
)) SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
3138 else SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
3142 SPY_ExitMessage( SPY_RESULT_OK
, msg
->hwnd
, msg
->message
, retval
,
3143 msg
->wParam
, msg
->lParam
);
3145 if (msg
->message
== WM_PAINT
)
3147 /* send a WM_NCPAINT and WM_ERASEBKGND if the non-client area is still invalid */
3148 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
3149 GetUpdateRgn( msg
->hwnd
, hrgn
, TRUE
);
3150 DeleteObject( hrgn
);
3156 /***********************************************************************
3157 * GetMessagePos (USER.119)
3158 * GetMessagePos (USER32.@)
3160 * The GetMessagePos() function returns a long value representing a
3161 * cursor position, in screen coordinates, when the last message
3162 * retrieved by the GetMessage() function occurs. The x-coordinate is
3163 * in the low-order word of the return value, the y-coordinate is in
3164 * the high-order word. The application can use the MAKEPOINT()
3165 * macro to obtain a POINT structure from the return value.
3167 * For the current cursor position, use GetCursorPos().
3171 * Cursor position of last message on success, zero on failure.
3178 DWORD WINAPI
GetMessagePos(void)
3180 return get_user_thread_info()->GetMessagePosVal
;
3184 /***********************************************************************
3185 * GetMessageTime (USER.120)
3186 * GetMessageTime (USER32.@)
3188 * GetMessageTime() returns the message time for the last message
3189 * retrieved by the function. The time is measured in milliseconds with
3190 * the same offset as GetTickCount().
3192 * Since the tick count wraps, this is only useful for moderately short
3193 * relative time comparisons.
3197 * Time of last message on success, zero on failure.
3199 LONG WINAPI
GetMessageTime(void)
3201 return get_user_thread_info()->GetMessageTimeVal
;
3205 /***********************************************************************
3206 * GetMessageExtraInfo (USER.288)
3207 * GetMessageExtraInfo (USER32.@)
3209 LPARAM WINAPI
GetMessageExtraInfo(void)
3211 return get_user_thread_info()->GetMessageExtraInfoVal
;
3215 /***********************************************************************
3216 * SetMessageExtraInfo (USER32.@)
3218 LPARAM WINAPI
SetMessageExtraInfo(LPARAM lParam
)
3220 struct user_thread_info
*thread_info
= get_user_thread_info();
3221 LONG old_value
= thread_info
->GetMessageExtraInfoVal
;
3222 thread_info
->GetMessageExtraInfoVal
= lParam
;
3227 /***********************************************************************
3228 * WaitMessage (USER.112) Suspend thread pending messages
3229 * WaitMessage (USER32.@) Suspend thread pending messages
3231 * WaitMessage() suspends a thread until events appear in the thread's
3234 BOOL WINAPI
WaitMessage(void)
3236 return (MsgWaitForMultipleObjectsEx( 0, NULL
, INFINITE
, QS_ALLINPUT
, 0 ) != WAIT_FAILED
);
3240 /***********************************************************************
3241 * MsgWaitForMultipleObjectsEx (USER32.@)
3243 DWORD WINAPI
MsgWaitForMultipleObjectsEx( DWORD count
, CONST HANDLE
*pHandles
,
3244 DWORD timeout
, DWORD mask
, DWORD flags
)
3246 HANDLE handles
[MAXIMUM_WAIT_OBJECTS
];
3249 if (count
> MAXIMUM_WAIT_OBJECTS
-1)
3251 SetLastError( ERROR_INVALID_PARAMETER
);
3255 /* set the queue mask */
3256 SERVER_START_REQ( set_queue_mask
)
3258 req
->wake_mask
= (flags
& MWMO_INPUTAVAILABLE
) ? mask
: 0;
3259 req
->changed_mask
= mask
;
3261 wine_server_call( req
);
3265 /* add the queue to the handle list */
3266 for (i
= 0; i
< count
; i
++) handles
[i
] = pHandles
[i
];
3267 handles
[count
] = get_server_queue_handle();
3269 ReleaseThunkLock( &lock
);
3270 ret
= USER_Driver
->pMsgWaitForMultipleObjectsEx( count
+1, handles
, timeout
, mask
, flags
);
3271 if (lock
) RestoreThunkLock( lock
);
3276 /***********************************************************************
3277 * MsgWaitForMultipleObjects (USER32.@)
3279 DWORD WINAPI
MsgWaitForMultipleObjects( DWORD count
, CONST HANDLE
*handles
,
3280 BOOL wait_all
, DWORD timeout
, DWORD mask
)
3282 return MsgWaitForMultipleObjectsEx( count
, handles
, timeout
, mask
,
3283 wait_all
? MWMO_WAITALL
: 0 );
3287 /***********************************************************************
3288 * WaitForInputIdle (USER32.@)
3290 DWORD WINAPI
WaitForInputIdle( HANDLE hProcess
, DWORD dwTimeOut
)
3292 DWORD start_time
, elapsed
, ret
;
3295 handles
[0] = hProcess
;
3296 SERVER_START_REQ( get_process_idle_event
)
3298 req
->handle
= wine_server_obj_handle( hProcess
);
3299 if (!(ret
= wine_server_call_err( req
)))
3300 handles
[1] = wine_server_ptr_handle( reply
->event
);
3303 if (ret
) return WAIT_FAILED
; /* error */
3304 if (!handles
[1]) return 0; /* no event to wait on */
3306 start_time
= GetTickCount();
3309 TRACE("waiting for %p\n", handles
[1] );
3312 ret
= MsgWaitForMultipleObjects ( 2, handles
, FALSE
, dwTimeOut
- elapsed
, QS_SENDMESSAGE
);
3317 case WAIT_OBJECT_0
+2:
3318 process_sent_messages();
3322 TRACE("timeout or error\n");
3325 TRACE("finished\n");
3328 if (dwTimeOut
!= INFINITE
)
3330 elapsed
= GetTickCount() - start_time
;
3331 if (elapsed
> dwTimeOut
)
3337 return WAIT_TIMEOUT
;
3341 /***********************************************************************
3342 * UserYield (USER.332)
3344 void WINAPI
UserYield16(void)
3348 /* Handle sent messages */
3349 process_sent_messages();
3352 ReleaseThunkLock(&count
);
3356 RestoreThunkLock(count
);
3357 /* Handle sent messages again */
3358 process_sent_messages();
3363 /***********************************************************************
3364 * RegisterWindowMessageA (USER32.@)
3365 * RegisterWindowMessage (USER.118)
3367 UINT WINAPI
RegisterWindowMessageA( LPCSTR str
)
3369 UINT ret
= GlobalAddAtomA(str
);
3370 TRACE("%s, ret=%x\n", str
, ret
);
3375 /***********************************************************************
3376 * RegisterWindowMessageW (USER32.@)
3378 UINT WINAPI
RegisterWindowMessageW( LPCWSTR str
)
3380 UINT ret
= GlobalAddAtomW(str
);
3381 TRACE("%s ret=%x\n", debugstr_w(str
), ret
);
3385 typedef struct BroadcastParm
3396 static BOOL CALLBACK
bcast_childwindow( HWND hw
, LPARAM lp
)
3398 BroadcastParm
*parm
= (BroadcastParm
*)lp
;
3399 DWORD_PTR retval
= 0;
3402 if (parm
->flags
& BSF_IGNORECURRENTTASK
&& WIN_IsCurrentProcess(hw
))
3404 TRACE("Not telling myself %p\n", hw
);
3408 /* I don't know 100% for sure if this is what Windows does, but it fits the tests */
3409 if (parm
->flags
& BSF_QUERY
)
3411 TRACE("Telling window %p using SendMessageTimeout\n", hw
);
3413 /* Not tested for conflicting flags */
3414 if (parm
->flags
& BSF_FORCEIFHUNG
|| parm
->flags
& BSF_NOHANG
)
3415 lresult
= SendMessageTimeoutW( hw
, parm
->msg
, parm
->wp
, parm
->lp
, SMTO_ABORTIFHUNG
, 2000, &retval
);
3416 else if (parm
->flags
& BSF_NOTIMEOUTIFNOTHUNG
)
3417 lresult
= SendMessageTimeoutW( hw
, parm
->msg
, parm
->wp
, parm
->lp
, SMTO_NOTIMEOUTIFNOTHUNG
, 2000, &retval
);
3419 lresult
= SendMessageTimeoutW( hw
, parm
->msg
, parm
->wp
, parm
->lp
, SMTO_NORMAL
, 2000, &retval
);
3421 if (!lresult
&& GetLastError() == ERROR_TIMEOUT
)
3423 WARN("Timed out!\n");
3424 if (!(parm
->flags
& BSF_FORCEIFHUNG
))
3427 if (retval
== BROADCAST_QUERY_DENY
)
3436 else if (parm
->flags
& BSF_POSTMESSAGE
)
3438 TRACE("Telling window %p using PostMessage\n", hw
);
3439 PostMessageW( hw
, parm
->msg
, parm
->wp
, parm
->lp
);
3443 TRACE("Telling window %p using SendNotifyMessage\n", hw
);
3444 SendNotifyMessageW( hw
, parm
->msg
, parm
->wp
, parm
->lp
);
3450 static BOOL CALLBACK
bcast_desktop( LPWSTR desktop
, LPARAM lp
)
3454 BroadcastParm
*parm
= (BroadcastParm
*)lp
;
3456 TRACE("desktop: %s\n", debugstr_w( desktop
));
3458 hdesktop
= open_winstation_desktop( parm
->winsta
, desktop
, 0, FALSE
, DESKTOP_ENUMERATE
|DESKTOP_WRITEOBJECTS
|STANDARD_RIGHTS_WRITE
);
3461 FIXME("Could not open desktop %s\n", debugstr_w(desktop
));
3465 ret
= EnumDesktopWindows( hdesktop
, bcast_childwindow
, lp
);
3466 CloseDesktop(hdesktop
);
3467 TRACE("-->%d\n", ret
);
3468 return parm
->success
;
3471 static BOOL CALLBACK
bcast_winsta( LPWSTR winsta
, LPARAM lp
)
3474 HWINSTA hwinsta
= OpenWindowStationW( winsta
, FALSE
, WINSTA_ENUMDESKTOPS
);
3475 TRACE("hwinsta: %p/%s/%08x\n", hwinsta
, debugstr_w( winsta
), GetLastError());
3478 ((BroadcastParm
*)lp
)->winsta
= hwinsta
;
3479 ret
= EnumDesktopsW( hwinsta
, bcast_desktop
, lp
);
3480 CloseWindowStation( hwinsta
);
3481 TRACE("-->%d\n", ret
);
3485 /***********************************************************************
3486 * BroadcastSystemMessageA (USER32.@)
3487 * BroadcastSystemMessage (USER32.@)
3489 LONG WINAPI
BroadcastSystemMessageA( DWORD flags
, LPDWORD recipients
, UINT msg
, WPARAM wp
, LPARAM lp
)
3491 return BroadcastSystemMessageExA( flags
, recipients
, msg
, wp
, lp
, NULL
);
3495 /***********************************************************************
3496 * BroadcastSystemMessageW (USER32.@)
3498 LONG WINAPI
BroadcastSystemMessageW( DWORD flags
, LPDWORD recipients
, UINT msg
, WPARAM wp
, LPARAM lp
)
3500 return BroadcastSystemMessageExW( flags
, recipients
, msg
, wp
, lp
, NULL
);
3503 /***********************************************************************
3504 * BroadcastSystemMessageExA (USER32.@)
3506 LONG WINAPI
BroadcastSystemMessageExA( DWORD flags
, LPDWORD recipients
, UINT msg
, WPARAM wp
, LPARAM lp
, PBSMINFO pinfo
)
3508 map_wparam_AtoW( msg
, &wp
, WMCHAR_MAP_NOMAPPING
);
3509 return BroadcastSystemMessageExW( flags
, recipients
, msg
, wp
, lp
, NULL
);
3513 /***********************************************************************
3514 * BroadcastSystemMessageExW (USER32.@)
3516 LONG WINAPI
BroadcastSystemMessageExW( DWORD flags
, LPDWORD recipients
, UINT msg
, WPARAM wp
, LPARAM lp
, PBSMINFO pinfo
)
3519 DWORD recips
= BSM_ALLCOMPONENTS
;
3521 static const DWORD all_flags
= ( BSF_QUERY
| BSF_IGNORECURRENTTASK
| BSF_FLUSHDISK
| BSF_NOHANG
3522 | BSF_POSTMESSAGE
| BSF_FORCEIFHUNG
| BSF_NOTIMEOUTIFNOTHUNG
3523 | BSF_ALLOWSFW
| BSF_SENDNOTIFYMESSAGE
| BSF_RETURNHDESK
| BSF_LUID
);
3525 TRACE("Flags: %08x, recipients: %p(0x%x), msg: %04x, wparam: %08lx, lparam: %08lx\n", flags
, recipients
,
3526 (recipients
? *recipients
: recips
), msg
, wp
, lp
);
3528 if (flags
& ~all_flags
)
3530 SetLastError(ERROR_INVALID_PARAMETER
);
3535 recipients
= &recips
;
3537 if ( pinfo
&& flags
& BSF_QUERY
)
3538 FIXME("Not returning PBSMINFO information yet\n");
3541 parm
.recipients
= recipients
;
3545 parm
.success
= TRUE
;
3547 if (*recipients
& BSM_ALLDESKTOPS
|| *recipients
== BSM_ALLCOMPONENTS
)
3548 ret
= EnumWindowStationsW(bcast_winsta
, (LONG_PTR
)&parm
);
3549 else if (*recipients
& BSM_APPLICATIONS
)
3551 EnumWindows(bcast_childwindow
, (LONG_PTR
)&parm
);
3555 FIXME("Recipients %08x not supported!\n", *recipients
);
3560 /***********************************************************************
3561 * SetMessageQueue (USER32.@)
3563 BOOL WINAPI
SetMessageQueue( INT size
)
3565 /* now obsolete the message queue will be expanded dynamically as necessary */
3570 /***********************************************************************
3571 * MessageBeep (USER32.@)
3573 BOOL WINAPI
MessageBeep( UINT i
)
3576 SystemParametersInfoA( SPI_GETBEEP
, 0, &active
, FALSE
);
3577 if (active
) USER_Driver
->pBeep();
3582 /***********************************************************************
3583 * SetTimer (USER32.@)
3585 UINT_PTR WINAPI
SetTimer( HWND hwnd
, UINT_PTR id
, UINT timeout
, TIMERPROC proc
)
3588 WNDPROC winproc
= 0;
3590 if (proc
) winproc
= WINPROC_AllocProc( (WNDPROC
)proc
, NULL
);
3592 SERVER_START_REQ( set_win_timer
)
3594 req
->win
= wine_server_user_handle( hwnd
);
3595 req
->msg
= WM_TIMER
;
3597 req
->rate
= max( timeout
, SYS_TIMER_RATE
);
3598 req
->lparam
= (ULONG_PTR
)winproc
;
3599 if (!wine_server_call_err( req
))
3602 if (!ret
) ret
= TRUE
;
3608 TRACE("Added %p %lx %p timeout %d\n", hwnd
, id
, winproc
, timeout
);
3613 /***********************************************************************
3614 * SetSystemTimer (USER32.@)
3616 UINT_PTR WINAPI
SetSystemTimer( HWND hwnd
, UINT_PTR id
, UINT timeout
, TIMERPROC proc
)
3619 WNDPROC winproc
= 0;
3621 if (proc
) winproc
= WINPROC_AllocProc( (WNDPROC
)proc
, NULL
);
3623 SERVER_START_REQ( set_win_timer
)
3625 req
->win
= wine_server_user_handle( hwnd
);
3626 req
->msg
= WM_SYSTIMER
;
3628 req
->rate
= max( timeout
, SYS_TIMER_RATE
);
3629 req
->lparam
= (ULONG_PTR
)winproc
;
3630 if (!wine_server_call_err( req
))
3633 if (!ret
) ret
= TRUE
;
3639 TRACE("Added %p %lx %p timeout %d\n", hwnd
, id
, winproc
, timeout
);
3644 /***********************************************************************
3645 * KillTimer (USER32.@)
3647 BOOL WINAPI
KillTimer( HWND hwnd
, UINT_PTR id
)
3651 SERVER_START_REQ( kill_win_timer
)
3653 req
->win
= wine_server_user_handle( hwnd
);
3654 req
->msg
= WM_TIMER
;
3656 ret
= !wine_server_call_err( req
);
3663 /***********************************************************************
3664 * KillSystemTimer (USER32.@)
3666 BOOL WINAPI
KillSystemTimer( HWND hwnd
, UINT_PTR id
)
3670 SERVER_START_REQ( kill_win_timer
)
3672 req
->win
= wine_server_user_handle( hwnd
);
3673 req
->msg
= WM_SYSTIMER
;
3675 ret
= !wine_server_call_err( req
);
3682 /**********************************************************************
3683 * GetGUIThreadInfo (USER32.@)
3685 BOOL WINAPI
GetGUIThreadInfo( DWORD id
, GUITHREADINFO
*info
)
3689 SERVER_START_REQ( get_thread_input
)
3692 if ((ret
= !wine_server_call_err( req
)))
3695 info
->hwndActive
= wine_server_ptr_handle( reply
->active
);
3696 info
->hwndFocus
= wine_server_ptr_handle( reply
->focus
);
3697 info
->hwndCapture
= wine_server_ptr_handle( reply
->capture
);
3698 info
->hwndMenuOwner
= wine_server_ptr_handle( reply
->menu_owner
);
3699 info
->hwndMoveSize
= wine_server_ptr_handle( reply
->move_size
);
3700 info
->hwndCaret
= wine_server_ptr_handle( reply
->caret
);
3701 info
->rcCaret
.left
= reply
->rect
.left
;
3702 info
->rcCaret
.top
= reply
->rect
.top
;
3703 info
->rcCaret
.right
= reply
->rect
.right
;
3704 info
->rcCaret
.bottom
= reply
->rect
.bottom
;
3705 if (reply
->menu_owner
) info
->flags
|= GUI_INMENUMODE
;
3706 if (reply
->move_size
) info
->flags
|= GUI_INMOVESIZE
;
3707 if (reply
->caret
) info
->flags
|= GUI_CARETBLINKING
;
3715 /******************************************************************
3716 * IsHungAppWindow (USER32.@)
3719 BOOL WINAPI
IsHungAppWindow( HWND hWnd
)
3723 SERVER_START_REQ( is_window_hung
)
3725 req
->win
= wine_server_user_handle( hWnd
);
3726 ret
= !wine_server_call_err( req
) && reply
->is_hung
;
3732 /******************************************************************
3733 * ChangeWindowMessageFilter (USER32.@)
3735 BOOL WINAPI
ChangeWindowMessageFilter( UINT message
, DWORD flag
)
3737 FIXME( "%x %08x\n", message
, flag
);