Düzenle

Aracılığıyla paylaş


Messages and Message Queues

This section describes messages and message queues and how to use them in your applications.

In This Section

Name Description
About Messages and Message Queues This section discusses Windows messages and message queues.
Using Messages and Message Queues The following code examples demonstrate how to perform the following tasks associated with Windows messages and message queues.
Message Reference Contains the API reference.

System-Provided Messages

For lists of the system-provided messages, see System-Defined Messages.

Message Functions

Name Description
BroadcastSystemMessage Sends a message to the specified recipients. The recipients can be applications, installable drivers, network drivers, system-level device drivers, or any combination of these system components.
To receive additional information if the request is defined, use the BroadcastSystemMessageEx function.
BroadcastSystemMessageEx Sends a message to the specified recipients. The recipients can be applications, installable drivers, network drivers, system-level device drivers, or any combination of these system components.
This function is similar to BroadcastSystemMessage except that this function can return more information from the recipients.
DispatchMessage Dispatches a message to a window procedure. It is typically used to dispatch a message retrieved by the GetMessage function.
GetInputState Determines whether there are mouse-button or keyboard messages in the calling thread's message queue.
GetMessage Retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval.
Unlike GetMessage, the PeekMessage function does not wait for a message to be posted before returning.
GetMessageExtraInfo Retrieves the extra message information for the current thread. Extra message information is an application- or driver-defined value associated with the current thread's message queue.
GetMessagePos Retrieves the cursor position for the last message retrieved by the GetMessage function.
To determine the current position of the cursor, use the GetCursorPos function.
GetMessageTime Retrieves the message time for the last message retrieved by the GetMessage function. The time is a long integer that specifies the elapsed time, in milliseconds, from the time the system was started to the time the message was created (that is, placed in the thread's message queue).
GetQueueStatus Indicates the type of messages found in the calling thread's message queue.
InSendMessage Determines whether the current window procedure is processing a message that was sent from another thread (in the same process or a different process) by a call to the SendMessage function.
To obtain additional information about how the message was sent, use the InSendMessageEx function.
InSendMessageEx Determines whether the current window procedure is processing a message that was sent from another thread (in the same process or a different process).
PeekMessage Dispatches incoming sent messages, checks the thread message queue for a posted message, and retrieves the message (if any exist).
PostMessage Posts a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.
To post a message in the message queue associated with a thread, use the PostThreadMessage function.
PostQuitMessage Indicates to the system that a thread has made a request to terminate (quit). It is typically used in response to a WM_DESTROY message.
PostThreadMessage Posts a message to the message queue of the specified thread. It returns without waiting for the thread to process the message.
RegisterWindowMessage Defines a new window message that is guaranteed to be unique throughout the system. The message value can be used when sending or posting messages.
ReplyMessage Replies to a message sent through the SendMessage function without returning control to the function that called SendMessage.
SendAsyncProc An application-defined callback function used with the SendMessageCallback function. The system passes the message to the callback function after passing the message to the destination window procedure. The SENDASYNCPROC type defines a pointer to this callback function. SendAsyncProc is a placeholder for the application-defined function name.
SendMessage Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.
SendMessageCallback Sends the specified message to a window or windows. It calls the window procedure for the specified window and returns immediately. After the window procedure processes the message, the system calls the specified callback function, passing the result of the message processing and an application-defined value to the callback function.
SendMessageTimeout Sends the specified message to one of more windows.
SendNotifyMessage Sends the specified message to a window or windows. If the window was created by the calling thread, SendNotifyMessage calls the window procedure for the window and does not return until the window procedure has processed the message. If the window was created by a different thread, SendNotifyMessage passes the message to the window procedure and returns immediately; it does not wait for the window procedure to finish processing the message.
SetMessageExtraInfo Sets the extra message information for the current thread. Extra message information is an application- or driver-defined value associated with the current thread's message queue. An application can use the GetMessageExtraInfo function to retrieve a thread's extra message information.
TranslateMessage Translates virtual-key messages into character messages. The character messages are posted to the calling thread's message queue, to be read the next time the thread calls the GetMessage or PeekMessage function.
WaitMessage Yields control to other threads when a thread has no other messages in its message queue. The WaitMessage function suspends the thread and does not return until a new message is placed in the thread's message queue.

Message Constants

Name Description
OCM__BASE Used to define private messages for use by private window classes.
WM_APP Used to define private messages.
WM_USER Used to define private messages for use by private window classes.

Message Structures

Name Description
BSMINFO Contains information about a window that denied a request from BroadcastSystemMessageEx.
MSG Contains message information from a thread's message queue.