Game Development Reference
In-Depth Information
to quit, nothing is keeping them from hitting Alt-F4 again. If your players are like the
folks at Microsoft ' s test labs, they ' ll hit it about 50 times. Your game is still pumping
messages, so the WM_SYSCOMMAND will get through every time a player presses Alt-
F4. Make sure you handle that by filtering it out.
If your game is minimized, you have to do something to catch the player
'
s attention.
If your game runs in full-screen mode and you
ve tabbed away to another app, your
game will act just as if it is minimized. If your player uses the system menu by right-
clicking on the game in the Start bar, your game should exhibit standard Windows
behavior and flash. This is what well-behaved Windows applications do when they
are minimized but require some attention from a human being.
'
void GameCodeApp::FlashWhileMinimized()
{
// Flash the application on the taskbar
// until it
s restored.
if ( ! GetHwnd() )
return;
'
// Blink the application if we are minimized,
// waiting until we are no longer minimized
if (IsIconic(GetHwnd()) )
{
// Make sure the app is up when creating a new screen
// this should be the case most of the time, but when
// we close the app down, minimized, and a confirmation
// dialog appears, we need to restore
DWORD now = timeGetTime();
DWORD then = now;
MSG msg;
FlashWindow( GetHwnd(), true );
while (true)
{
if ( PeekMessage( &msg, NULL, 0, 0, 0 ) )
{
jj
if ( msg.message != WM_SYSCOMMAND
msg.wParam != SC_CLOSE )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Are we done?
if ( ! IsIconic(GetHwnd()) )
Search WWH ::




Custom Search