Game Development Reference
In-Depth Information
{
FlashWindow( GetHwnd(), false );
break;
}
}
else
{
now = timeGetTime();
DWORD timeSpan = now > then ? (now - then) : (then - now);
if ( timeSpan > 1000 )
{
then = now;
FlashWindow( GetHwnd(), true );
}
}
}
}
}
Doing this is a little tricky. You basically have to run your own message pump in a
tight loop and swallow the
WM_SYSCOMMAND
and
SC_CLOSE
messages until your
game isn
'
t minimized anymore, all the while calling
FlashWindow()
at regular time
intervals.
When your game is closed by something external, such as a power down due to a low
battery condition, you might have some tricky cleanup to do if you are inside one of
your modal dialogs we
'
ll be discussing in Chapter 9,
“
Programming Input Devices.
”
Since you are running a special version of the message pump, the
“
real
”
message
pump won
t get the message.
The solution lies in forcing the modal dialog to close with its default answer and then
resending the
WM_SYSCOMMAND
with the
SC_CLOSE
parameter back into the message
pump. If you happen to have nested dialogs up, this will still work because each dia-
log will get a forced close until the normal message pump can process the close
message.
Here
'
'
s the pseudo-code for the code inside the
SC_CLOSE
message handler:
If (you want to prompt the user)
{
If (m_bQuitRequested)
Return early
-
user is spamming Alt-F4