消息与消息队列

Messages and Message Queues
消息与消息队列
--------------------------------------------------------------------------------
This section describes messages and message queues and how to use them in your applications.
这一节讲的是怎样在你的应用程序中使用消息和消息队列

Overviews
概述

About Messages and Message Queues
关于消息与消息队列

This section discusses Windows messages and message queues.
这一节讨论的是windows消息与消息队列

Using Messages and Message Queues
使用消息与消息队列

The following code examples demonstrate how to perform the following tasks associated with Microsoft Windows messages and message queues.
接下来的代码例句阐述了在windows中消息和消息队列怎样执行接下来的任务


Functions
函数

BroadcastSystemMessage
The BroadcastSystemMessage function 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.
BroadcastSystemMessage 函数向指定的收件人发送一条消息。收件人可以为应用程序、可安装驱动、网络驱动器、系统级装备驱动或者是这些系统组件的任意组合。

To receive additional information if the request is defined, use the BroadcastSystemMessage Ex function.
使用BroadcastSystemMessageEx 函数,可以接受到附加信息。

BroadcastSystemMessageEx
The BroadcastSystemMessageEx function 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.
BroadcastSystemMessageEx函数向指定的收件人发送一条信息。收件人可以是应用程序、可安装驱动、网络驱动器、系统级装备驱动或者是这些系统组件的任意组合。

This function is similar to BroadcastSystemMessage except that this function can return more information from the recipients.
这个函数与BroadcastSystemMessage相似,但是可以从收件人处返回更多的信息。

DispatchMessage
The DispatchMessage function dispatches a message to a window procedure. It is typically used to dispatch a message retrieved by the GetMessage function.
DispatchMessage函数调度一个消息给窗口程序。通常调度从GetMessage函数得到的消息。

GetInputState
The GetInputState function determines whether there are mouse-button or keyboard messages in the calling thread's message queue.
GetInputState函数判定是否有鼠标或者键盘信息在线程消息队列。

GetMessage
The GetMessage function retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval.
GetMessage函数从线程消息队列获得一条信息。这个函数不断调度进来的信息直到发布的信息可用为止

Unlike GetMessage, the PeekMessage function does not wait for a message to be posted before returning.
和 GetMessage不同的是PeekMessage函数不用等到一条信息发布就可以返回

GetMessageExtraInfo
The GetMessageExtraInfo function 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.
GetMessageExtraInfo函数从当前线程中获得额外信息。额外信息是当前消息线程队列中一个应用程序或者驱动程序的值

GetMessagePos
The GetMessagePos function retrieves the cursor position for the last message retrieved by the GetMessage function.
GetMessagePos函数可以获得GetMessage函数最后一个信息的光标位子

To determine the current position of the cursor, use the GetCursorPos function.
使用GetCursorPos函数可以确定当前光标的位子

GetMessageTime
The GetMessageTime function 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).
GetMessageTime函数可以获得GetMessage函数最后信息的时间。这个时间是从系统启动时间到信息创造出的时间的长整数,单位为毫秒(即安放在线程消息列队里)

GetQueueStatus
The GetQueueStatus function indicates the type of messages found in the calling thread's message queue.
GetQueueStatus函数显示在线程消息队列里的消息类型

InSendMessage
The InSendMessage function 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.
InSendMessage函数决定当前窗口程序是否处理另一线程调用SendMessage(在相同进程或不同进程中)发送的消息

To obtain additional information about how the message was sent, use the InSendMessageEx function.
使用InSendMessageEx函数可以获得消息是如何发送的额外信息

InSendMessageEx
The InSendMessageEx function determines whether the current window procedure is processing a message that was sent from another thread (in the same process or a different process).
InSendMessageEx函数决定当前窗口程序是否处理另一线程(在相同进程或不同进程中)发送的消息

PeekMessage
The PeekMessage function dispatches incoming sent messages, checks the thread message queue for a posted message, and retrieves the message (if any exist).
PeekMessage函数调度进来的消息,检查已发布的消息的线程消息队列,获得消息(如果有的话)

PostMessage
The PostMessage function places (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.
PostMessage函数放置一条消息在消息队列中,在这个线程中创建指定的窗口且可以不用等待线程处理消息就返回

To post a message in the message queue associate with a thread, use the PostThreadMessage function.
使用PostThreadMessage函数可以在一个线程中发布一条消息在消息队列

PostQuitMessage
The PostQuitMessage function 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.
PostQuitMessage函数向系统表明一个线程请求终止。通常用在响应WM_DESTROY消息

PostThreadMessage
The PostThreadMessage function posts a message to the message queue of the specified thread. It returns without waiting for the thread to process the message.
PostThreadMessage函数向线程中的消息队列发布一条消息。不需要等待线程处理消息就返回

RegisterWindowMessage
The RegisterWindowMessage function 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.
RegisterWindowMessage函数定义一个新窗口信息,这个新窗口信息在系统中的独一无二的。这个消息指可以在发送或发布消息是使用。

ReplyMessage
The ReplyMessage function is used to reply to a message sent through the SendMessage function without returning control to the function that called SendMessage.
ReplyMessage函数是用来应答SendMessage函数发送的消息,而不返回控制调用SendMessage的函数

SendAsyncProc
The SendAsyncProc function is 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.
SendAsyncProc函数是和SendMessageCallback函数一起使用的一个应用程序定义的回调函数。系统将消息传给目标窗口程序后,再传给回调函数。SendAsyncProc是应用程序定义的函数名的一个占位符。

SendMessage
The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.
SendMessage函数将指定的消息发送给一个或多个窗口。这个函数为指定的窗口调用窗口程序,当窗口程序处理完消息后返回

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或SendNotifyMessage函数,立即发送和返回一条消息。使用PostMessage or PostThreadMessage函数,发布一条消息给线程消息队列,然后立即返回


SendMessageCallback
The SendMessageCallback function 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.
SendMessageCallback函数给一个或多个窗口发送指定的消息。这个函数为指定的窗口调用窗口程序,然后立即返回。在窗口程序处理消息后,系统调用指定的回调函数,将消息处理结果和应用程序定义值发给回调函数。

SendMessageTimeout
Sends the specified message to one of more windows.
发送指定的消息给更多窗口中的一个

SendNotifyMessage
The SendNotifyMessage function 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.
SendNotifyMessage函数发送指定的消息给一个或多个窗口。如果窗口是由调用的线程创建,SendNotifyMessage就为窗口调用窗口程序,直至窗口程序完成处理消息后返回。如果窗口是由一个不同线创建,SendNotifyMessage将消息传给窗口程序,然后立即返回;这个函数不需要等待窗口程序处理完消息。

SetMessageExtraInfo
The SetMessageExtraInfo function 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.
SetMessageExtraInfo函数为当前线程设置额外消息信息。额外消息信息是当前线程消息队列中的一个应用程序或者驱动定义值。应用程序能够使用GetMessageExtraInfo函数来获得一个线程额外的消息信息。

TranslateMessage
The TranslateMessage function 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.
TranslateMessage函数是将虚拟键消息转换为字符消息。字符消息被指派去调用线程消息列队,从而在下一次线程调用GetMessage or PeekMessage函数时被读取

WaitMessage
The WaitMessage function 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.
当一个线程在它的消息队列里没有其他消息时,WaitMessage函数产生对其他线程的控制。WaitMessage函数终止线程,直到有一个新消息出现在线程消息队列时,再返回。

Notifications
OCM__BASE
The OCM__BASE constant is used by applications to help define private messages for use by private window classes, usually of the form OCM__BASE+X, where X is an integer value.
OCM__BASE常数通常被应用程序用来帮助为私有的窗口类别定义私有消息,通常用OCM__BASE+X的格式,X是一个整数值

Note  Unlike WM_APP and WM_USER, OCM__BASE is defined in Olectl.h.
和M_APP and WM_USER不同的是:OCM__BASE是在Olectl.h.定义

WM_APP
The WM_APP constant is used by applications to help define private messages, usually of the form WM_APP+X, where X is an integer value.
WM_APP常数通常被应用程序用来帮助定义私有消息,通常用WM_APP+X的格式,X是一个整数值

WM_QUIT
The WM_QUIT message indicates a request to terminate an application and is generated when the application calls the PostQuitMessage function. It causes the GetMessage function to return zero.
WM_QUIT消息指示了终止应用程序的请求,并且当应用程序调用PostQuitMessage函数时产生。WM_QUIT造成GetMessage函数返回到0

WM_USER
The WM_USER constant is used by applications to help define private messages for use by private window classes, usually of the form WM_USER+X, where X is an integer value.
WM_USER常数通常被应用程序用来帮助为私有的窗口类别定义私有消息,通常用WM_USER+X的格式,X是一个整数值


Structures
BSMINFO
The BSMINFO structure contains information about a window that denied a request from BroadcastSystemMessageEx.
BSMINFO结构包含拒绝BroadcastSystemMessageEx函数请求的窗口信息。

MSG
The MSG structure contains message information from a thread's message queue.
MSG结构包含线程消息队列的消息信息

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值