SendMessageTimeout Function
Sends the specified message to one of more windows.
Syntax
LRESULT SendMessageTimeout( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT fuFlags, UINT uTimeout, PDWORD_PTR lpdwResult );
Parameters
hWnd
- [in] Handle to the window whose window procedure will receive the message.
MsgIf this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows. The function does not return until each window has timed out. Therefore, the total wait time can be up to the value of uTimeout multiplied by the number of top-level windows.
- [in] Specifies the message to be sent.
wParam- [in] Specifies additional message-specific information.
lParam- [in] Specifies additional message-specific information.
fuFlags- [in] Specifies how to send the message. This parameter can be one or more of the following values.
uTimeoutSMTO_ABORTIFHUNG
- Returns without waiting for the time-out period to elapse if the receiving thread appears to not respond or "hangs."
SMTO_BLOCK- Prevents the calling thread from processing any other requests until the function returns.
SMTO_NORMAL- The calling thread is not prevented from processing other requests while waiting for the function to return.
SMTO_NOTIMEOUTIFNOTHUNG- Microsoft Windows 2000/Windows XP: Do not enforce the time-out period as long as the receiving thread is processing messages.
SMTO_ERRORONEXIT- [in] Specifies the duration, in milliseconds, of the time-out period. If the message is a broadcast message, each window can use the full time-out period. For example, if you specify a five second time-out period and there are three top-level windows that fail to process the message, you could have up to a 15 second delay.
lpdwResult- [out] Receives the result of the message processing. This value depends on the message sent.
Return Value
If the function succeeds, the return value is nonzero. SendMessageTimeout does not provide information about individual windows timing out if HWND_BROADCAST is used.
If the function fails or times out, the return value is zero. To get extended error information, call GetLastError. If GetLastError returns ERROR_TIMEOUT, then the function timed out.
Microsoft Windows 2000: If GetLastError returns zero, then the function timed out.
Remarks
The function calls the window procedure for the specified window and, if the specified window belongs to a different thread, does not return until the window procedure has processed the message or the specified time-out period has elapsed. If the window receiving the message belongs to the same queue as the current thread, the window procedure is called directly—the time-out value is ignored.
This function considers a thread is not responding if it has not called GetMessage or a similar function within five seconds.
The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send other messages (those >= WM_USER) to another process, you must do custom marshalling.
Windows 95/98/Me: SendMessageTimeoutW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems
.
Function Information
Minimum DLL Version user32.dll Header Declared in Winuser.h, include Windows.h Import library User32.lib Minimum operating systems Windows 95, Windows NT 3.1 Unicode Implemented as ANSI and Unicode versions.
See Also
Messages and Message Queues Overview, GetMessage, InSendMessage, PostMessage, SendDlgItemMessage, SendMessage, SendMessageCallback, SendNotifyMessage