Recommended Posts

In my game, key messages are send by windows to my window-procedure. This can affect the fps of the game, cause the game checks first if there are any messages and handles them. But in the game procedure, i handle my own key messages.
Is there a way to disallow (disable) windows from sending those key messages? (VK_*)
Gerben VV

0

Share this post

Link to post

Share on other sites

Advertisement

Guest Anonymous Poster

Not really. If they are affecting the performance of your game noticably, though, you're doing something very, very, very wrong somewhere in your code. Perhaps if you described your game loop in detail or posted some code, others could help you fix the bug.-Extrarius

0

Share this post

Link to post

Share on other sites

Yes, there is. The last two parameters of GetMessage () function are used to specified the range between allowed messages.But IMO, there're tons of messages are sent to your window and most of them are processed by DefWindowProc (), you should let Windows do the work for you, even if you want to disable some messages, the nunmber of remaining messages is still huge in comparison to these disabled ones.

Share this post

Link to post

Share on other sites

Guest Anonymous Poster

What happens to messages you don't process in such a way? I doubt windows discards them because you might later have another call to GetMessage/PeekMessage that processes those messages. As far as I can tell, MSDN doesn't specify what happens to messages filtered out by the two parameters given.

Likely, such a method will cause messages to build up in a buffer and eventually you'll probably get very strange errors once the message buffer is filled (if it is a fixed size). Alternately, if the buffer is growable, you might have what appears to be a memory leak as more and more memory is used to buffer unprocessed messages.

At the very least, you should have a PeekMessage that will catch messages from 0 to one less than the lowest you process, and another PeekMessage from the highest+1 you process to the maximum value (0xFFFF because you can only pass in a single word for each value) to discard messages that you don't process. This could be dangerous, though, since you have no idea what important messages you might be discarding.

I did some mouse and keyboard inputs while in the WindowProc () I still processed these messages, apparently I got nothing. Then after clicking the close button, a message box showed up then the app exited, doesn't that mean no messages are buffered ?.

But as Extrarius mentioned, these kind of 'optimizations' make no sense even in a very small app. I just gave you a way to do this, this shouldn't be implemented.

V@T

0

Share this post

Link to post

Share on other sites

Guest Anonymous Poster

Your typical PC does a couple hundred million things per second. Even with key repeat rate cranked all the way up, the rate at which key messages come into your app is analogous to the passing of Halley's Comet. This is really a very silly optimization.