PeekMessage function (Windows)
来源:互联网 发布:柠檬网络电视台 编辑:程序博客网 时间:2024/05/22 14:53
原文地址::http://msdn.microsoft.com/ZH-CN/library/windows/desktop/ms644943(v=vs.85).aspx
Dispatches incoming sent messages, checks the thread message queue for a posted message, and retrieves the message (if any exist).
Syntax
BOOL WINAPI PeekMessage( _Out_ LPMSG lpMsg, _In_opt_ HWND hWnd, _In_ UINT wMsgFilterMin, _In_ UINT wMsgFilterMax, _In_ UINT wRemoveMsg);
Parameters
- lpMsg [out]
Type: LPMSG
A pointer to an MSG structure that receives message information.
- hWnd [in, optional]
Type: HWND
A handle to the window whose messages are to be retrieved. The window must belong to the current thread.
If hWnd is NULL, PeekMessage 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, PeekMessage 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 hWndparameter is NULL) or PostThreadMessage.
- wMsgFilterMin [in]
Type: UINT
The value of the first message in the range of messages to be examined. Use WM_KEYFIRST(0x0100) to specify the first keyboard message or WM_MOUSEFIRST (0x0200) to specify the first mouse message.
If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns all available messages (that is, no range filtering is performed).
- wMsgFilterMax [in]
Type: UINT
The value of the last message in the range of messages to be examined. Use WM_KEYLAST to specify the last keyboard message or WM_MOUSELAST to specify the last mouse message.
If wMsgFilterMin and wMsgFilterMax are both zero, PeekMessage returns all available messages (that is, no range filtering is performed).
- wRemoveMsg [in]
Type: UINT
Specifies how messages are to be handled. This parameter can be one or more of the following values.
Value Meaning - PM_NOREMOVE
- 0x0000
Messages are not removed from the queue after processing byPeekMessage.
- PM_REMOVE
- 0x0001
Messages are removed from the queue after processing by PeekMessage.
- PM_NOYIELD
- 0x0002
Prevents the system from releasing any thread that is waiting for the caller to go idle (see WaitForInputIdle).
Combine this value with either PM_NOREMOVE or PM_REMOVE.
By default, all message types are processed. To specify that only certain message should be processed, specify one or more of the following values.
Value Meaning - PM_QS_INPUT
- (QS_INPUT << 16)
Process mouse and keyboard messages.
- PM_QS_PAINT
- (QS_PAINT << 16)
Process paint messages.
- PM_QS_POSTMESSAGE
- ((QS_POSTMESSAGE | QS_HOTKEY | QS_TIMER) << 16)
Process all posted messages, including timers and hotkeys.
- PM_QS_SENDMESSAGE
- (QS_SENDMESSAGE << 16)
Process all sent messages.
Return value
Type:
Type: BOOL
If a message is available, the return value is nonzero.
If no messages are available, the return value is zero.
Remarks
PeekMessage 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 thewMsgFilterMin and wMsgFilterMax parameters. Note that an application can only use the low word in thewMsgFilterMin and wMsgFilterMax parameters; the high word is reserved for the system.
Note that PeekMessage always retrieves WM_QUIT messages, no matter which values you specify forwMsgFilterMin 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, orSendNotifyMessage 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 wMsgFilterMaxparameters.
The PeekMessage function normally does not remove WM_PAINT messages from the queue. WM_PAINTmessages remain in the queue until they are processed. However, if a WM_PAINT message has a NULLupdate region, PeekMessage does remove it from the queue.
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 an application is being debugged, the system does not generate a ghost window.
Examples
For an example, see Examining a Message Queue.
Requirements
Minimum supported client
Minimum supported server
Header
- Winuser.h (include Windows.h)
Library
- User32.lib
DLL
- User32.dll
Unicode and ANSI names
See also
- Reference
- GetMessage
- IsChild
- MSG
- WaitMessage
- Conceptual
- Messages and Message Queues
- Other Resources
- WaitForInputIdle
Send comments about this topic to Microsoft
Build date: 10/16/2012
- PeekMessage function (Windows)
- Windows 消息处理 - PeekMessage
- PeekMessage Windows API函数
- PeekMessage
- PeekMessage
- peekmessage
- PeekMessage
- PeekMessage()
- PeekMessage
- PeekMessage
- PeekMessage
- PeekMessage
- PeekMessage
- How to Use PeekMessage() Correctly in Windows
- 深入GetMessage,PeekMessage以及Windows消息机制
- windows编程之PeekMessage与Getmessage
- 深入GetMessage,PeekMessage以及Windows消息机制
- HOWTO: How to Use PeekMessage() Correctly in Windows
- 动态修改UINavigationBar背景
- 如何改变Linux文件的属性与权限
- gdb调试讲解,快速入门
- 别让你的IAP轻易被破解
- BoW用于图像检索的一般化流程
- PeekMessage function (Windows)
- Http方法:Get请求与Post请求的区别
- Hdu 3599 War
- struts常量
- webQQ获得群列表、好友列表
- 纯CSS实现侧边栏/分栏高度自动相等
- SQL语句4
- android学习笔记(二) 之 android工程文件分析
- C# WinForm控件开发如何设置属性的默认值