网站首页  词典首页

请输入您要查询的函数:

 

术语 getmessage
释义 GetMessage
语法:
BOOL GetMessage( LPMSG lpMsg,
HWND hWnd,
UINT wMsgFilterMin,
UINT wMsgFilterMax
);
GetMessage函数
检索GetMessage函数从调用线程的消息队列的消息。函数调度直到传入发布消息发送的邮件都可以检索。
与GetMessage的PeekMessage函数不等待消息被张贴,然后返回。
参数
lpMsg
[out]指向一个MSG结构接收从线程的消息队列中的邮件信息。
hWnd
[in]句柄窗口的消息要检索。窗口必须属于当前线程。
如果hWnd为NULL,GetMessage撷取任何窗口属于当前线程的信息,并就当前线程的消息队列的任何消息,其hWnd值为NULL(见MSG结构)。因此,如果hWnd为NULL,既窗口消息和线程的邮件处理。
如果hWnd为-1,GetMessage获取当前线程的消息队列的消息,其唯一的hWnd值为NULL,即线程消息由PostMessage张贴(当hWnd参数为NULL)或PostThreadMessage。
wMsgFilterMin
[in]指定消息的最低值整数值进行检索。使用WM_KEYFIRST指定第一个键盘消息,或WM_MOUSEFIRST指定第一个鼠标消息。
Windows XP中:使用WM_INPUT这里和wMsgFilterMax指定只WM_INPUT消息。
如果wMsgFilterMin和wMsgFilterMax均为零,GetMessage返回所有可用的信息(即不进行筛选范围)。
wMsgFilterMax
[in]指定的最高值整数值的信息要检索。使用WM_KEYLAST指定最后键盘信息或WM_MOUSELAST指定最后鼠标消息。
窗口XP的:使用WM_INPUT这里和wMsgFilterMin指定只WM_INPUT消息。
如果wMsgFilterMin和wMsgFilterMax均为零,GetMessage返回所有可用的信息(即不进行筛选范围)。
返回值
如果该函数检索比WM_QUIT消息外,则返回值为非零。
如果该函数检索WM_QUIT消息,返回值是零。
如果出现错误,则返回值为-1。例如,函数失败如果hWnd是一个无效的窗口句柄或lpMsg是一个无效的指针。为了获得更多错误信息,调用GetLastError。
警告
由于返回值可以为零,零或-1,避免这样的代码:
while (GetMessage( lpMsg, hWnd, 0, 0)) ...
The possibility of a -1 return value means that such code can lead to fatal application errors. Instead, use code like this:
BOOL bRet;
while( (bRet = GetMessage( &msg, hWnd, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
备注
应用程序通常使用的返回值,以确定是否终止主消息循环并退出程序。
GetMessage函数与检索的hWnd参数或其子女的任何确定的窗口相关的信息,由IsChild函数指定,并在由wMsgFilterMin和wMsgFilterMax参数给定的消息值的范围。请注意,应用程序只能使用在wMsgFilterMin和wMsgFilterMax参数的低位字,高位字是为系统保留。
请注意,GetMessage总是检索WM_QUIT消息,无论哪个值指定为wMsgFilterMin和wMsgFilterMax。
在此呼吁,该系统能够等待,nonqueued消息,就是发送到由调用使用SendMessage消息,SendMessageCallback,SendMessageTimeout,或SendNotifyMessage功能线程拥有的窗口。然后第一个排队的消息相匹配指定的过滤器检索。该系统也可处理内部事件。如果没有指定过滤器,邮件处理,按以下顺序:
发送的邮件
发布信息
输入(硬件)信息和系统的内部事件
发送的邮件(再次)
WM_PAINT消息
WM_TIMER消息
要检索发布消息之前,输入信息,使用wMsgFilterMin和wMsgFilterMax参数。
GetMessage不从队列中删除WM_PAINT消息。这些消息留在队列中,直到处理。
Windows XP:如果顶层窗口停止响应的邮件超过几秒钟,系统会考虑将窗口没有响应,代之以一个幽灵窗口具有相同的z顺序,位置,大小它,视觉属性。这允许用户将其移动,调整大小,甚至关闭该应用程序。然而,这些行动是唯一可用,因为该应用程序实际上是没有响应。在调试模式下,系统不会生成映像窗口。
在Windows 95/98/Me:GetMessageW是支持的Unicode(MSLU)微软层。要使用此,您必须将某些文件到您的应用,概述了对Unicode的Microsoft层在Windows 95/98/Me系统。
例如
有关示例,请参阅创建消息循环。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低操作系统Windows 95,Windows NT 3.1
UnicodeImplemented为ANSI和Unicode版本。
参见
消息和消息队列概述,IsChild,味精,PeekMessage,PostMessage,PostThreadMessage,WaitMessage
==英文原文==GetMessage Function
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.
Unlike GetMessage, the PeekMessage function does not wait for a message to be posted before returning.
Syntax
BOOL GetMessage( LPMSG lpMsg,
HWND hWnd,
UINT wMsgFilterMin,
UINT wMsgFilterMax
);
Parameters
lpMsg
[out] Pointer to an MSG structure that receives message information from the thread's message queue.
hWnd
[in] Handle to the window whose messages are to be retrieved. The window must belong to the current thread.
If hWnd is NULL, GetMessage retrieves messages for any window that belongs to the current thread, and any messages on the current thread's message queue whose hwnd value is NULL (see the MSG structure). Therefore if hWnd is NULL, both window messages and thread messages are processed.
If hWnd is -1, GetMessage retrieves only messages on the current thread's message queue whose hwnd value is NULL, that is, thread messages as posted by PostMessage (when the hWnd parameter is NULL) or PostThreadMessage .
wMsgFilterMin
[in] Specifies the integer value of the lowest message value to be retrieved. Use WM_KEYFIRST to specify the first keyboard message or WM_MOUSEFIRST to specify the first mouse message.
Windows XP: Use WM_INPUT here and in wMsgFilterMax to specify only the WM_INPUT messages.
If wMsgFilterMin and wMsgFilterMax are both zero, GetMessage returns all available messages (that is, no range filtering is performed).
wMsgFilterMax
[in] Specifies the integer value of the highest message value to be retrieved. Use WM_KEYLAST to specify the last keyboard message or WM_MOUSELAST to specify the last mouse message.
Windows XP: Use WM_INPUT here and in wMsgFilterMin to specify only the WM_INPUT messages.
If wMsgFilterMin and wMsgFilterMax are both zero, GetMessage returns all available messages (that is, no range filtering is performed).
Return Value
If the function retrieves a message other than WM_QUIT , the return value is nonzero.
If the function retrieves the WM_QUIT message, the return value is zero.
If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. To get extended error information, call GetLastError .
Warning
Because the return value can be nonzero, zero, or -1, avoid code like this:
while (GetMessage( lpMsg, hWnd, 0, 0)) ...
The possibility of a -1 return value means that such code can lead to fatal application errors. Instead, use code like this:
BOOL bRet;
while( (bRet = GetMessage( &msg, hWnd, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Remarks
An application typically uses the return value to determine whether to end the main message loop and exit the program.
The GetMessage function retrieves messages associated with the window identified by the hWnd parameter or any of its children, as specified by the IsChild function, and within the range of message values given by the wMsgFilterMin and wMsgFilterMax parameters. Note that an application can only use the low word in the wMsgFilterMin and wMsgFilterMax parameters; the high word is reserved for the system.
Note that GetMessage always retrieves WM_QUIT messages, no matter which values you specify for wMsgFilterMin and wMsgFilterMax.
During this call, the system delivers pending, nonqueued messages, that is, messages sent to windows owned by the calling thread using the SendMessage , SendMessageCallback , SendMessageTimeout , or SendNotifyMessage function. Then the first queued message that matches the specified filter is retrieved. The system may also process internal events. If no filter is specified, messages are processed in the following order:
Sent messages
Posted messages
Input (hardware) messages and system internal events
Sent messages (again)
WM_PAINT messages
WM_TIMER messages
To retrieve input messages before posted messages, use the wMsgFilterMin and wMsgFilterMax parameters.
GetMessage does not remove WM_PAINT messages from the queue. The messages remain in the queue until processed.
Windows XP: If a top-level window stops responding to messages for more than several seconds, the system considers the window to be not responding and replaces it with a ghost window that has the same z-order, location, size, and visual attributes. This allows the user to move it, resize it, or even close the application. However, these are the only actions available because the application is actually not responding. When in the debugger mode, the system does not generate a ghost window.
Windows 95/98/Me: GetMessageW 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 .
Example
For an example, see Creating a Message Loop .
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
UnicodeImplemented as ANSI and Unicode versions.
See Also
Messages and Message Queues Overview , IsChild , MSG , PeekMessage , PostMessage , PostThreadMessage , WaitMessage
==原始网址==http://msdn.microsoft.com/en-us/library/ms644936(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:19:25