INFO: GetInputState Is Faster Than GetMessage() or PeekMessage() (35605)
The information in this article applies to:
- Microsoft Platform Software Development Kit (SDK) 1.0
- Microsoft Windows Software Development Kit (SDK) 3.0
- Microsoft Windows Software Development Kit (SDK) 3.1
This article was previously published under Q35605 SUMMARY
This article describes a method to quickly determine whether an
application for the Microsoft Windows graphical environment has any
keyboard or mouse messages in its queue without calling the GetMessage
or PeekMessage functions.
NOTE: In Win32, GetInputState is thread-local only.
MORE INFORMATION
The GetInputState function returns this information more quickly than
GetMessage or PeekMessage. GetInputState returns TRUE (nonzero) if
either a keyboard or mouse message is in the application's input
queue. If the application must distinguish between a mouse and a
keyboard message, GetInputState returns the value 2 for a keyboard and
the value 1024 for a mouse message.
Because difficulties may arise if the application loses the input
focus, use GetInputState only in tight loop conditions where execution
speed is critical.
In Win32, message queues are not global as they are in 16-bit Windows. The
message queues are local to the thread. When you call GetInputState, you
are checking to see if there are mouse or keyboard messages for the calling
thread only. If a window created by another thread in the application has
the keyboard input waiting, GetInputState will not be able to check for
those messages.
Modification Type: | Minor | Last Reviewed: | 7/11/2005 |
---|
Keywords: | kbinfo kbWndw KB35605 |
---|
|