Export (0) Print
Expand All
MFC
Expand Minimize

CWinApp::DoWaitCursor 

This member function is called by the framework to implement CWaitCursor, CCmdTarget::BeginWaitCursor, CCmdTarget::EndWaitCursor, and CCmdTarget::RestoreWaitCursor.


virtual void DoWaitCursor(
   int nCode 
);

Parameters

nCode

If this parameter is 1, a wait cursor appears. If 0, the wait cursor is restored without incrementing the reference count. If –1, the wait cursor ends.

The default implements an hourglass cursor. DoWaitCursor maintains a reference count. When positive, the hourglass cursor is displayed.

While you would not normally call DoWaitCursor directly, you could override this member function to change the wait cursor or to do additional processing while the wait cursor is displayed.

For an easier, more streamlined way to implement a wait cursor, use CWaitCursor.

// The following example shows how to display the
// hourglass cursor during some lengthy processing

void CMyApp::OnLButtonDown()
{
   AfxGetApp()->DoWaitCursor(1); // 1->>display the hourglass cursor

   // do some lengthy processing

   AfxGetApp()->DoWaitCursor(-1); // -1->>remove the hourglass cursor
}

// The next example shows DoWaitCursor with parameter 0. It restores
// the hourglass cursor.

void CMyApp::OnLButtonDown()
{
   AfxGetApp()->DoWaitCursor(1); // display the hourglass cursor

   // do some lengthy processing

   // The message box will normally change the cursor to
   // the standard arrow cursor, and leave the cursor in
   // as the standard arrow cursor when the message box is
   // closed.
   AfxMessageBox ("DoWaitCursor Sample");

   // Call DoWaitCursor with parameter 0 to restore
   // the cursor back to the hourglass cursor.
   AfxGetApp()->DoWaitCursor(0);

   // do some more lengthy processing

   AfxGetApp()->DoWaitCursor(-1); // remove the hourglass cursor
}

Community Additions

ADD
Show:
© 2014 Microsoft