Share via


CWinApp::DoWaitCursor

Questa funzione membro viene chiamata dal framework per implementare CWaitCursor, CCmdTarget::BeginWaitCursor, CCmdTarget::EndWaitCursore CCmdTarget::RestoreWaitCursor.

virtual void DoWaitCursor(
   int nCode 
);

Parametri

  • nCode
    Se questo parametro è 1, un cursore di attesa viene visualizzato.Se 0, il cursore di attesa ripristinata senza incrementare il conteggio dei riferimenti.Se a 1, il cursore di attesa.

Note

L'oggetto predefinito implementa un cursore di clessidra.DoWaitCursor gestisce un conteggio dei riferimenti.Quando il segno positivo, il cursore di clessidra visualizzare.

In genere non si chiama direttamente DoWaitCursor, è possibile eseguire l'override della funzione membro per modificare il cursore di attesa o per eseguire elaborazioni aggiuntive quando il cursore di attesa visualizzare.

Per una procedura più semplice e più semplice di implementare un cursore di attesa, utilizzare CWaitCursor.

Esempio

// The following example shows how to display the
// hourglass cursor during some lengthy processing
void CMdiView::OnLButtonDown(UINT nFlags, CPoint point)
{
   UNREFERENCED_PARAMETER(nFlags);
   UNREFERENCED_PARAMETER(point);

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

   // do some lengthy processing
   Sleep(1000);

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

// The next example shows DoWaitCursor with parameter 0. It restores
// the hourglass cursor.
void CMdiView::OnMButtonDown(UINT nFlags, CPoint point)
{
   UNREFERENCED_PARAMETER(nFlags);
   UNREFERENCED_PARAMETER(point);

   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 (_T("DoWaitCursor Sample"));

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

   // do some more lengthy processing
   Sleep(1000);

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

Requisiti

Header: afxwin.h

Vedere anche

Riferimenti

Classe di CWinApp

Grafico della gerarchia

CCmdTarget::BeginWaitCursor

CCmdTarget::EndWaitCursor

CCmdTarget::RestoreWaitCursor

Classe di CWaitCursor