I’m working on a game where the client needs to continue processing windows messages or else the game can be exploited. In order to solve this problem during window re-size and drag events, we have a WM_TIMER message that fires every 50ms which will restart the main event loop.
The problem is that this technique is not working when a user clicks and holds over the X or minimize button of a windowed client. (So they don’t complete the click, they just halt the client.)
Using Spy++, the last messages I see are:
<00731> 00160D3C P WM_NCLBUTTONDOWN nHittest:HTCLOSE xPos:1150 yPos:178
<00732> 00160D3C P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:1014 yPos:-23
Followed by nothing until I move the mouse, and no WM_TIMER messages until I let go the mouse button.
So the question is, while I’m in the state of having my mouse down over the window’s X button is there something I could key off of to get the client moving again? Or something I could do so our “watchdog” WM_TIMER messages fire?
Some system events such as system menu (as in your case) or window resizing stop regular window messages from being processed for a while. You need to re-think your architecture and maybe run a periodical operation in a secondary thread. There you can use WaitForSingleObject or just Sleep() instead of message-based timer.