예제 #1
0
int CRadiantApp::Run( void ) {
	BOOL bIdle = TRUE;
	LONG lIdleCount = 0;
#if _MSC_VER >= 1300
	MSG *msg = AfxGetCurrentMessage();			// TODO Robert fix me!!
#else
	MSG *msg = &m_msgCur;
#endif
	// phase1: check to see if we can do idle work
	while( bIdle &&	!::PeekMessage( msg, NULL, NULL, NULL, PM_NOREMOVE ) ) {
		// call OnIdle while in bIdle state
		if( !OnIdle( lIdleCount++ ) ) {
			bIdle = FALSE; // assume "no idle" state
		}
	}
	// phase2: pump messages while available
	do {
		// pump message, but quit on WM_QUIT
		if( !PumpMessage() ) {
			return ExitInstance();
		}
		// reset "no idle" state after pumping "normal" message
		if( IsIdleMessage( msg ) ) {
			bIdle = TRUE;
			lIdleCount = 0;
		}
	} while( ::PeekMessage( msg, NULL, NULL, NULL, PM_NOREMOVE ) );
	return 0;
}
예제 #2
0
/**
* Called every frame by the doom engine to allow the material editor to process messages.
*/
void MaterialEditorRun( void ) {

	MSG *msg = AfxGetCurrentMessage();

	while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
		// pump message
		if ( !AfxGetApp()->PumpMessage() ) {
		}
	}
}
/*
================
ScriptEditorRun
================
*/
void ScriptEditorRun( void ) {
#if _MSC_VER >= 1300
	MSG *msg = AfxGetCurrentMessage();			// TODO Robert fix me!!
#else
	MSG *msg = &m_msgCur;
#endif
	while( ::PeekMessage( msg, NULL, NULL, NULL, PM_NOREMOVE ) ) {
		// pump message
		if( !AfxGetApp()->PumpMessage() ) {
		}
	}
}
예제 #4
0
bool CWaitDlg::CancelPressed( void ) {
#if _MSC_VER >= 1300
	MSG *msg = AfxGetCurrentMessage();			// TODO Robert fix me!!
#else
	MSG *msg = &m_msgCur;
#endif

	while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
		// pump message
		if ( !AfxGetApp()->PumpMessage() ) {
		}
	}

	return cancelPressed;
}
예제 #5
0
/**
* Called every frame by the doom engine to allow the material editor to process messages.
*/
void MaterialEditorRun( void ) {
	MSG *msg = AfxGetCurrentMessage();
	BOOL bDoingBackgroundProcessing = TRUE;
	while( bDoingBackgroundProcessing ) {
		while( ::PeekMessage( msg, NULL, NULL, NULL, PM_NOREMOVE ) ) {
			// pump message
			if( !AfxGetApp()->PumpMessage() ) {
				bDoingBackgroundProcessing = FALSE;
				::PostQuitMessage( 0 );
				break;
			}
		}
		// let MFC do its idle processing
		LONG lIdle = 0;
		while( AfxGetApp()->OnIdle( lIdle++ ) );
	}
}
예제 #6
0
/*
================
AFEditorRun
================
*/
void AFEditorRun( void ) {
#if _MSC_VER >= 1300
	MSG *msg = AfxGetCurrentMessage();			// TODO Robert fix me!!
#else
	MSG *msg = &m_msgCur;
#endif
	BOOL bDoingBackgroundProcessing = TRUE;
	while( bDoingBackgroundProcessing ) {
		while( ::PeekMessage( msg, NULL, NULL, NULL, PM_NOREMOVE ) ) {
			// pump message
			if( !AfxGetApp()->PumpMessage() ) {
				bDoingBackgroundProcessing = FALSE;
				::PostQuitMessage( 0 );
				break;
			}
		}
		// let MFC do its idle processing
		LONG lIdle = 0;
		while( AfxGetApp()->OnIdle( lIdle++ ) );
	}
}
예제 #7
0
/*
			等待5秒
*/
int CHTMLViewCapView::RunModalLoop(DWORD dwFlags)
{
			ASSERT(::IsWindow(m_hWnd)); // window must be created
			ASSERT(!(m_nFlags & WF_MODALLOOP)); // window must not already be in modal state

			// for tracking the idle time state
			BOOL bIdle = TRUE;
			LONG lIdleCount = 0;
			BOOL bShowIdle = (dwFlags & MLF_SHOWONIDLE) && !(GetStyle() & WS_VISIBLE);
			HWND hWndParent = ::GetParent(m_hWnd);
			m_nFlags |= (WF_MODALLOOP|WF_CONTINUEMODAL);
			MSG *pMsg = AfxGetCurrentMessage();

			// acquire and dispatch messages until the modal state is done
			for (;;)
			{
				ASSERT(ContinueModal());

				// phase1: check to see if we can do idle work
				while (bIdle &&
					!::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE))
				{
					ASSERT(ContinueModal());

					// show the dialog when the message queue goes idle
					if (bShowIdle)
					{
						ShowWindow(SW_SHOWNORMAL);
						UpdateWindow();
						bShowIdle = FALSE;
					}

					// call OnIdle while in bIdle state
					if (!(dwFlags & MLF_NOIDLEMSG) && hWndParent != NULL && lIdleCount == 0)
					{
						// send WM_ENTERIDLE to the parent
						::SendMessage(hWndParent, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)m_hWnd);
					}
					if ((dwFlags & MLF_NOKICKIDLE) ||
						!SendMessage(WM_KICKIDLE, MSGF_DIALOGBOX, lIdleCount++))
					{
						// stop idle processing next time
						bIdle = FALSE;
					}
				}

				// Get current time
				//CTime tBeginLoop;
				CTime tEndLoop;
				CTimeSpan span;
				BOOL bQuit = FALSE;

				// phase2: pump messages while available
				do
				{
					ASSERT(ContinueModal());
					TRACE("pump messages!\n");

					//
					//tBeginLoop = CTime::GetCurrentTime();

					// pump message, but quit on WM_QUIT
					if (!AfxPumpMessage())
					{
						AfxPostQuitMessage(0);
						return -1;
					}

					// show the window when certain special messages rec'd
					if (bShowIdle &&
						(pMsg->message == 0x118 || pMsg->message == WM_SYSKEYDOWN))
					{
						ShowWindow(SW_SHOWNORMAL);
						UpdateWindow();
						bShowIdle = FALSE;
					}

					if (!ContinueModal() || bQuit)
						goto ExitModal;

					// reset "no idle" state after pumping "normal" message
					if (AfxIsIdleMessage(pMsg))
					{
						bIdle = TRUE;
						lIdleCount = 0;
					}

					tEndLoop = CTime::GetCurrentTime();
					span =  tEndLoop - m_tBeforeEnterLoop;
					TRACE("Span : %d .\n", span.GetTotalSeconds());
					if (span.GetTotalSeconds() >= m_wating_time_max)
					{
						bQuit = TRUE;
					}

				} while (::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE));
			}

		ExitModal:
			m_nFlags &= ~(WF_MODALLOOP|WF_CONTINUEMODAL);
			return m_nModalResult;
}