Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function sends a specified message to a window by calling the window procedure for the specified window, with the message as one of the parameters for the window procedure. If a specified window belongs to a different thread, SendMessageTimeoutdoes not return until either the window procedure for that window processes the message or a specified time-out period elapses. If the window receiving the message belongs to the message queue of the current thread, SendMessageTimeoutcalls the window procedure directly and ignores the time-out value.

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 to which SendMessageTimeoutshould send the message and for which SendMessageTimeoutshould call the window procedure. If the value of this parameter is HWND_BROADCAST, SendMessageTimeoutsends the message to all top-level windows running on the operating system, including unavailable or hidden unowned windows. SendMessageTimeoutdoes not return until each window times out. Therefore, the total delay can last up to uTimeoutmilliseconds times the number of top-level windows.

Msg

[in] Unsigned integer that specifies the message to be sent.

wParam

[in] WPARAMthat specifies additional message-specific information.

lParam

[in] LPARAMthat specifies additional message-specific information.

fuFlags

[in] Unsigned integer that specifies how to send the message. For Windows Embedded CE, the only valid value is SMTO_NORMAL, which indicates that the calling thread can process other requests while waiting for SendMessageTimeoutto return.

uTimeout

[in] Unsigned integer that specifies the duration, in milliseconds, of the time-out period. If you send a broadcast message, each window can use the full time-out period. For example, if you specify a 5 second time-out period and three top-level windows fail to process the message, your total delay can last up to 15 seconds.

lpdwResult

[out] Pointer to a DWORDthat receives the result of the message processing. This value depends on the message that you send.

Return Value

A nonzero value indicates success. Zero indicates failure or that SendMessageTimeouttimed out. To get extended error information, call GetLastError. If GetLastErrorreturns 0, SendMessageTimeouttimed out. If you call SendMessageTimeoutwith the HWND_BROADCAST handle, the return value does not indicate whether individual windows timed out.

Remarks

Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessagefunction to obtain a unique message for inter-application communication.

Windows Embedded CE does not support all the messages the Windows-based desktop platforms support.

Requirements

Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also