Beispiel #1
0
//=========================================================
// AlphaApp::OnSysCommand - Chapter X, page Y
//
// Handles the WM_SYSCOMMAND message
//
//=========================================================
LRESULT AlphaApp::OnSysCommand(WPARAM wParam, LPARAM lParam)
{
	switch (wParam)
	{
		case SC_MAXIMIZE :
		{
			// If windowed and ready...
			if ( m_bWindowedMode && IsRunning() )
			{
				// Make maximize into FULLSCREEN toggle
				OnAltEnter();
			}
		}
		return 0;

		case SC_CLOSE :
		{
			// The quit dialog confirmation would appear once for
			// every SC_CLOSE we get - which happens multiple times
			// if modal dialogs are up.  This now uses the g_QuitNoPrompt
			// flag to only prompt when receiving a SC_CLOSE that isn't
			// generated by us (identified by g_QuitNoPrompt).
			
			// If closing, prompt to close if this isn't a forced quit
			if ( lParam != g_QuitNoPrompt )
			{
				// ET - 05/21/01 - Bug #1916 - Begin
				// We were receiving multiple close dialogs
				// when closing again ALT-F4 while the close
				// confirmation dialog was up.
				// Eat if already servicing a close
				if ( m_bQuitRequested )
					return true;

				// Wait for the application to be restored
				// before going any further with the new 
				// screen.  Flash until the person selects
				// that they want to restore the game, then
				// reinit the display if fullscreen.  
				// The reinit is necessary otherwise the game
				// will switch to windowed mode.
	
				// Quit requested
				m_bQuitRequested = true;
				// Prompt TODO Fix pop up message
				//if ( MessageBox::Ask(QUESTION_QUIT_GAME) == IDNO )
				//{
				//	// Bail - quit aborted
				//	
				//	// Reset quit requested flag
				//	m_bQuitRequested = false;
				//	
				//	return true;
				//}
			}
	
			m_bQuitting = true;

			// Is there a game modal dialog up?
			if ( HasModalDialog() )
			{
				// Close the modal
				// and keep posting close to the app
				//ForceModalExit(); TODO uncomment when the func is coded

				// Reissue the close to the app
				
				// Issue the new close after handling the current one,
				// but send in g_QuitNoPrompt to differentiate it from a 
				// regular CLOSE issued by the system.
				PostMessage( GetHwnd(), WM_SYSCOMMAND, SC_CLOSE, g_QuitNoPrompt );

				m_bQuitRequested = false;
				
				// Eat the close
				return true;
			}

			// Reset the quit after any other dialogs have popped up from this close
			m_bQuitRequested = false;
		}
		return 0;

		default:
			// return non-zero of we didn't process the SYSCOMMAND message
			return DefWindowProc(GetHwnd(), WM_SYSCOMMAND, wParam, lParam);
	}

	return 0;
}
Beispiel #2
0
LRESULT GameApp::OnSysCommand(WPARAM wParam, LPARAM lParam)
{
	switch (wParam)
	{
	case SC_MAXIMIZE :
		{
			// If windowed and ready...
			if ( m_bWindowedMode && IsRunning() )
			{
				// Make maximize into FULLSCREEN toggle
				OnAltEnter();
			}
		}
		return 0;

	case SC_CLOSE :
		{
			// The quit dialog confirmation would appear once for
			// every SC_CLOSE we get - which happens multiple times
			// if modal dialogs are up.  This now uses the QUIT_NO_PROMPT
			// flag to only prompt when receiving a SC_CLOSE that isn't
			// generated by us (identified by QUIT_NO_PROMPT).

			// If closing, prompt to close if this isn't a forced quit
			if ( lParam != QUIT_NO_PROMPT )
			{
				// ET - 05/21/01 - Bug #1916 - Begin
				// We were receiving multiple close dialogs
				// when closing again ALT-F4 while the close
				// confirmation dialog was up.
				// Eat if already servicing a close
				if ( m_bQuitRequested )
					return true;

				// Wait for the application to be restored
				// before going any further with the new 
				// screen.  Flash until the person selects
				// that they want to restore the game, then
				// reinit the display if fullscreen.  
				// The reinit is necessary otherwise the game
				// will switch to windowed mode.

				// TODO MrMike: Need a message eater, message saver
				//if (postableMessageBacklog.valid())
				//{
				//	postableMessageBacklog->Add( PostableMessage(WM_SYSCOMMAND, wParam, MAKELPARAM(0, 0) ) );
				//	return true;
				//}

				// Quit requested
				m_bQuitRequested = true;

			}

			m_bQuitting = true;


			// Reset the quit after any other dialogs have popped up from this close
			m_bQuitRequested = false;
		}
		return 0;

	default:
		// return non-zero of we didn't process the SYSCOMMAND message
		return DefWindowProc(GetHwnd(), WM_SYSCOMMAND, wParam, lParam);
	}

	return 0;
}