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
55 #define MAX_SENDMSG_RECURSION 64
57 #define SYS_TIMER_RATE 55 /* min. timer rate in ms (actually 54.925)*/
59 /* description of the data fields that need to be packed along with a sent message */
63 const void *data
[MAX_PACK_COUNT
];
64 size_t size
[MAX_PACK_COUNT
];
67 /* info about the message currently being received by the current thread */
68 struct received_message_info
70 enum message_type type
;
72 UINT flags
; /* InSendMessageEx return flags */
75 /* structure to group all parameters for sent messages of the various kinds */
76 struct send_message_info
78 enum message_type type
;
84 UINT flags
; /* flags for SendMessageTimeout */
85 UINT timeout
; /* timeout for SendMessageTimeout */
86 SENDASYNCPROC callback
; /* callback function for SendMessageCallback */
87 ULONG_PTR data
; /* callback data */
88 enum wm_char_mapping wm_char
;
92 /* Message class descriptor */
93 static const WCHAR messageW
[] = {'M','e','s','s','a','g','e',0};
94 static LRESULT WINAPI
message_winproc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
);
95 const struct builtin_class_descr MESSAGE_builtin_class
=
99 NULL
, /* procA (winproc is Unicode only) */
100 message_winproc
, /* procW */
102 IDC_ARROW
, /* cursor */
108 /* flag for messages that contain pointers */
109 /* 32 messages per entry, messages 0..31 map to bits 0..31 */
111 #define SET(msg) (1 << ((msg) & 31))
113 static const unsigned int message_pointer_flags
[] =
116 SET(WM_CREATE
) | SET(WM_SETTEXT
) | SET(WM_GETTEXT
) |
117 SET(WM_WININICHANGE
) | SET(WM_DEVMODECHANGE
),
119 SET(WM_GETMINMAXINFO
) | SET(WM_DRAWITEM
) | SET(WM_MEASUREITEM
) | SET(WM_DELETEITEM
) |
122 SET(WM_WINDOWPOSCHANGING
) | SET(WM_WINDOWPOSCHANGED
) | SET(WM_COPYDATA
) |
123 SET(WM_NOTIFY
) | SET(WM_HELP
),
125 SET(WM_STYLECHANGING
) | SET(WM_STYLECHANGED
),
127 SET(WM_NCCREATE
) | SET(WM_NCCALCSIZE
) | SET(WM_GETDLGCODE
),
129 SET(EM_GETSEL
) | SET(EM_GETRECT
) | SET(EM_SETRECT
) | SET(EM_SETRECTNP
),
131 SET(EM_REPLACESEL
) | SET(EM_GETLINE
) | SET(EM_SETTABSTOPS
),
133 SET(SBM_GETRANGE
) | SET(SBM_SETSCROLLINFO
) | SET(SBM_GETSCROLLINFO
) | SET(SBM_GETSCROLLBARINFO
),
139 SET(CB_GETEDITSEL
) | SET(CB_ADDSTRING
) | SET(CB_DIR
) | SET(CB_GETLBTEXT
) |
140 SET(CB_INSERTSTRING
) | SET(CB_FINDSTRING
) | SET(CB_SELECTSTRING
) |
141 SET(CB_GETDROPPEDCONTROLRECT
) | SET(CB_FINDSTRINGEXACT
),
145 SET(LB_ADDSTRING
) | SET(LB_INSERTSTRING
) | SET(LB_GETTEXT
) | SET(LB_SELECTSTRING
) |
146 SET(LB_DIR
) | SET(LB_FINDSTRING
) |
147 SET(LB_GETSELITEMS
) | SET(LB_SETTABSTOPS
) | SET(LB_ADDFILE
) | SET(LB_GETITEMRECT
),
149 SET(LB_FINDSTRINGEXACT
),
155 SET(WM_NEXTMENU
) | SET(WM_SIZING
) | SET(WM_MOVING
) | SET(WM_DEVICECHANGE
),
157 SET(WM_MDICREATE
) | SET(WM_MDIGETACTIVE
) | SET(WM_DROPOBJECT
) |
158 SET(WM_QUERYDROPOBJECT
) | SET(WM_DRAGLOOP
) | SET(WM_DRAGSELECT
) | SET(WM_DRAGMOVE
),
172 SET(WM_ASKCBFORMATNAME
)
175 /* flags for messages that contain Unicode strings */
176 static const unsigned int message_unicode_flags
[] =
179 SET(WM_CREATE
) | SET(WM_SETTEXT
) | SET(WM_GETTEXT
) | SET(WM_GETTEXTLENGTH
) |
180 SET(WM_WININICHANGE
) | SET(WM_DEVMODECHANGE
),
192 SET(EM_REPLACESEL
) | SET(EM_GETLINE
) | SET(EM_SETPASSWORDCHAR
),
196 SET(WM_CHAR
) | SET(WM_DEADCHAR
) | SET(WM_SYSCHAR
) | SET(WM_SYSDEADCHAR
),
200 SET(CB_ADDSTRING
) | SET(CB_DIR
) | SET(CB_GETLBTEXT
) | SET(CB_GETLBTEXTLEN
) |
201 SET(CB_INSERTSTRING
) | SET(CB_FINDSTRING
) | SET(CB_SELECTSTRING
) | SET(CB_FINDSTRINGEXACT
),
205 SET(LB_ADDSTRING
) | SET(LB_INSERTSTRING
) | SET(LB_GETTEXT
) | SET(LB_GETTEXTLEN
) |
206 SET(LB_SELECTSTRING
) | SET(LB_DIR
) | SET(LB_FINDSTRING
) | SET(LB_ADDFILE
),
208 SET(LB_FINDSTRINGEXACT
),
230 SET(WM_PAINTCLIPBOARD
) | SET(WM_SIZECLIPBOARD
) | SET(WM_ASKCBFORMATNAME
)
233 /* check whether a given message type includes pointers */
234 static inline int is_pointer_message( UINT message
)
236 if (message
>= 8*sizeof(message_pointer_flags
)) return FALSE
;
237 return (message_pointer_flags
[message
/ 32] & SET(message
)) != 0;
240 /* check whether a given message type contains Unicode (or ASCII) chars */
241 static inline int is_unicode_message( UINT message
)
243 if (message
>= 8*sizeof(message_unicode_flags
)) return FALSE
;
244 return (message_unicode_flags
[message
/ 32] & SET(message
)) != 0;
249 /* add a data field to a packed message */
250 static inline void push_data( struct packed_message
*data
, const void *ptr
, size_t size
)
252 data
->data
[data
->count
] = ptr
;
253 data
->size
[data
->count
] = size
;
257 /* add a string to a packed message */
258 static inline void push_string( struct packed_message
*data
, LPCWSTR str
)
260 push_data( data
, str
, (strlenW(str
) + 1) * sizeof(WCHAR
) );
263 /* make sure that the buffer contains a valid null-terminated Unicode string */
264 static inline BOOL
check_string( LPCWSTR str
, size_t size
)
266 for (size
/= sizeof(WCHAR
); size
; size
--, str
++)
267 if (!*str
) return TRUE
;
271 /* make sure that there is space for 'size' bytes in buffer, growing it if needed */
272 static inline void *get_buffer_space( void **buffer
, size_t size
)
278 if (!(ret
= HeapReAlloc( GetProcessHeap(), 0, *buffer
, size
)))
279 HeapFree( GetProcessHeap(), 0, *buffer
);
281 else ret
= HeapAlloc( GetProcessHeap(), 0, size
);
287 /* check whether a combobox expects strings or ids in CB_ADDSTRING/CB_INSERTSTRING */
288 static inline BOOL
combobox_has_strings( HWND hwnd
)
290 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
291 return (!(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) || (style
& CBS_HASSTRINGS
));
294 /* check whether a listbox expects strings or ids in LB_ADDSTRING/LB_INSERTSTRING */
295 static inline BOOL
listbox_has_strings( HWND hwnd
)
297 DWORD style
= GetWindowLongA( hwnd
, GWL_STYLE
);
298 return (!(style
& (LBS_OWNERDRAWFIXED
| LBS_OWNERDRAWVARIABLE
)) || (style
& LBS_HASSTRINGS
));
301 /* check whether message is in the range of keyboard messages */
302 static inline BOOL
is_keyboard_message( UINT message
)
304 return (message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
);
307 /* check whether message is in the range of mouse messages */
308 static inline BOOL
is_mouse_message( UINT message
)
310 return ((message
>= WM_NCMOUSEFIRST
&& message
<= WM_NCMOUSELAST
) ||
311 (message
>= WM_MOUSEFIRST
&& message
<= WM_MOUSELAST
));
314 /* check whether message matches the specified hwnd filter */
315 static inline BOOL
check_hwnd_filter( const MSG
*msg
, HWND hwnd_filter
)
317 if (!hwnd_filter
|| hwnd_filter
== GetDesktopWindow()) return TRUE
;
318 return (msg
->hwnd
== hwnd_filter
|| IsChild( hwnd_filter
, msg
->hwnd
));
321 /* check for pending WM_CHAR message with DBCS trailing byte */
322 static inline BOOL
get_pending_wmchar( MSG
*msg
, UINT first
, UINT last
, BOOL remove
)
324 struct wm_char_mapping_data
*data
= get_user_thread_info()->wmchar_data
;
326 if (!data
|| !data
->get_msg
.message
) return FALSE
;
327 if ((first
|| last
) && (first
> WM_CHAR
|| last
< WM_CHAR
)) return FALSE
;
328 if (!msg
) return FALSE
;
329 *msg
= data
->get_msg
;
330 if (remove
) data
->get_msg
.message
= 0;
335 /***********************************************************************
338 * Window procedure for "Message" windows (HWND_MESSAGE parent).
340 static LRESULT WINAPI
message_winproc( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
342 if (message
== WM_NCCREATE
) return TRUE
;
343 return 0; /* all other messages are ignored */
347 /***********************************************************************
348 * broadcast_message_callback
350 * Helper callback for broadcasting messages.
352 static BOOL CALLBACK
broadcast_message_callback( HWND hwnd
, LPARAM lparam
)
354 struct send_message_info
*info
= (struct send_message_info
*)lparam
;
355 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & (WS_POPUP
|WS_CAPTION
))) return TRUE
;
359 SendMessageTimeoutW( hwnd
, info
->msg
, info
->wparam
, info
->lparam
,
360 info
->flags
, info
->timeout
, NULL
);
363 SendMessageTimeoutA( hwnd
, info
->msg
, info
->wparam
, info
->lparam
,
364 info
->flags
, info
->timeout
, NULL
);
367 SendNotifyMessageW( hwnd
, info
->msg
, info
->wparam
, info
->lparam
);
370 SendMessageCallbackW( hwnd
, info
->msg
, info
->wparam
, info
->lparam
,
371 info
->callback
, info
->data
);
374 PostMessageW( hwnd
, info
->msg
, info
->wparam
, info
->lparam
);
377 ERR( "bad type %d\n", info
->type
);
384 /***********************************************************************
387 * Convert the wparam of an ASCII message to Unicode.
389 BOOL
map_wparam_AtoW( UINT message
, WPARAM
*wparam
, enum wm_char_mapping mapping
)
398 /* WM_CHAR is magic: a DBCS char can be sent/posted as two consecutive WM_CHAR
399 * messages, in which case the first char is stored, and the conversion
400 * to Unicode only takes place once the second char is sent/posted.
402 if (mapping
!= WMCHAR_MAP_NOMAPPING
)
404 struct wm_char_mapping_data
*data
= get_user_thread_info()->wmchar_data
;
405 BYTE low
= LOBYTE(*wparam
);
410 ch
[1] = HIBYTE(*wparam
);
411 RtlMultiByteToUnicodeN( wch
, sizeof(wch
), NULL
, ch
, 2 );
412 TRACE( "map %02x,%02x -> %04x mapping %u\n", (BYTE
)ch
[0], (BYTE
)ch
[1], wch
[0], mapping
);
413 if (data
) data
->lead_byte
[mapping
] = 0;
415 else if (data
&& data
->lead_byte
[mapping
])
417 ch
[0] = data
->lead_byte
[mapping
];
419 RtlMultiByteToUnicodeN( wch
, sizeof(wch
), NULL
, ch
, 2 );
420 TRACE( "map stored %02x,%02x -> %04x mapping %u\n", (BYTE
)ch
[0], (BYTE
)ch
[1], wch
[0], mapping
);
421 data
->lead_byte
[mapping
] = 0;
423 else if (!IsDBCSLeadByte( low
))
426 RtlMultiByteToUnicodeN( wch
, sizeof(wch
), NULL
, ch
, 1 );
427 TRACE( "map %02x -> %04x\n", (BYTE
)ch
[0], wch
[0] );
428 if (data
) data
->lead_byte
[mapping
] = 0;
430 else /* store it and wait for trail byte */
434 if (!(data
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*data
) )))
436 get_user_thread_info()->wmchar_data
= data
;
438 TRACE( "storing lead byte %02x mapping %u\n", low
, mapping
);
439 data
->lead_byte
[mapping
] = low
;
442 *wparam
= MAKEWPARAM(wch
[0], wch
[1]);
445 /* else fall through */
447 case EM_SETPASSWORDCHAR
:
452 ch
[0] = LOBYTE(*wparam
);
453 ch
[1] = HIBYTE(*wparam
);
454 RtlMultiByteToUnicodeN( wch
, sizeof(wch
), NULL
, ch
, 2 );
455 *wparam
= MAKEWPARAM(wch
[0], wch
[1]);
458 ch
[0] = HIBYTE(*wparam
);
459 ch
[1] = LOBYTE(*wparam
);
460 if (ch
[0]) RtlMultiByteToUnicodeN( wch
, sizeof(wch
[0]), NULL
, ch
, 2 );
461 else RtlMultiByteToUnicodeN( wch
, sizeof(wch
[0]), NULL
, ch
+ 1, 1 );
462 *wparam
= MAKEWPARAM(wch
[0], HIWORD(*wparam
));
469 /***********************************************************************
472 * Convert the wparam of a Unicode message to ASCII.
474 static void map_wparam_WtoA( MSG
*msg
, BOOL remove
)
483 if (!HIWORD(msg
->wParam
))
485 wch
[0] = LOWORD(msg
->wParam
);
487 RtlUnicodeToMultiByteN( (LPSTR
)ch
, 2, &len
, wch
, sizeof(wch
[0]) );
488 if (len
== 2) /* DBCS char */
490 struct wm_char_mapping_data
*data
= get_user_thread_info()->wmchar_data
;
493 if (!(data
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*data
) ))) return;
494 get_user_thread_info()->wmchar_data
= data
;
498 data
->get_msg
= *msg
;
499 data
->get_msg
.wParam
= ch
[1];
505 /* else fall through */
507 case EM_SETPASSWORDCHAR
:
512 wch
[0] = LOWORD(msg
->wParam
);
513 wch
[1] = HIWORD(msg
->wParam
);
515 RtlUnicodeToMultiByteN( (LPSTR
)ch
, 2, NULL
, wch
, sizeof(wch
) );
516 msg
->wParam
= MAKEWPARAM( ch
[0] | (ch
[1] << 8), 0 );
519 wch
[0] = LOWORD(msg
->wParam
);
521 RtlUnicodeToMultiByteN( (LPSTR
)ch
, 2, &len
, wch
, sizeof(wch
[0]) );
523 msg
->wParam
= MAKEWPARAM( (ch
[0] << 8) | ch
[1], HIWORD(msg
->wParam
) );
525 msg
->wParam
= MAKEWPARAM( ch
[0], HIWORD(msg
->wParam
) );
531 /***********************************************************************
534 * Pack a message for sending to another process.
535 * Return the size of the data we expect in the message reply.
536 * Set data->count to -1 if there is an error.
538 static size_t pack_message( HWND hwnd
, UINT message
, WPARAM wparam
, LPARAM lparam
,
539 struct packed_message
*data
)
547 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lparam
;
548 push_data( data
, cs
, sizeof(*cs
) );
549 if (HIWORD(cs
->lpszName
)) push_string( data
, cs
->lpszName
);
550 if (HIWORD(cs
->lpszClass
)) push_string( data
, cs
->lpszClass
);
554 case WM_ASKCBFORMATNAME
:
555 return wparam
* sizeof(WCHAR
);
556 case WM_WININICHANGE
:
557 if (lparam
) push_string(data
, (LPWSTR
)lparam
);
560 case WM_DEVMODECHANGE
:
565 push_string( data
, (LPWSTR
)lparam
);
567 case WM_GETMINMAXINFO
:
568 push_data( data
, (MINMAXINFO
*)lparam
, sizeof(MINMAXINFO
) );
569 return sizeof(MINMAXINFO
);
571 push_data( data
, (DRAWITEMSTRUCT
*)lparam
, sizeof(DRAWITEMSTRUCT
) );
574 push_data( data
, (MEASUREITEMSTRUCT
*)lparam
, sizeof(MEASUREITEMSTRUCT
) );
575 return sizeof(MEASUREITEMSTRUCT
);
577 push_data( data
, (DELETEITEMSTRUCT
*)lparam
, sizeof(DELETEITEMSTRUCT
) );
580 push_data( data
, (COMPAREITEMSTRUCT
*)lparam
, sizeof(COMPAREITEMSTRUCT
) );
582 case WM_WINDOWPOSCHANGING
:
583 case WM_WINDOWPOSCHANGED
:
584 push_data( data
, (WINDOWPOS
*)lparam
, sizeof(WINDOWPOS
) );
585 return sizeof(WINDOWPOS
);
588 COPYDATASTRUCT
*cp
= (COPYDATASTRUCT
*)lparam
;
589 push_data( data
, cp
, sizeof(*cp
) );
590 if (cp
->lpData
) push_data( data
, cp
->lpData
, cp
->cbData
);
594 /* WM_NOTIFY cannot be sent across processes (MSDN) */
598 push_data( data
, (HELPINFO
*)lparam
, sizeof(HELPINFO
) );
600 case WM_STYLECHANGING
:
601 case WM_STYLECHANGED
:
602 push_data( data
, (STYLESTRUCT
*)lparam
, sizeof(STYLESTRUCT
) );
607 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
612 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lparam
;
613 push_data( data
, nc
, sizeof(*nc
) );
614 push_data( data
, nc
->lppos
, sizeof(*nc
->lppos
) );
615 return sizeof(*nc
) + sizeof(*nc
->lppos
);
618 if (lparam
) push_data( data
, (MSG
*)lparam
, sizeof(MSG
) );
620 case SBM_SETSCROLLINFO
:
621 push_data( data
, (SCROLLINFO
*)lparam
, sizeof(SCROLLINFO
) );
623 case SBM_GETSCROLLINFO
:
624 push_data( data
, (SCROLLINFO
*)lparam
, sizeof(SCROLLINFO
) );
625 return sizeof(SCROLLINFO
);
626 case SBM_GETSCROLLBARINFO
:
628 const SCROLLBARINFO
*info
= (const SCROLLBARINFO
*)lparam
;
629 size_t size
= min( info
->cbSize
, sizeof(SCROLLBARINFO
) );
630 push_data( data
, info
, size
);
638 if (wparam
) size
+= sizeof(DWORD
);
639 if (lparam
) size
+= sizeof(DWORD
);
644 case CB_GETDROPPEDCONTROLRECT
:
648 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
652 WORD
*pw
= (WORD
*)lparam
;
653 push_data( data
, pw
, sizeof(*pw
) );
654 return *pw
* sizeof(WCHAR
);
658 if (wparam
) push_data( data
, (UINT
*)lparam
, sizeof(UINT
) * wparam
);
661 case CB_INSERTSTRING
:
663 case CB_FINDSTRINGEXACT
:
664 case CB_SELECTSTRING
:
665 if (combobox_has_strings( hwnd
)) push_string( data
, (LPWSTR
)lparam
);
668 if (!combobox_has_strings( hwnd
)) return sizeof(ULONG_PTR
);
669 return (SendMessageW( hwnd
, CB_GETLBTEXTLEN
, wparam
, 0 ) + 1) * sizeof(WCHAR
);
671 case LB_INSERTSTRING
:
673 case LB_FINDSTRINGEXACT
:
674 case LB_SELECTSTRING
:
675 if (listbox_has_strings( hwnd
)) push_string( data
, (LPWSTR
)lparam
);
678 if (!listbox_has_strings( hwnd
)) return sizeof(ULONG_PTR
);
679 return (SendMessageW( hwnd
, LB_GETTEXTLEN
, wparam
, 0 ) + 1) * sizeof(WCHAR
);
681 return wparam
* sizeof(UINT
);
683 push_data( data
, (MDINEXTMENU
*)lparam
, sizeof(MDINEXTMENU
) );
684 return sizeof(MDINEXTMENU
);
687 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
691 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lparam
;
692 push_data( data
, cs
, sizeof(*cs
) );
693 if (HIWORD(cs
->szTitle
)) push_string( data
, cs
->szTitle
);
694 if (HIWORD(cs
->szClass
)) push_string( data
, cs
->szClass
);
697 case WM_MDIGETACTIVE
:
698 if (lparam
) return sizeof(BOOL
);
700 case WM_DEVICECHANGE
:
702 DEV_BROADCAST_HDR
*header
= (DEV_BROADCAST_HDR
*)lparam
;
703 push_data( data
, header
, header
->dbch_size
);
706 case WM_WINE_SETWINDOWPOS
:
707 push_data( data
, (WINDOWPOS
*)lparam
, sizeof(WINDOWPOS
) );
709 case WM_WINE_KEYBOARD_LL_HOOK
:
711 struct hook_extra_info
*h_extra
= (struct hook_extra_info
*)lparam
;
712 push_data( data
, h_extra
, sizeof(*h_extra
) );
713 push_data( data
, (LPVOID
)h_extra
->lparam
, sizeof(KBDLLHOOKSTRUCT
) );
716 case WM_WINE_MOUSE_LL_HOOK
:
718 struct hook_extra_info
*h_extra
= (struct hook_extra_info
*)lparam
;
719 push_data( data
, h_extra
, sizeof(*h_extra
) );
720 push_data( data
, (LPVOID
)h_extra
->lparam
, sizeof(MSLLHOOKSTRUCT
) );
724 if (wparam
<= 1) return 0;
725 FIXME( "WM_NCPAINT hdc packing not supported yet\n" );
729 if (!wparam
) return 0;
732 /* these contain an HFONT */
735 /* these contain an HDC */
737 case WM_ICONERASEBKGND
:
738 case WM_CTLCOLORMSGBOX
:
739 case WM_CTLCOLOREDIT
:
740 case WM_CTLCOLORLISTBOX
:
743 case WM_CTLCOLORSCROLLBAR
:
744 case WM_CTLCOLORSTATIC
:
747 /* these contain an HGLOBAL */
748 case WM_PAINTCLIPBOARD
:
749 case WM_SIZECLIPBOARD
:
750 /* these contain HICON */
753 case WM_QUERYDRAGICON
:
754 case WM_QUERYPARKICON
:
755 /* these contain pointers */
757 case WM_QUERYDROPOBJECT
:
761 FIXME( "msg %x (%s) not supported yet\n", message
, SPY_GetMsgName(message
, hwnd
) );
769 /***********************************************************************
772 * Unpack a message received from another process.
774 static BOOL
unpack_message( HWND hwnd
, UINT message
, WPARAM
*wparam
, LPARAM
*lparam
,
775 void **buffer
, size_t size
)
784 CREATESTRUCTW
*cs
= *buffer
;
785 WCHAR
*str
= (WCHAR
*)(cs
+ 1);
786 if (size
< sizeof(*cs
)) return FALSE
;
788 if (HIWORD(cs
->lpszName
))
790 if (!check_string( str
, size
)) return FALSE
;
792 size
-= (strlenW(str
) + 1) * sizeof(WCHAR
);
793 str
+= strlenW(str
) + 1;
795 if (HIWORD(cs
->lpszClass
))
797 if (!check_string( str
, size
)) return FALSE
;
803 case WM_ASKCBFORMATNAME
:
804 if (!get_buffer_space( buffer
, (*wparam
* sizeof(WCHAR
)) )) return FALSE
;
806 case WM_WININICHANGE
:
807 if (!*lparam
) return TRUE
;
810 case WM_DEVMODECHANGE
:
815 if (!check_string( *buffer
, size
)) return FALSE
;
817 case WM_GETMINMAXINFO
:
818 minsize
= sizeof(MINMAXINFO
);
821 minsize
= sizeof(DRAWITEMSTRUCT
);
824 minsize
= sizeof(MEASUREITEMSTRUCT
);
827 minsize
= sizeof(DELETEITEMSTRUCT
);
830 minsize
= sizeof(COMPAREITEMSTRUCT
);
832 case WM_WINDOWPOSCHANGING
:
833 case WM_WINDOWPOSCHANGED
:
834 case WM_WINE_SETWINDOWPOS
:
835 minsize
= sizeof(WINDOWPOS
);
839 COPYDATASTRUCT
*cp
= *buffer
;
840 if (size
< sizeof(*cp
)) return FALSE
;
843 minsize
= sizeof(*cp
) + cp
->cbData
;
849 /* WM_NOTIFY cannot be sent across processes (MSDN) */
852 minsize
= sizeof(HELPINFO
);
854 case WM_STYLECHANGING
:
855 case WM_STYLECHANGED
:
856 minsize
= sizeof(STYLESTRUCT
);
859 if (!*wparam
) minsize
= sizeof(RECT
);
862 NCCALCSIZE_PARAMS
*nc
= *buffer
;
863 if (size
< sizeof(*nc
) + sizeof(*nc
->lppos
)) return FALSE
;
864 nc
->lppos
= (WINDOWPOS
*)(nc
+ 1);
868 if (!*lparam
) return TRUE
;
869 minsize
= sizeof(MSG
);
871 case SBM_SETSCROLLINFO
:
872 minsize
= sizeof(SCROLLINFO
);
874 case SBM_GETSCROLLINFO
:
875 if (!get_buffer_space( buffer
, sizeof(SCROLLINFO
))) return FALSE
;
877 case SBM_GETSCROLLBARINFO
:
878 if (!get_buffer_space( buffer
, sizeof(SCROLLBARINFO
))) return FALSE
;
883 if (*wparam
|| *lparam
)
885 if (!get_buffer_space( buffer
, 2*sizeof(DWORD
) )) return FALSE
;
886 if (*wparam
) *wparam
= (WPARAM
)*buffer
;
887 if (*lparam
) *lparam
= (LPARAM
)((DWORD
*)*buffer
+ 1);
892 case CB_GETDROPPEDCONTROLRECT
:
893 if (!get_buffer_space( buffer
, sizeof(RECT
) )) return FALSE
;
897 minsize
= sizeof(RECT
);
902 if (size
< sizeof(WORD
)) return FALSE
;
903 len
= *(WORD
*)*buffer
;
904 if (!get_buffer_space( buffer
, (len
+ 1) * sizeof(WCHAR
) )) return FALSE
;
905 *lparam
= (LPARAM
)*buffer
+ sizeof(WORD
); /* don't erase WORD at start of buffer */
910 if (!*wparam
) return TRUE
;
911 minsize
= *wparam
* sizeof(UINT
);
914 case CB_INSERTSTRING
:
916 case CB_FINDSTRINGEXACT
:
917 case CB_SELECTSTRING
:
919 case LB_INSERTSTRING
:
921 case LB_FINDSTRINGEXACT
:
922 case LB_SELECTSTRING
:
923 if (!*buffer
) return TRUE
;
924 if (!check_string( *buffer
, size
)) return FALSE
;
928 size
= sizeof(ULONG_PTR
);
929 if (combobox_has_strings( hwnd
))
930 size
= (SendMessageW( hwnd
, CB_GETLBTEXTLEN
, *wparam
, 0 ) + 1) * sizeof(WCHAR
);
931 if (!get_buffer_space( buffer
, size
)) return FALSE
;
936 size
= sizeof(ULONG_PTR
);
937 if (listbox_has_strings( hwnd
))
938 size
= (SendMessageW( hwnd
, LB_GETTEXTLEN
, *wparam
, 0 ) + 1) * sizeof(WCHAR
);
939 if (!get_buffer_space( buffer
, size
)) return FALSE
;
943 if (!get_buffer_space( buffer
, *wparam
* sizeof(UINT
) )) return FALSE
;
946 minsize
= sizeof(MDINEXTMENU
);
947 if (!get_buffer_space( buffer
, sizeof(MDINEXTMENU
) )) return FALSE
;
951 minsize
= sizeof(RECT
);
952 if (!get_buffer_space( buffer
, sizeof(RECT
) )) return FALSE
;
956 MDICREATESTRUCTW
*cs
= *buffer
;
957 WCHAR
*str
= (WCHAR
*)(cs
+ 1);
958 if (size
< sizeof(*cs
)) return FALSE
;
960 if (HIWORD(cs
->szTitle
))
962 if (!check_string( str
, size
)) return FALSE
;
964 size
-= (strlenW(str
) + 1) * sizeof(WCHAR
);
965 str
+= strlenW(str
) + 1;
967 if (HIWORD(cs
->szClass
))
969 if (!check_string( str
, size
)) return FALSE
;
974 case WM_MDIGETACTIVE
:
975 if (!*lparam
) return TRUE
;
976 if (!get_buffer_space( buffer
, sizeof(BOOL
) )) return FALSE
;
978 case WM_DEVICECHANGE
:
979 minsize
= sizeof(DEV_BROADCAST_HDR
);
981 case WM_WINE_KEYBOARD_LL_HOOK
:
982 case WM_WINE_MOUSE_LL_HOOK
:
984 struct hook_extra_info
*h_extra
= (struct hook_extra_info
*)*buffer
;
986 minsize
= sizeof(struct hook_extra_info
) +
987 (message
== WM_WINE_KEYBOARD_LL_HOOK
? sizeof(KBDLLHOOKSTRUCT
)
988 : sizeof(MSLLHOOKSTRUCT
));
989 if (size
< minsize
) return FALSE
;
990 h_extra
->lparam
= (LPARAM
)(h_extra
+ 1);
994 if (*wparam
<= 1) return TRUE
;
995 FIXME( "WM_NCPAINT hdc unpacking not supported\n" );
998 if (!*wparam
) return TRUE
;
1001 /* these contain an HFONT */
1004 /* these contain an HDC */
1006 case WM_ICONERASEBKGND
:
1007 case WM_CTLCOLORMSGBOX
:
1008 case WM_CTLCOLOREDIT
:
1009 case WM_CTLCOLORLISTBOX
:
1010 case WM_CTLCOLORBTN
:
1011 case WM_CTLCOLORDLG
:
1012 case WM_CTLCOLORSCROLLBAR
:
1013 case WM_CTLCOLORSTATIC
:
1015 case WM_PRINTCLIENT
:
1016 /* these contain an HGLOBAL */
1017 case WM_PAINTCLIPBOARD
:
1018 case WM_SIZECLIPBOARD
:
1019 /* these contain HICON */
1022 case WM_QUERYDRAGICON
:
1023 case WM_QUERYPARKICON
:
1024 /* these contain pointers */
1026 case WM_QUERYDROPOBJECT
:
1030 FIXME( "msg %x (%s) not supported yet\n", message
, SPY_GetMsgName(message
, hwnd
) );
1034 return TRUE
; /* message doesn't need any unpacking */
1037 /* default exit for most messages: check minsize and store buffer in lparam */
1038 if (size
< minsize
) return FALSE
;
1039 *lparam
= (LPARAM
)*buffer
;
1044 /***********************************************************************
1047 * Pack a reply to a message for sending to another process.
1049 static void pack_reply( HWND hwnd
, UINT message
, WPARAM wparam
, LPARAM lparam
,
1050 LRESULT res
, struct packed_message
*data
)
1057 push_data( data
, (CREATESTRUCTW
*)lparam
, sizeof(CREATESTRUCTW
) );
1062 push_data( data
, (WCHAR
*)lparam
, (res
+ 1) * sizeof(WCHAR
) );
1064 case WM_GETMINMAXINFO
:
1065 push_data( data
, (MINMAXINFO
*)lparam
, sizeof(MINMAXINFO
) );
1067 case WM_MEASUREITEM
:
1068 push_data( data
, (MEASUREITEMSTRUCT
*)lparam
, sizeof(MEASUREITEMSTRUCT
) );
1070 case WM_WINDOWPOSCHANGING
:
1071 case WM_WINDOWPOSCHANGED
:
1072 push_data( data
, (WINDOWPOS
*)lparam
, sizeof(WINDOWPOS
) );
1075 if (lparam
) push_data( data
, (MSG
*)lparam
, sizeof(MSG
) );
1077 case SBM_GETSCROLLINFO
:
1078 push_data( data
, (SCROLLINFO
*)lparam
, sizeof(SCROLLINFO
) );
1081 case LB_GETITEMRECT
:
1082 case CB_GETDROPPEDCONTROLRECT
:
1085 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
1089 WORD
*ptr
= (WORD
*)lparam
;
1090 push_data( data
, ptr
, ptr
[-1] * sizeof(WCHAR
) );
1093 case LB_GETSELITEMS
:
1094 push_data( data
, (UINT
*)lparam
, wparam
* sizeof(UINT
) );
1096 case WM_MDIGETACTIVE
:
1097 if (lparam
) push_data( data
, (BOOL
*)lparam
, sizeof(BOOL
) );
1101 push_data( data
, (RECT
*)lparam
, sizeof(RECT
) );
1104 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lparam
;
1105 push_data( data
, nc
, sizeof(*nc
) );
1106 push_data( data
, nc
->lppos
, sizeof(*nc
->lppos
) );
1112 if (wparam
) push_data( data
, (DWORD
*)wparam
, sizeof(DWORD
) );
1113 if (lparam
) push_data( data
, (DWORD
*)lparam
, sizeof(DWORD
) );
1116 push_data( data
, (MDINEXTMENU
*)lparam
, sizeof(MDINEXTMENU
) );
1119 push_data( data
, (MDICREATESTRUCTW
*)lparam
, sizeof(MDICREATESTRUCTW
) );
1121 case WM_ASKCBFORMATNAME
:
1122 push_data( data
, (WCHAR
*)lparam
, (strlenW((WCHAR
*)lparam
) + 1) * sizeof(WCHAR
) );
1128 /***********************************************************************
1131 * Unpack a message reply received from another process.
1133 static void unpack_reply( HWND hwnd
, UINT message
, WPARAM wparam
, LPARAM lparam
,
1134 void *buffer
, size_t size
)
1141 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lparam
;
1142 LPCWSTR name
= cs
->lpszName
, class = cs
->lpszClass
;
1143 memcpy( cs
, buffer
, min( sizeof(*cs
), size
));
1144 cs
->lpszName
= name
; /* restore the original pointers */
1145 cs
->lpszClass
= class;
1149 case WM_ASKCBFORMATNAME
:
1150 memcpy( (WCHAR
*)lparam
, buffer
, min( wparam
*sizeof(WCHAR
), size
));
1152 case WM_GETMINMAXINFO
:
1153 memcpy( (MINMAXINFO
*)lparam
, buffer
, min( sizeof(MINMAXINFO
), size
));
1155 case WM_MEASUREITEM
:
1156 memcpy( (MEASUREITEMSTRUCT
*)lparam
, buffer
, min( sizeof(MEASUREITEMSTRUCT
), size
));
1158 case WM_WINDOWPOSCHANGING
:
1159 case WM_WINDOWPOSCHANGED
:
1160 memcpy( (WINDOWPOS
*)lparam
, buffer
, min( sizeof(WINDOWPOS
), size
));
1163 if (lparam
) memcpy( (MSG
*)lparam
, buffer
, min( sizeof(MSG
), size
));
1165 case SBM_GETSCROLLINFO
:
1166 memcpy( (SCROLLINFO
*)lparam
, buffer
, min( sizeof(SCROLLINFO
), size
));
1168 case SBM_GETSCROLLBARINFO
:
1169 memcpy( (SCROLLBARINFO
*)lparam
, buffer
, min( sizeof(SCROLLBARINFO
), size
));
1172 case CB_GETDROPPEDCONTROLRECT
:
1173 case LB_GETITEMRECT
:
1176 memcpy( (RECT
*)lparam
, buffer
, min( sizeof(RECT
), size
));
1179 size
= min( size
, (size_t)*(WORD
*)lparam
);
1180 memcpy( (WCHAR
*)lparam
, buffer
, size
);
1182 case LB_GETSELITEMS
:
1183 memcpy( (UINT
*)lparam
, buffer
, min( wparam
*sizeof(UINT
), size
));
1187 memcpy( (WCHAR
*)lparam
, buffer
, size
);
1190 memcpy( (MDINEXTMENU
*)lparam
, buffer
, min( sizeof(MDINEXTMENU
), size
));
1192 case WM_MDIGETACTIVE
:
1193 if (lparam
) memcpy( (BOOL
*)lparam
, buffer
, min( sizeof(BOOL
), size
));
1197 memcpy( (RECT
*)lparam
, buffer
, min( sizeof(RECT
), size
));
1200 NCCALCSIZE_PARAMS
*nc
= (NCCALCSIZE_PARAMS
*)lparam
;
1201 WINDOWPOS
*wp
= nc
->lppos
;
1202 memcpy( nc
, buffer
, min( sizeof(*nc
), size
));
1203 if (size
> sizeof(*nc
))
1205 size
-= sizeof(*nc
);
1206 memcpy( wp
, (NCCALCSIZE_PARAMS
*)buffer
+ 1, min( sizeof(*wp
), size
));
1208 nc
->lppos
= wp
; /* restore the original pointer */
1216 memcpy( (DWORD
*)wparam
, buffer
, min( sizeof(DWORD
), size
));
1217 if (size
<= sizeof(DWORD
)) break;
1218 size
-= sizeof(DWORD
);
1219 buffer
= (DWORD
*)buffer
+ 1;
1221 if (lparam
) memcpy( (DWORD
*)lparam
, buffer
, min( sizeof(DWORD
), size
));
1225 MDICREATESTRUCTW
*cs
= (MDICREATESTRUCTW
*)lparam
;
1226 LPCWSTR title
= cs
->szTitle
, class = cs
->szClass
;
1227 memcpy( cs
, buffer
, min( sizeof(*cs
), size
));
1228 cs
->szTitle
= title
; /* restore the original pointers */
1229 cs
->szClass
= class;
1233 ERR( "should not happen: unexpected message %x\n", message
);
1239 /***********************************************************************
1242 * Send a reply to a sent message.
1244 static void reply_message( struct received_message_info
*info
, LRESULT result
, BOOL remove
)
1246 struct packed_message data
;
1247 int i
, replied
= info
->flags
& ISMEX_REPLIED
;
1249 if (info
->flags
& ISMEX_NOTIFY
) return; /* notify messages don't get replies */
1250 if (!remove
&& replied
) return; /* replied already */
1253 info
->flags
|= ISMEX_REPLIED
;
1255 if (info
->type
== MSG_OTHER_PROCESS
&& !replied
)
1257 pack_reply( info
->msg
.hwnd
, info
->msg
.message
, info
->msg
.wParam
,
1258 info
->msg
.lParam
, result
, &data
);
1261 SERVER_START_REQ( reply_message
)
1263 req
->result
= result
;
1264 req
->remove
= remove
;
1265 for (i
= 0; i
< data
.count
; i
++) wine_server_add_data( req
, data
.data
[i
], data
.size
[i
] );
1266 wine_server_call( req
);
1272 /***********************************************************************
1273 * handle_internal_message
1275 * Handle an internal Wine message instead of calling the window proc.
1277 static LRESULT
handle_internal_message( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1281 case WM_WINE_DESTROYWINDOW
:
1282 return WIN_DestroyWindow( hwnd
);
1283 case WM_WINE_SETWINDOWPOS
:
1284 if (is_desktop_window( hwnd
)) return 0;
1285 return USER_SetWindowPos( (WINDOWPOS
*)lparam
);
1286 case WM_WINE_SHOWWINDOW
:
1287 if (is_desktop_window( hwnd
)) return 0;
1288 return ShowWindow( hwnd
, wparam
);
1289 case WM_WINE_SETPARENT
:
1290 if (is_desktop_window( hwnd
)) return 0;
1291 return (LRESULT
)SetParent( hwnd
, (HWND
)wparam
);
1292 case WM_WINE_SETWINDOWLONG
:
1293 return WIN_SetWindowLong( hwnd
, (short)LOWORD(wparam
), HIWORD(wparam
), lparam
, TRUE
);
1294 case WM_WINE_ENABLEWINDOW
:
1295 if (is_desktop_window( hwnd
)) return 0;
1296 return EnableWindow( hwnd
, wparam
);
1297 case WM_WINE_SETACTIVEWINDOW
:
1298 if (is_desktop_window( hwnd
)) return 0;
1299 return (LRESULT
)SetActiveWindow( (HWND
)wparam
);
1300 case WM_WINE_KEYBOARD_LL_HOOK
:
1301 case WM_WINE_MOUSE_LL_HOOK
:
1303 struct hook_extra_info
*h_extra
= (struct hook_extra_info
*)lparam
;
1305 return call_current_hook( h_extra
->handle
, HC_ACTION
, wparam
, h_extra
->lparam
);
1308 if (msg
>= WM_WINE_FIRST_DRIVER_MSG
&& msg
<= WM_WINE_LAST_DRIVER_MSG
)
1309 return USER_Driver
->pWindowMessage( hwnd
, msg
, wparam
, lparam
);
1310 FIXME( "unknown internal message %x\n", msg
);
1315 /* since the WM_DDE_ACK response to a WM_DDE_EXECUTE message should contain the handle
1316 * to the memory handle, we keep track (in the server side) of all pairs of handle
1317 * used (the client passes its value and the content of the memory handle), and
1318 * the server stored both values (the client, and the local one, created after the
1319 * content). When a ACK message is generated, the list of pair is searched for a
1320 * matching pair, so that the client memory handle can be returned.
1323 HGLOBAL client_hMem
;
1324 HGLOBAL server_hMem
;
1327 static struct DDE_pair
* dde_pairs
;
1328 static int dde_num_alloc
;
1329 static int dde_num_used
;
1331 static CRITICAL_SECTION dde_crst
;
1332 static CRITICAL_SECTION_DEBUG critsect_debug
=
1335 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
1336 0, 0, { (DWORD_PTR
)(__FILE__
": dde_crst") }
1338 static CRITICAL_SECTION dde_crst
= { &critsect_debug
, -1, 0, 0, 0, 0 };
1340 static BOOL
dde_add_pair(HGLOBAL chm
, HGLOBAL shm
)
1345 EnterCriticalSection(&dde_crst
);
1347 /* now remember the pair of hMem on both sides */
1348 if (dde_num_used
== dde_num_alloc
)
1350 struct DDE_pair
* tmp
;
1352 tmp
= HeapReAlloc( GetProcessHeap(), 0, dde_pairs
,
1353 (dde_num_alloc
+ GROWBY
) * sizeof(struct DDE_pair
));
1355 tmp
= HeapAlloc( GetProcessHeap(), 0,
1356 (dde_num_alloc
+ GROWBY
) * sizeof(struct DDE_pair
));
1360 LeaveCriticalSection(&dde_crst
);
1364 /* zero out newly allocated part */
1365 memset(&dde_pairs
[dde_num_alloc
], 0, GROWBY
* sizeof(struct DDE_pair
));
1366 dde_num_alloc
+= GROWBY
;
1369 for (i
= 0; i
< dde_num_alloc
; i
++)
1371 if (dde_pairs
[i
].server_hMem
== 0)
1373 dde_pairs
[i
].client_hMem
= chm
;
1374 dde_pairs
[i
].server_hMem
= shm
;
1379 LeaveCriticalSection(&dde_crst
);
1383 static HGLOBAL
dde_get_pair(HGLOBAL shm
)
1388 EnterCriticalSection(&dde_crst
);
1389 for (i
= 0; i
< dde_num_alloc
; i
++)
1391 if (dde_pairs
[i
].server_hMem
== shm
)
1393 /* free this pair */
1394 dde_pairs
[i
].server_hMem
= 0;
1396 ret
= dde_pairs
[i
].client_hMem
;
1400 LeaveCriticalSection(&dde_crst
);
1404 /***********************************************************************
1407 * Post a DDE message
1409 static BOOL
post_dde_message( struct packed_message
*data
, const struct send_message_info
*info
)
1413 UINT_PTR uiLo
, uiHi
;
1415 HGLOBAL hunlock
= 0;
1419 if (!UnpackDDElParam( info
->msg
, info
->lparam
, &uiLo
, &uiHi
))
1425 /* DDE messages which don't require packing are:
1434 /* uiHi should contain a hMem from WM_DDE_EXECUTE */
1435 HGLOBAL h
= dde_get_pair( (HANDLE
)uiHi
);
1438 /* send back the value of h on the other side */
1439 push_data( data
, &h
, sizeof(HGLOBAL
) );
1441 TRACE( "send dde-ack %lx %08lx => %p\n", uiLo
, uiHi
, h
);
1446 /* uiHi should contain either an atom or 0 */
1447 TRACE( "send dde-ack %lx atom=%lx\n", uiLo
, uiHi
);
1448 lp
= MAKELONG( uiLo
, uiHi
);
1457 size
= GlobalSize( (HGLOBAL
)uiLo
) ;
1458 if ((info
->msg
== WM_DDE_ADVISE
&& size
< sizeof(DDEADVISE
)) ||
1459 (info
->msg
== WM_DDE_DATA
&& size
< FIELD_OFFSET(DDEDATA
, Value
)) ||
1460 (info
->msg
== WM_DDE_POKE
&& size
< FIELD_OFFSET(DDEPOKE
, Value
))
1464 else if (info
->msg
!= WM_DDE_DATA
) return FALSE
;
1469 if ((ptr
= GlobalLock( (HGLOBAL
)uiLo
) ))
1471 DDEDATA
*dde_data
= (DDEDATA
*)ptr
;
1472 TRACE("unused %d, fResponse %d, fRelease %d, fDeferUpd %d, fAckReq %d, cfFormat %d\n",
1473 dde_data
->unused
, dde_data
->fResponse
, dde_data
->fRelease
,
1474 dde_data
->reserved
, dde_data
->fAckReq
, dde_data
->cfFormat
);
1475 push_data( data
, ptr
, size
);
1476 hunlock
= (HGLOBAL
)uiLo
;
1479 TRACE( "send ddepack %u %lx\n", size
, uiHi
);
1481 case WM_DDE_EXECUTE
:
1484 if ((ptr
= GlobalLock( (HGLOBAL
)info
->lparam
) ))
1486 push_data(data
, ptr
, GlobalSize( (HGLOBAL
)info
->lparam
));
1487 /* so that the other side can send it back on ACK */
1489 hunlock
= (HGLOBAL
)info
->lparam
;
1494 SERVER_START_REQ( send_message
)
1496 req
->id
= info
->dest_tid
;
1497 req
->type
= info
->type
;
1499 req
->win
= info
->hwnd
;
1500 req
->msg
= info
->msg
;
1501 req
->wparam
= info
->wparam
;
1503 req
->timeout
= TIMEOUT_INFINITE
;
1504 for (i
= 0; i
< data
->count
; i
++)
1505 wine_server_add_data( req
, data
->data
[i
], data
->size
[i
] );
1506 if ((res
= wine_server_call( req
)))
1508 if (res
== STATUS_INVALID_PARAMETER
)
1509 /* FIXME: find a STATUS_ value for this one */
1510 SetLastError( ERROR_INVALID_THREAD_ID
);
1512 SetLastError( RtlNtStatusToDosError(res
) );
1515 FreeDDElParam(info
->msg
, info
->lparam
);
1518 if (hunlock
) GlobalUnlock(hunlock
);
1523 /***********************************************************************
1524 * unpack_dde_message
1526 * Unpack a posted DDE message received from another process.
1528 static BOOL
unpack_dde_message( HWND hwnd
, UINT message
, WPARAM
*wparam
, LPARAM
*lparam
,
1529 void **buffer
, size_t size
)
1531 UINT_PTR uiLo
, uiHi
;
1540 /* hMem is being passed */
1541 if (size
!= sizeof(HGLOBAL
)) return FALSE
;
1542 if (!buffer
|| !*buffer
) return FALSE
;
1544 memcpy( &hMem
, *buffer
, size
);
1545 uiHi
= (UINT_PTR
)hMem
;
1546 TRACE("recv dde-ack %lx mem=%lx[%lx]\n", uiLo
, uiHi
, GlobalSize( hMem
));
1550 uiLo
= LOWORD( *lparam
);
1551 uiHi
= HIWORD( *lparam
);
1552 TRACE("recv dde-ack %lx atom=%lx\n", uiLo
, uiHi
);
1554 *lparam
= PackDDElParam( WM_DDE_ACK
, uiLo
, uiHi
);
1559 if ((!buffer
|| !*buffer
) && message
!= WM_DDE_DATA
) return FALSE
;
1563 if (!(hMem
= GlobalAlloc( GMEM_MOVEABLE
|GMEM_DDESHARE
, size
)))
1565 if ((ptr
= GlobalLock( hMem
)))
1567 memcpy( ptr
, *buffer
, size
);
1568 GlobalUnlock( hMem
);
1576 uiLo
= (UINT_PTR
)hMem
;
1578 *lparam
= PackDDElParam( message
, uiLo
, uiHi
);
1580 case WM_DDE_EXECUTE
:
1583 if (!buffer
|| !*buffer
) return FALSE
;
1584 if (!(hMem
= GlobalAlloc( GMEM_MOVEABLE
|GMEM_DDESHARE
, size
))) return FALSE
;
1585 if ((ptr
= GlobalLock( hMem
)))
1587 memcpy( ptr
, *buffer
, size
);
1588 GlobalUnlock( hMem
);
1589 TRACE( "exec: pairing c=%08lx s=%p\n", *lparam
, hMem
);
1590 if (!dde_add_pair( (HGLOBAL
)*lparam
, hMem
))
1601 } else return FALSE
;
1602 *lparam
= (LPARAM
)hMem
;
1608 /***********************************************************************
1611 * Call a window procedure and the corresponding hooks.
1613 static LRESULT
call_window_proc( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
1614 BOOL unicode
, BOOL same_thread
, enum wm_char_mapping mapping
)
1616 struct user_thread_info
*thread_info
= get_user_thread_info();
1619 CWPRETSTRUCT cwpret
;
1621 if (thread_info
->recursion_count
> MAX_SENDMSG_RECURSION
) return 0;
1622 thread_info
->recursion_count
++;
1624 if (msg
& 0x80000000)
1626 result
= handle_internal_message( hwnd
, msg
, wparam
, lparam
);
1630 /* first the WH_CALLWNDPROC hook */
1631 hwnd
= WIN_GetFullHandle( hwnd
);
1632 cwp
.lParam
= lparam
;
1633 cwp
.wParam
= wparam
;
1636 HOOK_CallHooks( WH_CALLWNDPROC
, HC_ACTION
, same_thread
, (LPARAM
)&cwp
, unicode
);
1638 /* now call the window procedure */
1639 if (!WINPROC_call_window( hwnd
, msg
, wparam
, lparam
, &result
, unicode
, mapping
)) goto done
;
1641 /* and finally the WH_CALLWNDPROCRET hook */
1642 cwpret
.lResult
= result
;
1643 cwpret
.lParam
= lparam
;
1644 cwpret
.wParam
= wparam
;
1645 cwpret
.message
= msg
;
1647 HOOK_CallHooks( WH_CALLWNDPROCRET
, HC_ACTION
, same_thread
, (LPARAM
)&cwpret
, unicode
);
1649 thread_info
->recursion_count
--;
1654 /***********************************************************************
1655 * send_parent_notify
1657 * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
1658 * the window has the WS_EX_NOPARENTNOTIFY style.
1660 static void send_parent_notify( HWND hwnd
, WORD event
, WORD idChild
, POINT pt
)
1662 /* pt has to be in the client coordinates of the parent window */
1663 MapWindowPoints( 0, hwnd
, &pt
, 1 );
1668 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
)) break;
1669 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_NOPARENTNOTIFY
) break;
1670 if (!(parent
= GetParent(hwnd
))) break;
1671 if (parent
== GetDesktopWindow()) break;
1672 MapWindowPoints( hwnd
, parent
, &pt
, 1 );
1674 SendMessageW( hwnd
, WM_PARENTNOTIFY
,
1675 MAKEWPARAM( event
, idChild
), MAKELPARAM( pt
.x
, pt
.y
) );
1680 /***********************************************************************
1681 * accept_hardware_message
1683 * Tell the server we have passed the message to the app
1684 * (even though we may end up dropping it later on)
1686 static void accept_hardware_message( UINT hw_id
, BOOL remove
, HWND new_hwnd
)
1688 SERVER_START_REQ( accept_hardware_message
)
1691 req
->remove
= remove
;
1692 req
->new_win
= new_hwnd
;
1693 if (wine_server_call( req
))
1694 FIXME("Failed to reply to MSG_HARDWARE message. Message may not be removed from queue.\n");
1700 /***********************************************************************
1701 * process_keyboard_message
1703 * returns TRUE if the contents of 'msg' should be passed to the application
1705 static BOOL
process_keyboard_message( MSG
*msg
, UINT hw_id
, HWND hwnd_filter
,
1706 UINT first
, UINT last
, BOOL remove
)
1710 if (msg
->message
== WM_KEYDOWN
|| msg
->message
== WM_SYSKEYDOWN
||
1711 msg
->message
== WM_KEYUP
|| msg
->message
== WM_SYSKEYUP
)
1712 switch (msg
->wParam
)
1714 case VK_LSHIFT
: case VK_RSHIFT
:
1715 msg
->wParam
= VK_SHIFT
;
1717 case VK_LCONTROL
: case VK_RCONTROL
:
1718 msg
->wParam
= VK_CONTROL
;
1720 case VK_LMENU
: case VK_RMENU
:
1721 msg
->wParam
= VK_MENU
;
1725 /* FIXME: is this really the right place for this hook? */
1726 event
.message
= msg
->message
;
1727 event
.hwnd
= msg
->hwnd
;
1728 event
.time
= msg
->time
;
1729 event
.paramL
= (msg
->wParam
& 0xFF) | (HIWORD(msg
->lParam
) << 8);
1730 event
.paramH
= msg
->lParam
& 0x7FFF;
1731 if (HIWORD(msg
->lParam
) & 0x0100) event
.paramH
|= 0x8000; /* special_key - bit */
1732 HOOK_CallHooks( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
, TRUE
);
1734 /* check message filters */
1735 if (msg
->message
< first
|| msg
->message
> last
) return FALSE
;
1736 if (!check_hwnd_filter( msg
, hwnd_filter
)) return FALSE
;
1740 if((msg
->message
== WM_KEYDOWN
) &&
1741 (msg
->hwnd
!= GetDesktopWindow()))
1743 /* Handle F1 key by sending out WM_HELP message */
1744 if (msg
->wParam
== VK_F1
)
1746 PostMessageW( msg
->hwnd
, WM_KEYF1
, 0, 0 );
1748 else if(msg
->wParam
>= VK_BROWSER_BACK
&&
1749 msg
->wParam
<= VK_LAUNCH_APP2
)
1751 /* FIXME: Process keystate */
1752 SendMessageW(msg
->hwnd
, WM_APPCOMMAND
, (WPARAM
)msg
->hwnd
, MAKELPARAM(0, (FAPPCOMMAND_KEY
| (msg
->wParam
- VK_BROWSER_BACK
+ 1))));
1755 else if (msg
->message
== WM_KEYUP
)
1757 /* Handle VK_APPS key by posting a WM_CONTEXTMENU message */
1758 if (msg
->wParam
== VK_APPS
&& !MENU_IsMenuActive())
1759 PostMessageW(msg
->hwnd
, WM_CONTEXTMENU
, (WPARAM
)msg
->hwnd
, (LPARAM
)-1);
1763 if (HOOK_CallHooks( WH_KEYBOARD
, remove
? HC_ACTION
: HC_NOREMOVE
,
1764 LOWORD(msg
->wParam
), msg
->lParam
, TRUE
))
1766 /* skip this message */
1767 HOOK_CallHooks( WH_CBT
, HCBT_KEYSKIPPED
, LOWORD(msg
->wParam
), msg
->lParam
, TRUE
);
1768 accept_hardware_message( hw_id
, TRUE
, 0 );
1771 accept_hardware_message( hw_id
, remove
, 0 );
1773 if ( msg
->message
== WM_KEYDOWN
|| msg
->message
== WM_KEYUP
)
1774 if ( ImmProcessKey(msg
->hwnd
, GetKeyboardLayout(0), msg
->wParam
, msg
->lParam
, 0) )
1775 msg
->wParam
= VK_PROCESSKEY
;
1781 /***********************************************************************
1782 * process_mouse_message
1784 * returns TRUE if the contents of 'msg' should be passed to the application
1786 static BOOL
process_mouse_message( MSG
*msg
, UINT hw_id
, ULONG_PTR extra_info
, HWND hwnd_filter
,
1787 UINT first
, UINT last
, BOOL remove
)
1796 MOUSEHOOKSTRUCT hook
;
1799 /* find the window to dispatch this mouse message to */
1801 GetGUIThreadInfo( GetCurrentThreadId(), &info
);
1802 if (info
.hwndCapture
)
1805 msg
->hwnd
= info
.hwndCapture
;
1809 msg
->hwnd
= WINPOS_WindowFromPoint( msg
->hwnd
, msg
->pt
, &hittest
);
1812 if (!msg
->hwnd
|| !WIN_IsCurrentThread( msg
->hwnd
))
1814 accept_hardware_message( hw_id
, TRUE
, msg
->hwnd
);
1818 /* FIXME: is this really the right place for this hook? */
1819 event
.message
= msg
->message
;
1820 event
.time
= msg
->time
;
1821 event
.hwnd
= msg
->hwnd
;
1822 event
.paramL
= msg
->pt
.x
;
1823 event
.paramH
= msg
->pt
.y
;
1824 HOOK_CallHooks( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
, TRUE
);
1826 if (!check_hwnd_filter( msg
, hwnd_filter
)) return FALSE
;
1829 message
= msg
->message
;
1830 /* Note: windows has no concept of a non-client wheel message */
1831 if (message
!= WM_MOUSEWHEEL
)
1833 if (hittest
!= HTCLIENT
)
1835 message
+= WM_NCMOUSEMOVE
- WM_MOUSEMOVE
;
1836 msg
->wParam
= hittest
;
1840 /* coordinates don't get translated while tracking a menu */
1841 /* FIXME: should differentiate popups and top-level menus */
1842 if (!(info
.flags
& GUI_INMENUMODE
))
1843 ScreenToClient( msg
->hwnd
, &pt
);
1846 msg
->lParam
= MAKELONG( pt
.x
, pt
.y
);
1848 /* translate double clicks */
1850 if ((msg
->message
== WM_LBUTTONDOWN
) ||
1851 (msg
->message
== WM_RBUTTONDOWN
) ||
1852 (msg
->message
== WM_MBUTTONDOWN
) ||
1853 (msg
->message
== WM_XBUTTONDOWN
))
1855 BOOL update
= remove
;
1857 /* translate double clicks -
1858 * note that ...MOUSEMOVEs can slip in between
1859 * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
1861 if ((info
.flags
& (GUI_INMENUMODE
|GUI_INMOVESIZE
)) ||
1862 hittest
!= HTCLIENT
||
1863 (GetClassLongA( msg
->hwnd
, GCL_STYLE
) & CS_DBLCLKS
))
1865 if ((msg
->message
== clk_msg
.message
) &&
1866 (msg
->hwnd
== clk_msg
.hwnd
) &&
1867 (msg
->wParam
== clk_msg
.wParam
) &&
1868 (msg
->time
- clk_msg
.time
< GetDoubleClickTime()) &&
1869 (abs(msg
->pt
.x
- clk_msg
.pt
.x
) < GetSystemMetrics(SM_CXDOUBLECLK
)/2) &&
1870 (abs(msg
->pt
.y
- clk_msg
.pt
.y
) < GetSystemMetrics(SM_CYDOUBLECLK
)/2))
1872 message
+= (WM_LBUTTONDBLCLK
- WM_LBUTTONDOWN
);
1875 clk_msg
.message
= 0; /* clear the double click conditions */
1880 if (message
< first
|| message
> last
) return FALSE
;
1881 /* update static double click conditions */
1882 if (update
) clk_msg
= *msg
;
1886 if (message
< first
|| message
> last
) return FALSE
;
1889 /* message is accepted now (but may still get dropped) */
1892 hook
.hwnd
= msg
->hwnd
;
1893 hook
.wHitTestCode
= hittest
;
1894 hook
.dwExtraInfo
= extra_info
;
1895 if (HOOK_CallHooks( WH_MOUSE
, remove
? HC_ACTION
: HC_NOREMOVE
,
1896 message
, (LPARAM
)&hook
, TRUE
))
1899 hook
.hwnd
= msg
->hwnd
;
1900 hook
.wHitTestCode
= hittest
;
1901 hook
.dwExtraInfo
= extra_info
;
1902 HOOK_CallHooks( WH_CBT
, HCBT_CLICKSKIPPED
, message
, (LPARAM
)&hook
, TRUE
);
1903 accept_hardware_message( hw_id
, TRUE
, 0 );
1907 if ((hittest
== HTERROR
) || (hittest
== HTNOWHERE
))
1909 SendMessageW( msg
->hwnd
, WM_SETCURSOR
, (WPARAM
)msg
->hwnd
,
1910 MAKELONG( hittest
, msg
->message
));
1911 accept_hardware_message( hw_id
, TRUE
, 0 );
1915 accept_hardware_message( hw_id
, remove
, 0 );
1917 if (!remove
|| info
.hwndCapture
)
1919 msg
->message
= message
;
1925 if ((msg
->message
== WM_LBUTTONDOWN
) ||
1926 (msg
->message
== WM_RBUTTONDOWN
) ||
1927 (msg
->message
== WM_MBUTTONDOWN
) ||
1928 (msg
->message
== WM_XBUTTONDOWN
))
1930 /* Send the WM_PARENTNOTIFY,
1931 * note that even for double/nonclient clicks
1932 * notification message is still WM_L/M/RBUTTONDOWN.
1934 send_parent_notify( msg
->hwnd
, msg
->message
, 0, msg
->pt
);
1936 /* Activate the window if needed */
1938 if (msg
->hwnd
!= info
.hwndActive
)
1940 HWND hwndTop
= msg
->hwnd
;
1943 if ((GetWindowLongW( hwndTop
, GWL_STYLE
) & (WS_POPUP
|WS_CHILD
)) != WS_CHILD
) break;
1944 hwndTop
= GetParent( hwndTop
);
1947 if (hwndTop
&& hwndTop
!= GetDesktopWindow())
1949 LONG ret
= SendMessageW( msg
->hwnd
, WM_MOUSEACTIVATE
, (WPARAM
)hwndTop
,
1950 MAKELONG( hittest
, msg
->message
) );
1953 case MA_NOACTIVATEANDEAT
:
1958 case MA_ACTIVATEANDEAT
:
1963 if (!FOCUS_MouseActivate( hwndTop
)) eatMsg
= TRUE
;
1966 WARN( "unknown WM_MOUSEACTIVATE code %d\n", ret
);
1973 /* send the WM_SETCURSOR message */
1975 /* Windows sends the normal mouse message as the message parameter
1976 in the WM_SETCURSOR message even if it's non-client mouse message */
1977 SendMessageW( msg
->hwnd
, WM_SETCURSOR
, (WPARAM
)msg
->hwnd
, MAKELONG( hittest
, msg
->message
));
1979 msg
->message
= message
;
1984 /***********************************************************************
1985 * process_hardware_message
1987 * Process a hardware message; return TRUE if message should be passed on to the app
1989 static BOOL
process_hardware_message( MSG
*msg
, UINT hw_id
, ULONG_PTR extra_info
, HWND hwnd_filter
,
1990 UINT first
, UINT last
, BOOL remove
)
1992 if (is_keyboard_message( msg
->message
))
1993 return process_keyboard_message( msg
, hw_id
, hwnd_filter
, first
, last
, remove
);
1995 if (is_mouse_message( msg
->message
))
1996 return process_mouse_message( msg
, hw_id
, extra_info
, hwnd_filter
, first
, last
, remove
);
1998 ERR( "unknown message type %x\n", msg
->message
);
2003 /***********************************************************************
2004 * call_sendmsg_callback
2006 * Call the callback function of SendMessageCallback.
2008 static inline void call_sendmsg_callback( SENDASYNCPROC callback
, HWND hwnd
, UINT msg
,
2009 ULONG_PTR data
, LRESULT result
)
2011 if (!callback
) return;
2013 if (TRACE_ON(relay
))
2014 DPRINTF( "%04x:Call message callback %p (hwnd=%p,msg=%s,data=%08lx,result=%08lx)\n",
2015 GetCurrentThreadId(), callback
, hwnd
, SPY_GetMsgName( msg
, hwnd
),
2017 callback( hwnd
, msg
, data
, result
);
2018 if (TRACE_ON(relay
))
2019 DPRINTF( "%04x:Ret message callback %p (hwnd=%p,msg=%s,data=%08lx,result=%08lx)\n",
2020 GetCurrentThreadId(), callback
, hwnd
, SPY_GetMsgName( msg
, hwnd
),
2025 /***********************************************************************
2028 * Peek for a message matching the given parameters. Return FALSE if none available.
2029 * All pending sent messages are processed before returning.
2031 static BOOL
peek_message( MSG
*msg
, HWND hwnd
, UINT first
, UINT last
, UINT flags
)
2034 ULONG_PTR extra_info
= 0;
2035 struct user_thread_info
*thread_info
= get_user_thread_info();
2036 struct received_message_info info
, *old_info
;
2037 unsigned int wake_mask
, changed_mask
= HIWORD(flags
);
2038 unsigned int hw_id
= 0; /* id of previous hardware message */
2040 if (!first
&& !last
) last
= ~0;
2041 if (!changed_mask
) changed_mask
= QS_ALLINPUT
;
2042 wake_mask
= changed_mask
& (QS_SENDMESSAGE
| QS_SMRESULT
);
2047 void *buffer
= NULL
;
2048 size_t size
= 0, buffer_size
= 0;
2050 do /* loop while buffer is too small */
2052 if (buffer_size
&& !(buffer
= HeapAlloc( GetProcessHeap(), 0, buffer_size
)))
2054 SERVER_START_REQ( get_message
)
2057 req
->get_win
= hwnd
;
2058 req
->get_first
= first
;
2059 req
->get_last
= last
;
2061 req
->wake_mask
= wake_mask
;
2062 req
->changed_mask
= changed_mask
;
2063 if (buffer_size
) wine_server_set_reply( req
, buffer
, buffer_size
);
2064 if (!(res
= wine_server_call( req
)))
2066 size
= wine_server_reply_size( reply
);
2067 info
.type
= reply
->type
;
2068 info
.msg
.hwnd
= reply
->win
;
2069 info
.msg
.message
= reply
->msg
;
2070 info
.msg
.wParam
= reply
->wparam
;
2071 info
.msg
.lParam
= reply
->lparam
;
2072 info
.msg
.time
= reply
->time
;
2073 info
.msg
.pt
.x
= reply
->x
;
2074 info
.msg
.pt
.y
= reply
->y
;
2075 hw_id
= reply
->hw_id
;
2076 extra_info
= reply
->info
;
2077 thread_info
->active_hooks
= reply
->active_hooks
;
2081 HeapFree( GetProcessHeap(), 0, buffer
);
2082 buffer_size
= reply
->total
;
2086 } while (res
== STATUS_BUFFER_OVERFLOW
);
2088 if (res
) return FALSE
;
2090 TRACE( "got type %d msg %x (%s) hwnd %p wp %lx lp %lx\n",
2091 info
.type
, info
.msg
.message
,
2092 (info
.type
== MSG_WINEVENT
) ? "MSG_WINEVENT" : SPY_GetMsgName(info
.msg
.message
, info
.msg
.hwnd
),
2093 info
.msg
.hwnd
, info
.msg
.wParam
, info
.msg
.lParam
);
2099 info
.flags
= ISMEX_SEND
;
2102 info
.flags
= ISMEX_NOTIFY
;
2105 info
.flags
= ISMEX_CALLBACK
;
2107 case MSG_CALLBACK_RESULT
:
2108 if (size
>= sizeof(struct callback_msg_data
))
2110 const struct callback_msg_data
*data
= (const struct callback_msg_data
*)buffer
;
2111 call_sendmsg_callback( data
->callback
, info
.msg
.hwnd
,
2112 info
.msg
.message
, data
->data
, data
->result
);
2116 if (size
>= sizeof(struct winevent_msg_data
))
2118 WINEVENTPROC hook_proc
;
2119 const struct winevent_msg_data
*data
= (const struct winevent_msg_data
*)buffer
;
2121 hook_proc
= data
->hook_proc
;
2122 size
-= sizeof(*data
);
2125 WCHAR module
[MAX_PATH
];
2127 size
= min( size
, (MAX_PATH
- 1) * sizeof(WCHAR
) );
2128 memcpy( module
, buffer
, size
);
2129 module
[size
/ sizeof(WCHAR
)] = 0;
2130 if (!(hook_proc
= get_hook_proc( hook_proc
, module
)))
2132 ERR( "invalid winevent hook module name %s\n", debugstr_w(module
) );
2137 if (TRACE_ON(relay
))
2138 DPRINTF( "%04x:Call winevent proc %p (hook=%p,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n",
2139 GetCurrentThreadId(), hook_proc
,
2140 data
->hook
, info
.msg
.message
, info
.msg
.hwnd
, info
.msg
.wParam
,
2141 info
.msg
.lParam
, data
->tid
, info
.msg
.time
);
2143 hook_proc( data
->hook
, info
.msg
.message
, info
.msg
.hwnd
, info
.msg
.wParam
,
2144 info
.msg
.lParam
, data
->tid
, info
.msg
.time
);
2146 if (TRACE_ON(relay
))
2147 DPRINTF( "%04x:Ret winevent proc %p (hook=%p,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n",
2148 GetCurrentThreadId(), hook_proc
,
2149 data
->hook
, info
.msg
.message
, info
.msg
.hwnd
, info
.msg
.wParam
,
2150 info
.msg
.lParam
, data
->tid
, info
.msg
.time
);
2153 case MSG_OTHER_PROCESS
:
2154 info
.flags
= ISMEX_SEND
;
2155 if (!unpack_message( info
.msg
.hwnd
, info
.msg
.message
, &info
.msg
.wParam
,
2156 &info
.msg
.lParam
, &buffer
, size
))
2159 reply_message( &info
, 0, TRUE
);
2164 if (!process_hardware_message( &info
.msg
, hw_id
, extra_info
,
2165 hwnd
, first
, last
, flags
& PM_REMOVE
))
2167 TRACE("dropping msg %x\n", info
.msg
.message
);
2168 goto next
; /* ignore it */
2170 thread_info
->GetMessagePosVal
= MAKELONG( info
.msg
.pt
.x
, info
.msg
.pt
.y
);
2173 thread_info
->GetMessageExtraInfoVal
= extra_info
;
2174 if (info
.msg
.message
>= WM_DDE_FIRST
&& info
.msg
.message
<= WM_DDE_LAST
)
2176 if (!unpack_dde_message( info
.msg
.hwnd
, info
.msg
.message
, &info
.msg
.wParam
,
2177 &info
.msg
.lParam
, &buffer
, size
))
2178 goto next
; /* ignore it */
2181 HeapFree( GetProcessHeap(), 0, buffer
);
2185 /* if we get here, we have a sent message; call the window procedure */
2186 old_info
= thread_info
->receive_info
;
2187 thread_info
->receive_info
= &info
;
2188 result
= call_window_proc( info
.msg
.hwnd
, info
.msg
.message
, info
.msg
.wParam
,
2189 info
.msg
.lParam
, (info
.type
!= MSG_ASCII
), FALSE
,
2190 WMCHAR_MAP_RECVMESSAGE
);
2191 reply_message( &info
, result
, TRUE
);
2192 thread_info
->receive_info
= old_info
;
2194 /* if some PM_QS* flags were specified, only handle sent messages from now on */
2195 if (HIWORD(flags
)) flags
= PM_QS_SENDMESSAGE
| LOWORD(flags
);
2197 HeapFree( GetProcessHeap(), 0, buffer
);
2202 /***********************************************************************
2203 * process_sent_messages
2205 * Process all pending sent messages.
2207 static inline void process_sent_messages(void)
2210 peek_message( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
2214 /***********************************************************************
2215 * get_server_queue_handle
2217 * Get a handle to the server message queue for the current thread.
2219 static HANDLE
get_server_queue_handle(void)
2221 struct user_thread_info
*thread_info
= get_user_thread_info();
2224 if (!(ret
= thread_info
->server_queue
))
2226 SERVER_START_REQ( get_msg_queue
)
2228 wine_server_call( req
);
2229 ret
= reply
->handle
;
2232 thread_info
->server_queue
= ret
;
2233 if (!ret
) ERR( "Cannot get server thread queue\n" );
2239 /***********************************************************************
2240 * wait_message_reply
2242 * Wait until a sent message gets replied to.
2244 static void wait_message_reply( UINT flags
)
2246 HANDLE server_queue
= get_server_queue_handle();
2250 unsigned int wake_bits
= 0;
2253 SERVER_START_REQ( set_queue_mask
)
2255 req
->wake_mask
= QS_SMRESULT
| ((flags
& SMTO_BLOCK
) ? 0 : QS_SENDMESSAGE
);
2256 req
->changed_mask
= req
->wake_mask
;
2258 if (!wine_server_call( req
))
2259 wake_bits
= reply
->wake_bits
;
2263 if (wake_bits
& QS_SMRESULT
) return; /* got a result */
2264 if (wake_bits
& QS_SENDMESSAGE
)
2266 /* Process the sent message immediately */
2267 process_sent_messages();
2271 /* now wait for it */
2273 ReleaseThunkLock( &dwlc
);
2274 res
= USER_Driver
->pMsgWaitForMultipleObjectsEx( 1, &server_queue
,
2275 INFINITE
, QS_SENDMESSAGE
, 0 );
2276 if (dwlc
) RestoreThunkLock( dwlc
);
2280 /***********************************************************************
2281 * put_message_in_queue
2283 * Put a sent message into the destination queue.
2284 * For inter-process message, reply_size is set to expected size of reply data.
2286 static BOOL
put_message_in_queue( const struct send_message_info
*info
, size_t *reply_size
)
2288 struct packed_message data
;
2289 message_data_t msg_data
;
2292 timeout_t timeout
= TIMEOUT_INFINITE
;
2294 /* Check for INFINITE timeout for compatibility with Win9x,
2295 * although Windows >= NT does not do so
2297 if (info
->type
!= MSG_NOTIFY
&&
2298 info
->type
!= MSG_CALLBACK
&&
2299 info
->type
!= MSG_POSTED
&&
2301 info
->timeout
!= INFINITE
)
2303 /* timeout is signed despite the prototype */
2304 timeout
= (timeout_t
)max( 0, (int)info
->timeout
) * -10000;
2308 if (info
->type
== MSG_OTHER_PROCESS
)
2310 *reply_size
= pack_message( info
->hwnd
, info
->msg
, info
->wparam
, info
->lparam
, &data
);
2311 if (data
.count
== -1)
2313 WARN( "cannot pack message %x\n", info
->msg
);
2317 else if (info
->type
== MSG_CALLBACK
)
2319 msg_data
.callback
.callback
= info
->callback
;
2320 msg_data
.callback
.data
= info
->data
;
2321 msg_data
.callback
.result
= 0;
2322 data
.data
[0] = &msg_data
;
2323 data
.size
[0] = sizeof(msg_data
.callback
);
2326 else if (info
->type
== MSG_POSTED
&& info
->msg
>= WM_DDE_FIRST
&& info
->msg
<= WM_DDE_LAST
)
2328 return post_dde_message( &data
, info
);
2331 SERVER_START_REQ( send_message
)
2333 req
->id
= info
->dest_tid
;
2334 req
->type
= info
->type
;
2336 req
->win
= info
->hwnd
;
2337 req
->msg
= info
->msg
;
2338 req
->wparam
= info
->wparam
;
2339 req
->lparam
= info
->lparam
;
2340 req
->timeout
= timeout
;
2342 if (info
->flags
& SMTO_ABORTIFHUNG
) req
->flags
|= SEND_MSG_ABORT_IF_HUNG
;
2343 for (i
= 0; i
< data
.count
; i
++) wine_server_add_data( req
, data
.data
[i
], data
.size
[i
] );
2344 if ((res
= wine_server_call( req
)))
2346 if (res
== STATUS_INVALID_PARAMETER
)
2347 /* FIXME: find a STATUS_ value for this one */
2348 SetLastError( ERROR_INVALID_THREAD_ID
);
2350 SetLastError( RtlNtStatusToDosError(res
) );
2358 /***********************************************************************
2361 * Retrieve a message reply from the server.
2363 static LRESULT
retrieve_reply( const struct send_message_info
*info
,
2364 size_t reply_size
, LRESULT
*result
)
2367 void *reply_data
= NULL
;
2371 if (!(reply_data
= HeapAlloc( GetProcessHeap(), 0, reply_size
)))
2373 WARN( "no memory for reply, will be truncated\n" );
2377 SERVER_START_REQ( get_message_reply
)
2380 if (reply_size
) wine_server_set_reply( req
, reply_data
, reply_size
);
2381 if (!(status
= wine_server_call( req
))) *result
= reply
->result
;
2382 reply_size
= wine_server_reply_size( reply
);
2385 if (!status
&& reply_size
)
2386 unpack_reply( info
->hwnd
, info
->msg
, info
->wparam
, info
->lparam
, reply_data
, reply_size
);
2388 HeapFree( GetProcessHeap(), 0, reply_data
);
2390 TRACE( "hwnd %p msg %x (%s) wp %lx lp %lx got reply %lx (err=%d)\n",
2391 info
->hwnd
, info
->msg
, SPY_GetMsgName(info
->msg
, info
->hwnd
), info
->wparam
,
2392 info
->lparam
, *result
, status
);
2394 /* MSDN states that last error is 0 on timeout, but at least NT4 returns ERROR_TIMEOUT */
2395 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
2400 /***********************************************************************
2401 * send_inter_thread_message
2403 static LRESULT
send_inter_thread_message( const struct send_message_info
*info
, LRESULT
*res_ptr
)
2405 size_t reply_size
= 0;
2407 TRACE( "hwnd %p msg %x (%s) wp %lx lp %lx\n",
2408 info
->hwnd
, info
->msg
, SPY_GetMsgName(info
->msg
, info
->hwnd
), info
->wparam
, info
->lparam
);
2410 USER_CheckNotLock();
2412 if (!put_message_in_queue( info
, &reply_size
)) return 0;
2414 /* there's no reply to wait for on notify/callback messages */
2415 if (info
->type
== MSG_NOTIFY
|| info
->type
== MSG_CALLBACK
) return 1;
2417 wait_message_reply( info
->flags
);
2418 return retrieve_reply( info
, reply_size
, res_ptr
);
2422 /***********************************************************************
2423 * send_inter_thread_callback
2425 static LRESULT
send_inter_thread_callback( HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
,
2426 LRESULT
*result
, void *arg
)
2428 struct send_message_info
*info
= arg
;
2433 return send_inter_thread_message( info
, result
);
2437 /***********************************************************************
2440 * Backend implementation of the various SendMessage functions.
2442 static BOOL
send_message( struct send_message_info
*info
, DWORD_PTR
*res_ptr
, BOOL unicode
)
2448 if (is_broadcast(info
->hwnd
))
2450 EnumWindows( broadcast_message_callback
, (LPARAM
)info
);
2451 if (res_ptr
) *res_ptr
= 1;
2455 if (!(info
->dest_tid
= GetWindowThreadProcessId( info
->hwnd
, &dest_pid
))) return FALSE
;
2457 if (USER_IsExitingThread( info
->dest_tid
)) return FALSE
;
2459 SPY_EnterMessage( SPY_SENDMESSAGE
, info
->hwnd
, info
->msg
, info
->wparam
, info
->lparam
);
2461 if (info
->dest_tid
== GetCurrentThreadId())
2463 result
= call_window_proc( info
->hwnd
, info
->msg
, info
->wparam
, info
->lparam
,
2464 unicode
, TRUE
, info
->wm_char
);
2465 if (info
->type
== MSG_CALLBACK
)
2466 call_sendmsg_callback( info
->callback
, info
->hwnd
, info
->msg
, info
->data
, result
);
2471 if (dest_pid
!= GetCurrentProcessId() && (info
->type
== MSG_ASCII
|| info
->type
== MSG_UNICODE
))
2472 info
->type
= MSG_OTHER_PROCESS
;
2474 /* MSG_ASCII can be sent unconverted except for WM_CHAR; everything else needs to be Unicode */
2475 if (!unicode
&& is_unicode_message( info
->msg
) &&
2476 (info
->type
!= MSG_ASCII
|| info
->msg
== WM_CHAR
))
2477 ret
= WINPROC_CallProcAtoW( send_inter_thread_callback
, info
->hwnd
, info
->msg
,
2478 info
->wparam
, info
->lparam
, &result
, info
, info
->wm_char
);
2480 ret
= send_inter_thread_message( info
, &result
);
2483 SPY_ExitMessage( SPY_RESULT_OK
, info
->hwnd
, info
->msg
, result
, info
->wparam
, info
->lparam
);
2484 if (ret
&& res_ptr
) *res_ptr
= result
;
2489 /***********************************************************************
2490 * MSG_SendInternalMessageTimeout
2492 * Same as SendMessageTimeoutW but sends the message to a specific thread
2493 * without requiring a window handle. Only works for internal Wine messages.
2495 LRESULT
MSG_SendInternalMessageTimeout( DWORD dest_pid
, DWORD dest_tid
,
2496 UINT msg
, WPARAM wparam
, LPARAM lparam
,
2497 UINT flags
, UINT timeout
, PDWORD_PTR res_ptr
)
2499 struct send_message_info info
;
2500 LRESULT ret
, result
;
2502 assert( msg
& 0x80000000 ); /* must be an internal Wine message */
2504 info
.type
= MSG_UNICODE
;
2505 info
.dest_tid
= dest_tid
;
2508 info
.wparam
= wparam
;
2509 info
.lparam
= lparam
;
2511 info
.timeout
= timeout
;
2513 if (USER_IsExitingThread( dest_tid
)) return 0;
2515 if (dest_tid
== GetCurrentThreadId())
2517 result
= handle_internal_message( 0, msg
, wparam
, lparam
);
2522 if (dest_pid
!= GetCurrentProcessId()) info
.type
= MSG_OTHER_PROCESS
;
2523 ret
= send_inter_thread_message( &info
, &result
);
2525 if (ret
&& res_ptr
) *res_ptr
= result
;
2530 /***********************************************************************
2531 * SendMessageTimeoutW (USER32.@)
2533 LRESULT WINAPI
SendMessageTimeoutW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
2534 UINT flags
, UINT timeout
, PDWORD_PTR res_ptr
)
2536 struct send_message_info info
;
2538 info
.type
= MSG_UNICODE
;
2541 info
.wparam
= wparam
;
2542 info
.lparam
= lparam
;
2544 info
.timeout
= timeout
;
2546 return send_message( &info
, res_ptr
, TRUE
);
2549 /***********************************************************************
2550 * SendMessageTimeoutA (USER32.@)
2552 LRESULT WINAPI
SendMessageTimeoutA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
2553 UINT flags
, UINT timeout
, PDWORD_PTR res_ptr
)
2555 struct send_message_info info
;
2557 info
.type
= MSG_ASCII
;
2560 info
.wparam
= wparam
;
2561 info
.lparam
= lparam
;
2563 info
.timeout
= timeout
;
2564 info
.wm_char
= WMCHAR_MAP_SENDMESSAGETIMEOUT
;
2566 return send_message( &info
, res_ptr
, FALSE
);
2570 /***********************************************************************
2571 * SendMessageW (USER32.@)
2573 LRESULT WINAPI
SendMessageW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2576 struct send_message_info info
;
2578 info
.type
= MSG_UNICODE
;
2581 info
.wparam
= wparam
;
2582 info
.lparam
= lparam
;
2583 info
.flags
= SMTO_NORMAL
;
2586 send_message( &info
, &res
, TRUE
);
2591 /***********************************************************************
2592 * SendMessageA (USER32.@)
2594 LRESULT WINAPI
SendMessageA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2597 struct send_message_info info
;
2599 info
.type
= MSG_ASCII
;
2602 info
.wparam
= wparam
;
2603 info
.lparam
= lparam
;
2604 info
.flags
= SMTO_NORMAL
;
2606 info
.wm_char
= WMCHAR_MAP_SENDMESSAGE
;
2608 send_message( &info
, &res
, FALSE
);
2613 /***********************************************************************
2614 * SendNotifyMessageA (USER32.@)
2616 BOOL WINAPI
SendNotifyMessageA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2618 struct send_message_info info
;
2620 if (is_pointer_message(msg
))
2622 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2626 info
.type
= MSG_NOTIFY
;
2629 info
.wparam
= wparam
;
2630 info
.lparam
= lparam
;
2632 info
.wm_char
= WMCHAR_MAP_SENDMESSAGETIMEOUT
;
2634 return send_message( &info
, NULL
, FALSE
);
2638 /***********************************************************************
2639 * SendNotifyMessageW (USER32.@)
2641 BOOL WINAPI
SendNotifyMessageW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2643 struct send_message_info info
;
2645 if (is_pointer_message(msg
))
2647 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2651 info
.type
= MSG_NOTIFY
;
2654 info
.wparam
= wparam
;
2655 info
.lparam
= lparam
;
2658 return send_message( &info
, NULL
, TRUE
);
2662 /***********************************************************************
2663 * SendMessageCallbackA (USER32.@)
2665 BOOL WINAPI
SendMessageCallbackA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
2666 SENDASYNCPROC callback
, ULONG_PTR data
)
2668 struct send_message_info info
;
2670 if (is_pointer_message(msg
))
2672 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2676 info
.type
= MSG_CALLBACK
;
2679 info
.wparam
= wparam
;
2680 info
.lparam
= lparam
;
2681 info
.callback
= callback
;
2684 info
.wm_char
= WMCHAR_MAP_SENDMESSAGETIMEOUT
;
2686 return send_message( &info
, NULL
, FALSE
);
2690 /***********************************************************************
2691 * SendMessageCallbackW (USER32.@)
2693 BOOL WINAPI
SendMessageCallbackW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
,
2694 SENDASYNCPROC callback
, ULONG_PTR data
)
2696 struct send_message_info info
;
2698 if (is_pointer_message(msg
))
2700 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2704 info
.type
= MSG_CALLBACK
;
2707 info
.wparam
= wparam
;
2708 info
.lparam
= lparam
;
2709 info
.callback
= callback
;
2713 return send_message( &info
, NULL
, TRUE
);
2717 /***********************************************************************
2718 * ReplyMessage (USER32.@)
2720 BOOL WINAPI
ReplyMessage( LRESULT result
)
2722 struct received_message_info
*info
= get_user_thread_info()->receive_info
;
2724 if (!info
) return FALSE
;
2725 reply_message( info
, result
, FALSE
);
2730 /***********************************************************************
2731 * InSendMessage (USER32.@)
2733 BOOL WINAPI
InSendMessage(void)
2735 return (InSendMessageEx(NULL
) & (ISMEX_SEND
|ISMEX_REPLIED
)) == ISMEX_SEND
;
2739 /***********************************************************************
2740 * InSendMessageEx (USER32.@)
2742 DWORD WINAPI
InSendMessageEx( LPVOID reserved
)
2744 struct received_message_info
*info
= get_user_thread_info()->receive_info
;
2746 if (info
) return info
->flags
;
2747 return ISMEX_NOSEND
;
2751 /***********************************************************************
2752 * PostMessageA (USER32.@)
2754 BOOL WINAPI
PostMessageA( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2756 if (!map_wparam_AtoW( msg
, &wparam
, WMCHAR_MAP_POSTMESSAGE
)) return TRUE
;
2757 return PostMessageW( hwnd
, msg
, wparam
, lparam
);
2761 /***********************************************************************
2762 * PostMessageW (USER32.@)
2764 BOOL WINAPI
PostMessageW( HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2766 struct send_message_info info
;
2768 if (is_pointer_message( msg
))
2770 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2774 TRACE( "hwnd %p msg %x (%s) wp %lx lp %lx\n",
2775 hwnd
, msg
, SPY_GetMsgName(msg
, hwnd
), wparam
, lparam
);
2777 info
.type
= MSG_POSTED
;
2780 info
.wparam
= wparam
;
2781 info
.lparam
= lparam
;
2784 if (is_broadcast(hwnd
))
2786 EnumWindows( broadcast_message_callback
, (LPARAM
)&info
);
2790 if (!hwnd
) return PostThreadMessageW( GetCurrentThreadId(), msg
, wparam
, lparam
);
2792 if (!(info
.dest_tid
= GetWindowThreadProcessId( hwnd
, NULL
))) return FALSE
;
2794 if (USER_IsExitingThread( info
.dest_tid
)) return TRUE
;
2796 return put_message_in_queue( &info
, NULL
);
2800 /**********************************************************************
2801 * PostThreadMessageA (USER32.@)
2803 BOOL WINAPI
PostThreadMessageA( DWORD thread
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2805 if (!map_wparam_AtoW( msg
, &wparam
, WMCHAR_MAP_POSTMESSAGE
)) return TRUE
;
2806 return PostThreadMessageW( thread
, msg
, wparam
, lparam
);
2810 /**********************************************************************
2811 * PostThreadMessageW (USER32.@)
2813 BOOL WINAPI
PostThreadMessageW( DWORD thread
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2815 struct send_message_info info
;
2817 if (is_pointer_message( msg
))
2819 SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
2822 if (USER_IsExitingThread( thread
)) return TRUE
;
2824 info
.type
= MSG_POSTED
;
2825 info
.dest_tid
= thread
;
2828 info
.wparam
= wparam
;
2829 info
.lparam
= lparam
;
2831 return put_message_in_queue( &info
, NULL
);
2835 /***********************************************************************
2836 * PostQuitMessage (USER32.@)
2838 * Posts a quit message to the current thread's message queue.
2841 * exit_code [I] Exit code to return from message loop.
2847 * This function is not the same as calling:
2848 *|PostThreadMessage(GetCurrentThreadId(), WM_QUIT, exit_code, 0);
2849 * It instead sets a flag in the message queue that signals it to generate
2850 * a WM_QUIT message when there are no other pending sent or posted messages
2853 void WINAPI
PostQuitMessage( INT exit_code
)
2855 SERVER_START_REQ( post_quit_message
)
2857 req
->exit_code
= exit_code
;
2858 wine_server_call( req
);
2864 /***********************************************************************
2865 * PeekMessageW (USER32.@)
2867 BOOL WINAPI
PeekMessageW( MSG
*msg_out
, HWND hwnd
, UINT first
, UINT last
, UINT flags
)
2869 struct user_thread_info
*thread_info
= get_user_thread_info();
2872 USER_CheckNotLock();
2874 /* check for graphics events */
2875 USER_Driver
->pMsgWaitForMultipleObjectsEx( 0, NULL
, 0, QS_ALLINPUT
, 0 );
2877 hwnd
= WIN_GetFullHandle( hwnd
);
2881 if (!peek_message( &msg
, hwnd
, first
, last
, flags
))
2883 if (!(flags
& PM_NOYIELD
))
2886 ReleaseThunkLock(&count
);
2888 if (count
) RestoreThunkLock(count
);
2892 if (msg
.message
& 0x80000000)
2894 if (!(flags
& PM_REMOVE
))
2896 /* Have to remove the message explicitly.
2897 Do this before handling it, because the message handler may
2898 call PeekMessage again */
2899 peek_message( &msg
, msg
.hwnd
, msg
.message
, msg
.message
, flags
| PM_REMOVE
);
2901 handle_internal_message( msg
.hwnd
, msg
.message
, msg
.wParam
, msg
.lParam
);
2906 thread_info
->GetMessageTimeVal
= msg
.time
;
2907 msg
.pt
.x
= (short)LOWORD( thread_info
->GetMessagePosVal
);
2908 msg
.pt
.y
= (short)HIWORD( thread_info
->GetMessagePosVal
);
2910 HOOK_CallHooks( WH_GETMESSAGE
, HC_ACTION
, flags
& PM_REMOVE
, (LPARAM
)&msg
, TRUE
);
2912 /* copy back our internal safe copy of message data to msg_out.
2913 * msg_out is a variable from the *program*, so it can't be used
2914 * internally as it can get "corrupted" by our use of SendMessage()
2915 * (back to the program) inside the message handling itself. */
2918 SetLastError( ERROR_NOACCESS
);
2926 /***********************************************************************
2927 * PeekMessageA (USER32.@)
2929 BOOL WINAPI
PeekMessageA( MSG
*msg
, HWND hwnd
, UINT first
, UINT last
, UINT flags
)
2931 if (get_pending_wmchar( msg
, first
, last
, (flags
& PM_REMOVE
) )) return TRUE
;
2932 if (!PeekMessageW( msg
, hwnd
, first
, last
, flags
)) return FALSE
;
2933 map_wparam_WtoA( msg
, (flags
& PM_REMOVE
) );
2938 /***********************************************************************
2939 * GetMessageW (USER32.@)
2941 BOOL WINAPI
GetMessageW( MSG
*msg
, HWND hwnd
, UINT first
, UINT last
)
2943 HANDLE server_queue
= get_server_queue_handle();
2944 int mask
= QS_POSTMESSAGE
| QS_SENDMESSAGE
; /* Always selected */
2948 if ((first
<= WM_KEYLAST
) && (last
>= WM_KEYFIRST
)) mask
|= QS_KEY
;
2949 if ( ((first
<= WM_MOUSELAST
) && (last
>= WM_MOUSEFIRST
)) ||
2950 ((first
<= WM_NCMOUSELAST
) && (last
>= WM_NCMOUSEFIRST
)) ) mask
|= QS_MOUSE
;
2951 if ((first
<= WM_TIMER
) && (last
>= WM_TIMER
)) mask
|= QS_TIMER
;
2952 if ((first
<= WM_SYSTIMER
) && (last
>= WM_SYSTIMER
)) mask
|= QS_TIMER
;
2953 if ((first
<= WM_PAINT
) && (last
>= WM_PAINT
)) mask
|= QS_PAINT
;
2955 else mask
= QS_ALLINPUT
;
2957 while (!PeekMessageW( msg
, hwnd
, first
, last
, PM_REMOVE
| PM_NOYIELD
| (mask
<< 16) ))
2961 ReleaseThunkLock( &dwlc
);
2962 USER_Driver
->pMsgWaitForMultipleObjectsEx( 1, &server_queue
, INFINITE
, mask
, 0 );
2963 if (dwlc
) RestoreThunkLock( dwlc
);
2966 return (msg
->message
!= WM_QUIT
);
2970 /***********************************************************************
2971 * GetMessageA (USER32.@)
2973 BOOL WINAPI
GetMessageA( MSG
*msg
, HWND hwnd
, UINT first
, UINT last
)
2975 if (get_pending_wmchar( msg
, first
, last
, TRUE
)) return TRUE
;
2976 GetMessageW( msg
, hwnd
, first
, last
);
2977 map_wparam_WtoA( msg
, TRUE
);
2978 return (msg
->message
!= WM_QUIT
);
2982 /***********************************************************************
2983 * IsDialogMessageA (USER32.@)
2984 * IsDialogMessage (USER32.@)
2986 BOOL WINAPI
IsDialogMessageA( HWND hwndDlg
, LPMSG pmsg
)
2989 map_wparam_AtoW( msg
.message
, &msg
.wParam
, WMCHAR_MAP_NOMAPPING
);
2990 return IsDialogMessageW( hwndDlg
, &msg
);
2994 /***********************************************************************
2995 * TranslateMessage (USER32.@)
2997 * Implementation of TranslateMessage.
2999 * TranslateMessage translates virtual-key messages into character-messages,
3001 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
3002 * ditto replacing WM_* with WM_SYS*
3003 * This produces WM_CHAR messages only for keys mapped to ASCII characters
3004 * by the keyboard driver.
3006 * If the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, the
3007 * return value is nonzero, regardless of the translation.
3010 BOOL WINAPI
TranslateMessage( const MSG
*msg
)
3016 if (msg
->message
< WM_KEYFIRST
|| msg
->message
> WM_KEYLAST
) return FALSE
;
3017 if (msg
->message
!= WM_KEYDOWN
&& msg
->message
!= WM_SYSKEYDOWN
) return TRUE
;
3019 TRACE_(key
)("Translating key %s (%04lx), scancode %02x\n",
3020 SPY_GetVKeyName(msg
->wParam
), msg
->wParam
, LOBYTE(HIWORD(msg
->lParam
)));
3022 if ( msg
->wParam
== VK_PROCESSKEY
)
3023 return ImmTranslateMessage(msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
3025 GetKeyboardState( state
);
3026 /* FIXME : should handle ToUnicode yielding 2 */
3027 switch (ToUnicode(msg
->wParam
, HIWORD(msg
->lParam
), state
, wp
, 2, 0))
3030 message
= (msg
->message
== WM_KEYDOWN
) ? WM_CHAR
: WM_SYSCHAR
;
3031 TRACE_(key
)("1 -> PostMessageW(%p,%s,%04x,%08lx)\n",
3032 msg
->hwnd
, SPY_GetMsgName(message
, msg
->hwnd
), wp
[0], msg
->lParam
);
3033 PostMessageW( msg
->hwnd
, message
, wp
[0], msg
->lParam
);
3037 message
= (msg
->message
== WM_KEYDOWN
) ? WM_DEADCHAR
: WM_SYSDEADCHAR
;
3038 TRACE_(key
)("-1 -> PostMessageW(%p,%s,%04x,%08lx)\n",
3039 msg
->hwnd
, SPY_GetMsgName(message
, msg
->hwnd
), wp
[0], msg
->lParam
);
3040 PostMessageW( msg
->hwnd
, message
, wp
[0], msg
->lParam
);
3047 /***********************************************************************
3048 * DispatchMessageA (USER32.@)
3050 * See DispatchMessageW.
3052 LRESULT WINAPI
DispatchMessageA( const MSG
* msg
)
3056 /* Process timer messages */
3057 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
3059 if (msg
->lParam
) return CallWindowProcA( (WNDPROC
)msg
->lParam
, msg
->hwnd
,
3060 msg
->message
, msg
->wParam
, GetTickCount() );
3062 if (!msg
->hwnd
) return 0;
3064 SPY_EnterMessage( SPY_DISPATCHMESSAGE
, msg
->hwnd
, msg
->message
,
3065 msg
->wParam
, msg
->lParam
);
3067 if (!WINPROC_call_window( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
,
3068 &retval
, FALSE
, WMCHAR_MAP_DISPATCHMESSAGE
))
3070 if (!IsWindow( msg
->hwnd
)) SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
3071 else SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
3075 SPY_ExitMessage( SPY_RESULT_OK
, msg
->hwnd
, msg
->message
, retval
,
3076 msg
->wParam
, msg
->lParam
);
3078 if (msg
->message
== WM_PAINT
)
3080 /* send a WM_NCPAINT and WM_ERASEBKGND if the non-client area is still invalid */
3081 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
3082 GetUpdateRgn( msg
->hwnd
, hrgn
, TRUE
);
3083 DeleteObject( hrgn
);
3089 /***********************************************************************
3090 * DispatchMessageW (USER32.@) Process a message
3092 * Process the message specified in the structure *_msg_.
3094 * If the lpMsg parameter points to a WM_TIMER message and the
3095 * parameter of the WM_TIMER message is not NULL, the lParam parameter
3096 * points to the function that is called instead of the window
3099 * The message must be valid.
3103 * DispatchMessage() returns the result of the window procedure invoked.
3110 LRESULT WINAPI
DispatchMessageW( const MSG
* msg
)
3114 /* Process timer messages */
3115 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
3117 if (msg
->lParam
) return CallWindowProcW( (WNDPROC
)msg
->lParam
, msg
->hwnd
,
3118 msg
->message
, msg
->wParam
, GetTickCount() );
3120 if (!msg
->hwnd
) return 0;
3122 SPY_EnterMessage( SPY_DISPATCHMESSAGE
, msg
->hwnd
, msg
->message
,
3123 msg
->wParam
, msg
->lParam
);
3125 if (!WINPROC_call_window( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
,
3126 &retval
, TRUE
, WMCHAR_MAP_DISPATCHMESSAGE
))
3128 if (!IsWindow( msg
->hwnd
)) SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
3129 else SetLastError( ERROR_MESSAGE_SYNC_ONLY
);
3133 SPY_ExitMessage( SPY_RESULT_OK
, msg
->hwnd
, msg
->message
, retval
,
3134 msg
->wParam
, msg
->lParam
);
3136 if (msg
->message
== WM_PAINT
)
3138 /* send a WM_NCPAINT and WM_ERASEBKGND if the non-client area is still invalid */
3139 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
3140 GetUpdateRgn( msg
->hwnd
, hrgn
, TRUE
);
3141 DeleteObject( hrgn
);
3147 /***********************************************************************
3148 * GetMessagePos (USER.119)
3149 * GetMessagePos (USER32.@)
3151 * The GetMessagePos() function returns a long value representing a
3152 * cursor position, in screen coordinates, when the last message
3153 * retrieved by the GetMessage() function occurs. The x-coordinate is
3154 * in the low-order word of the return value, the y-coordinate is in
3155 * the high-order word. The application can use the MAKEPOINT()
3156 * macro to obtain a POINT structure from the return value.
3158 * For the current cursor position, use GetCursorPos().
3162 * Cursor position of last message on success, zero on failure.
3169 DWORD WINAPI
GetMessagePos(void)
3171 return get_user_thread_info()->GetMessagePosVal
;
3175 /***********************************************************************
3176 * GetMessageTime (USER.120)
3177 * GetMessageTime (USER32.@)
3179 * GetMessageTime() returns the message time for the last message
3180 * retrieved by the function. The time is measured in milliseconds with
3181 * the same offset as GetTickCount().
3183 * Since the tick count wraps, this is only useful for moderately short
3184 * relative time comparisons.
3188 * Time of last message on success, zero on failure.
3190 LONG WINAPI
GetMessageTime(void)
3192 return get_user_thread_info()->GetMessageTimeVal
;
3196 /***********************************************************************
3197 * GetMessageExtraInfo (USER.288)
3198 * GetMessageExtraInfo (USER32.@)
3200 LPARAM WINAPI
GetMessageExtraInfo(void)
3202 return get_user_thread_info()->GetMessageExtraInfoVal
;
3206 /***********************************************************************
3207 * SetMessageExtraInfo (USER32.@)
3209 LPARAM WINAPI
SetMessageExtraInfo(LPARAM lParam
)
3211 struct user_thread_info
*thread_info
= get_user_thread_info();
3212 LONG old_value
= thread_info
->GetMessageExtraInfoVal
;
3213 thread_info
->GetMessageExtraInfoVal
= lParam
;
3218 /***********************************************************************
3219 * WaitMessage (USER.112) Suspend thread pending messages
3220 * WaitMessage (USER32.@) Suspend thread pending messages
3222 * WaitMessage() suspends a thread until events appear in the thread's
3225 BOOL WINAPI
WaitMessage(void)
3227 return (MsgWaitForMultipleObjectsEx( 0, NULL
, INFINITE
, QS_ALLINPUT
, 0 ) != WAIT_FAILED
);
3231 /***********************************************************************
3232 * MsgWaitForMultipleObjectsEx (USER32.@)
3234 DWORD WINAPI
MsgWaitForMultipleObjectsEx( DWORD count
, CONST HANDLE
*pHandles
,
3235 DWORD timeout
, DWORD mask
, DWORD flags
)
3237 HANDLE handles
[MAXIMUM_WAIT_OBJECTS
];
3240 if (count
> MAXIMUM_WAIT_OBJECTS
-1)
3242 SetLastError( ERROR_INVALID_PARAMETER
);
3246 /* set the queue mask */
3247 SERVER_START_REQ( set_queue_mask
)
3249 req
->wake_mask
= (flags
& MWMO_INPUTAVAILABLE
) ? mask
: 0;
3250 req
->changed_mask
= mask
;
3252 wine_server_call( req
);
3256 /* add the queue to the handle list */
3257 for (i
= 0; i
< count
; i
++) handles
[i
] = pHandles
[i
];
3258 handles
[count
] = get_server_queue_handle();
3260 ReleaseThunkLock( &lock
);
3261 ret
= USER_Driver
->pMsgWaitForMultipleObjectsEx( count
+1, handles
, timeout
, mask
, flags
);
3262 if (lock
) RestoreThunkLock( lock
);
3267 /***********************************************************************
3268 * MsgWaitForMultipleObjects (USER32.@)
3270 DWORD WINAPI
MsgWaitForMultipleObjects( DWORD count
, CONST HANDLE
*handles
,
3271 BOOL wait_all
, DWORD timeout
, DWORD mask
)
3273 return MsgWaitForMultipleObjectsEx( count
, handles
, timeout
, mask
,
3274 wait_all
? MWMO_WAITALL
: 0 );
3278 /***********************************************************************
3279 * WaitForInputIdle (USER32.@)
3281 DWORD WINAPI
WaitForInputIdle( HANDLE hProcess
, DWORD dwTimeOut
)
3283 DWORD start_time
, elapsed
, ret
;
3286 handles
[0] = hProcess
;
3287 SERVER_START_REQ( get_process_idle_event
)
3289 req
->handle
= hProcess
;
3290 if (!(ret
= wine_server_call_err( req
))) handles
[1] = reply
->event
;
3293 if (ret
) return WAIT_FAILED
; /* error */
3294 if (!handles
[1]) return 0; /* no event to wait on */
3296 start_time
= GetTickCount();
3299 TRACE("waiting for %p\n", handles
[1] );
3302 ret
= MsgWaitForMultipleObjects ( 2, handles
, FALSE
, dwTimeOut
- elapsed
, QS_SENDMESSAGE
);
3307 case WAIT_OBJECT_0
+2:
3308 process_sent_messages();
3312 TRACE("timeout or error\n");
3315 TRACE("finished\n");
3318 if (dwTimeOut
!= INFINITE
)
3320 elapsed
= GetTickCount() - start_time
;
3321 if (elapsed
> dwTimeOut
)
3327 return WAIT_TIMEOUT
;
3331 /***********************************************************************
3332 * UserYield (USER.332)
3334 void WINAPI
UserYield16(void)
3338 /* Handle sent messages */
3339 process_sent_messages();
3342 ReleaseThunkLock(&count
);
3346 RestoreThunkLock(count
);
3347 /* Handle sent messages again */
3348 process_sent_messages();
3353 /***********************************************************************
3354 * RegisterWindowMessageA (USER32.@)
3355 * RegisterWindowMessage (USER.118)
3357 UINT WINAPI
RegisterWindowMessageA( LPCSTR str
)
3359 UINT ret
= GlobalAddAtomA(str
);
3360 TRACE("%s, ret=%x\n", str
, ret
);
3365 /***********************************************************************
3366 * RegisterWindowMessageW (USER32.@)
3368 UINT WINAPI
RegisterWindowMessageW( LPCWSTR str
)
3370 UINT ret
= GlobalAddAtomW(str
);
3371 TRACE("%s ret=%x\n", debugstr_w(str
), ret
);
3375 typedef struct BroadcastParm
3386 static BOOL CALLBACK
bcast_childwindow( HWND hw
, LPARAM lp
)
3388 BroadcastParm
*parm
= (BroadcastParm
*)lp
;
3389 DWORD_PTR retval
= 0;
3392 if (parm
->flags
& BSF_IGNORECURRENTTASK
&& WIN_IsCurrentProcess(hw
))
3394 TRACE("Not telling myself %p\n", hw
);
3398 /* I don't know 100% for sure if this is what Windows does, but it fits the tests */
3399 if (parm
->flags
& BSF_QUERY
)
3401 TRACE("Telling window %p using SendMessageTimeout\n", hw
);
3403 /* Not tested for conflicting flags */
3404 if (parm
->flags
& BSF_FORCEIFHUNG
|| parm
->flags
& BSF_NOHANG
)
3405 lresult
= SendMessageTimeoutW( hw
, parm
->msg
, parm
->wp
, parm
->lp
, SMTO_ABORTIFHUNG
, 2000, &retval
);
3406 else if (parm
->flags
& BSF_NOTIMEOUTIFNOTHUNG
)
3407 lresult
= SendMessageTimeoutW( hw
, parm
->msg
, parm
->wp
, parm
->lp
, SMTO_NOTIMEOUTIFNOTHUNG
, 2000, &retval
);
3409 lresult
= SendMessageTimeoutW( hw
, parm
->msg
, parm
->wp
, parm
->lp
, SMTO_NORMAL
, 2000, &retval
);
3411 if (!lresult
&& GetLastError() == ERROR_TIMEOUT
)
3413 WARN("Timed out!\n");
3414 if (!(parm
->flags
& BSF_FORCEIFHUNG
))
3417 if (retval
== BROADCAST_QUERY_DENY
)
3426 else if (parm
->flags
& BSF_POSTMESSAGE
)
3428 TRACE("Telling window %p using PostMessage\n", hw
);
3429 PostMessageW( hw
, parm
->msg
, parm
->wp
, parm
->lp
);
3433 TRACE("Telling window %p using SendNotifyMessage\n", hw
);
3434 SendNotifyMessageW( hw
, parm
->msg
, parm
->wp
, parm
->lp
);
3440 static BOOL CALLBACK
bcast_desktop( LPWSTR desktop
, LPARAM lp
)
3444 BroadcastParm
*parm
= (BroadcastParm
*)lp
;
3446 TRACE("desktop: %s\n", debugstr_w( desktop
));
3448 hdesktop
= open_winstation_desktop( parm
->winsta
, desktop
, 0, FALSE
, DESKTOP_ENUMERATE
|DESKTOP_WRITEOBJECTS
|STANDARD_RIGHTS_WRITE
);
3451 FIXME("Could not open desktop %s\n", debugstr_w(desktop
));
3455 ret
= EnumDesktopWindows( hdesktop
, bcast_childwindow
, lp
);
3456 CloseDesktop(hdesktop
);
3457 TRACE("-->%d\n", ret
);
3458 return parm
->success
;
3461 static BOOL CALLBACK
bcast_winsta( LPWSTR winsta
, LPARAM lp
)
3464 HWINSTA hwinsta
= OpenWindowStationW( winsta
, FALSE
, WINSTA_ENUMDESKTOPS
);
3465 TRACE("hwinsta: %p/%s/%08x\n", hwinsta
, debugstr_w( winsta
), GetLastError());
3468 ((BroadcastParm
*)lp
)->winsta
= hwinsta
;
3469 ret
= EnumDesktopsW( hwinsta
, bcast_desktop
, lp
);
3470 CloseWindowStation( hwinsta
);
3471 TRACE("-->%d\n", ret
);
3475 /***********************************************************************
3476 * BroadcastSystemMessageA (USER32.@)
3477 * BroadcastSystemMessage (USER32.@)
3479 LONG WINAPI
BroadcastSystemMessageA( DWORD flags
, LPDWORD recipients
, UINT msg
, WPARAM wp
, LPARAM lp
)
3481 return BroadcastSystemMessageExA( flags
, recipients
, msg
, wp
, lp
, NULL
);
3485 /***********************************************************************
3486 * BroadcastSystemMessageW (USER32.@)
3488 LONG WINAPI
BroadcastSystemMessageW( DWORD flags
, LPDWORD recipients
, UINT msg
, WPARAM wp
, LPARAM lp
)
3490 return BroadcastSystemMessageExW( flags
, recipients
, msg
, wp
, lp
, NULL
);
3493 /***********************************************************************
3494 * BroadcastSystemMessageExA (USER32.@)
3496 LONG WINAPI
BroadcastSystemMessageExA( DWORD flags
, LPDWORD recipients
, UINT msg
, WPARAM wp
, LPARAM lp
, PBSMINFO pinfo
)
3498 map_wparam_AtoW( msg
, &wp
, WMCHAR_MAP_NOMAPPING
);
3499 return BroadcastSystemMessageExW( flags
, recipients
, msg
, wp
, lp
, NULL
);
3503 /***********************************************************************
3504 * BroadcastSystemMessageExW (USER32.@)
3506 LONG WINAPI
BroadcastSystemMessageExW( DWORD flags
, LPDWORD recipients
, UINT msg
, WPARAM wp
, LPARAM lp
, PBSMINFO pinfo
)
3509 DWORD recips
= BSM_ALLCOMPONENTS
;
3511 static const DWORD all_flags
= ( BSF_QUERY
| BSF_IGNORECURRENTTASK
| BSF_FLUSHDISK
| BSF_NOHANG
3512 | BSF_POSTMESSAGE
| BSF_FORCEIFHUNG
| BSF_NOTIMEOUTIFNOTHUNG
3513 | BSF_ALLOWSFW
| BSF_SENDNOTIFYMESSAGE
| BSF_RETURNHDESK
| BSF_LUID
);
3515 TRACE("Flags: %08x, recipients: %p(0x%x), msg: %04x, wparam: %08lx, lparam: %08lx\n", flags
, recipients
,
3516 (recipients
? *recipients
: recips
), msg
, wp
, lp
);
3518 if (flags
& ~all_flags
)
3520 SetLastError(ERROR_INVALID_PARAMETER
);
3525 recipients
= &recips
;
3527 if ( pinfo
&& flags
& BSF_QUERY
)
3528 FIXME("Not returning PBSMINFO information yet\n");
3531 parm
.recipients
= recipients
;
3535 parm
.success
= TRUE
;
3537 if (*recipients
& BSM_ALLDESKTOPS
|| *recipients
== BSM_ALLCOMPONENTS
)
3538 ret
= EnumWindowStationsW(bcast_winsta
, (LONG_PTR
)&parm
);
3539 else if (*recipients
& BSM_APPLICATIONS
)
3541 EnumWindows(bcast_childwindow
, (LONG_PTR
)&parm
);
3545 FIXME("Recipients %08x not supported!\n", *recipients
);
3550 /***********************************************************************
3551 * SetMessageQueue (USER32.@)
3553 BOOL WINAPI
SetMessageQueue( INT size
)
3555 /* now obsolete the message queue will be expanded dynamically as necessary */
3560 /***********************************************************************
3561 * MessageBeep (USER32.@)
3563 BOOL WINAPI
MessageBeep( UINT i
)
3566 SystemParametersInfoA( SPI_GETBEEP
, 0, &active
, FALSE
);
3567 if (active
) USER_Driver
->pBeep();
3572 /***********************************************************************
3573 * SetTimer (USER32.@)
3575 UINT_PTR WINAPI
SetTimer( HWND hwnd
, UINT_PTR id
, UINT timeout
, TIMERPROC proc
)
3578 WNDPROC winproc
= 0;
3580 if (proc
) winproc
= WINPROC_AllocProc( (WNDPROC
)proc
, NULL
);
3582 SERVER_START_REQ( set_win_timer
)
3585 req
->msg
= WM_TIMER
;
3587 req
->rate
= max( timeout
, SYS_TIMER_RATE
);
3588 req
->lparam
= (unsigned long)winproc
;
3589 if (!wine_server_call_err( req
))
3592 if (!ret
) ret
= TRUE
;
3598 TRACE("Added %p %lx %p timeout %d\n", hwnd
, id
, winproc
, timeout
);
3603 /***********************************************************************
3604 * SetSystemTimer (USER32.@)
3606 UINT_PTR WINAPI
SetSystemTimer( HWND hwnd
, UINT_PTR id
, UINT timeout
, TIMERPROC proc
)
3609 WNDPROC winproc
= 0;
3611 if (proc
) winproc
= WINPROC_AllocProc( (WNDPROC
)proc
, NULL
);
3613 SERVER_START_REQ( set_win_timer
)
3616 req
->msg
= WM_SYSTIMER
;
3618 req
->rate
= max( timeout
, SYS_TIMER_RATE
);
3619 req
->lparam
= (unsigned long)winproc
;
3620 if (!wine_server_call_err( req
))
3623 if (!ret
) ret
= TRUE
;
3629 TRACE("Added %p %lx %p timeout %d\n", hwnd
, id
, winproc
, timeout
);
3634 /***********************************************************************
3635 * KillTimer (USER32.@)
3637 BOOL WINAPI
KillTimer( HWND hwnd
, UINT_PTR id
)
3641 SERVER_START_REQ( kill_win_timer
)
3644 req
->msg
= WM_TIMER
;
3646 ret
= !wine_server_call_err( req
);
3653 /***********************************************************************
3654 * KillSystemTimer (USER32.@)
3656 BOOL WINAPI
KillSystemTimer( HWND hwnd
, UINT_PTR id
)
3660 SERVER_START_REQ( kill_win_timer
)
3663 req
->msg
= WM_SYSTIMER
;
3665 ret
= !wine_server_call_err( req
);
3672 /**********************************************************************
3673 * GetGUIThreadInfo (USER32.@)
3675 BOOL WINAPI
GetGUIThreadInfo( DWORD id
, GUITHREADINFO
*info
)
3679 SERVER_START_REQ( get_thread_input
)
3682 if ((ret
= !wine_server_call_err( req
)))
3685 info
->hwndActive
= reply
->active
;
3686 info
->hwndFocus
= reply
->focus
;
3687 info
->hwndCapture
= reply
->capture
;
3688 info
->hwndMenuOwner
= reply
->menu_owner
;
3689 info
->hwndMoveSize
= reply
->move_size
;
3690 info
->hwndCaret
= reply
->caret
;
3691 info
->rcCaret
.left
= reply
->rect
.left
;
3692 info
->rcCaret
.top
= reply
->rect
.top
;
3693 info
->rcCaret
.right
= reply
->rect
.right
;
3694 info
->rcCaret
.bottom
= reply
->rect
.bottom
;
3695 if (reply
->menu_owner
) info
->flags
|= GUI_INMENUMODE
;
3696 if (reply
->move_size
) info
->flags
|= GUI_INMOVESIZE
;
3697 if (reply
->caret
) info
->flags
|= GUI_CARETBLINKING
;
3705 /******************************************************************
3706 * IsHungAppWindow (USER32.@)
3709 BOOL WINAPI
IsHungAppWindow( HWND hWnd
)
3713 SERVER_START_REQ( is_window_hung
)
3716 ret
= !wine_server_call_err( req
) && reply
->is_hung
;