Ejemplo n.º 1
0
DWORD CThread::DestroyThread(BOOL bQueue)
{
	MSG  sMsg;
	DWORD  dwExitCode;

	if (IsThreadActive())
	{
		for (SetEvent(m_hObject), PostThreadMessage(WM_QUIT, 0, 0); GetThreadID() != GetCurrentThreadId() && ((!bQueue && WaitForSingleObject(m_hThread, INFINITE)) || (bQueue && MsgWaitForMultipleObjects(1, &m_hThread, FALSE, INFINITE, QS_PAINT | QS_TIMER | QS_POSTMESSAGE | QS_SENDMESSAGE) == WAIT_OBJECT_0 + 1)); )
		{
			if (PeekMessage(&sMsg, (HWND)NULL, 0, 0, PM_QS_PAINT | PM_QS_POSTMESSAGE | PM_QS_SENDMESSAGE | PM_REMOVE))
			{
				if (!AfxPreTranslateMessage(&sMsg))
				{
					TranslateMessage(&sMsg);
					DispatchMessage(&sMsg);
				}
			}
			RestoreWaitCursor();
		}
		dwExitCode = GetThreadStatus();
		CloseHandle(m_hThread);
		CommonConstruct();
		m_bAutoDelete = 0;
		return dwExitCode;
	}
	return 0;
}
Ejemplo n.º 2
0
BOOL CMainFrame::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) {
	if (_wait_cursor)	{
		RestoreWaitCursor();
		return TRUE;
	}
	return CFrameWnd::OnSetCursor(pWnd, nHitTest, message);
}
Ejemplo n.º 3
0
// In the above example, the dialog was clearly invoked between
// the pair of calls to BeginWaitCursor and EndWaitCursor.
// Sometimes it may not be clear whether the dialog is invoked 
// in between a pair of calls to BeginWaitCursor and EndWaitCursor.
// It is permissable to call RestoreWaitCursor, even if 
// BeginWaitCursor was not previously called.  This case is 
// illustrated below, where CMyView::AnotherFunction does not
// need to know whether it was called in the context of an
// hourglass cursor.
void CMyView::OnDlgRestore()
{
   // some processing ...
   CFileDialog dlg(TRUE);
   dlg.DoModal();
   RestoreWaitCursor();

   // some more processing ...
}
Ejemplo n.º 4
0
void InformApp::RunMessagePump(void)
{
  LONG count = 0;
  while (OnIdle(count++));

  MSG msg;
  while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  {
    if (msg.message == WM_COMMAND)
      ::PeekMessage(&msg,NULL,0,0,PM_REMOVE);
    else if (PumpMessage() == FALSE)
      exit(ExitInstance());
  }

  if (IsWaitCursor())
    RestoreWaitCursor();
}
Ejemplo n.º 5
0
// The next example illustrates RestoreWaitCursor.
void CMyView::OnBeginDlgRestore()
{
   BeginWaitCursor(); // display the hourglass cursor
   // do some lengthy processing
   // The dialog box will normally change the cursor to
   // the standard arrow cursor, and leave the cursor in
   // as the standard arrow cursor when the dialog box is
   // closed.
   CFileDialog dlg(TRUE);
   dlg.DoModal();

   // It is necessary to call RestoreWaitCursor here in order
   // to change the cursor back to the hourglass cursor.
   RestoreWaitCursor();
   // do some more lengthy processing
   Sleep(3000);
   EndWaitCursor(); // remove the hourglass cursor
}