次の方法で共有


CWinApp::DoWaitCursor

このメンバー関数は、フレームワークによって CWaitCursorCCmdTarget::BeginWaitCursorCCmdTarget::EndWaitCursorCCmdTarget::RestoreWaitCursorを実行するために呼び出されます。

virtual void DoWaitCursor( 
   int nCode  
);

パラメーター

  • nCode
    このパラメーターが 1 の場合、待機カーソルが表示されます。 0 が参照カウントをインクリメントすることなく、待機カーソル復元する場合は。 – 1 は、待機カーソル終了します。

解説

既定値は砂時計カーソルを実装します。 DoWaitCursor は、参照カウントを保持します。 肯定、砂時計カーソルが表示されます。

通常 DoWaitCursor を直接呼び出していませんが、待機カーソルを表示したまま、待機カーソルを変更または追加の処理を実行するには、このメンバー関数をオーバーライドできます。

待機カーソルを実装するよりも簡単で効率的な方法で CWaitCursorを使用します。

使用例

// 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
}

必要条件

ヘッダー: afxwin.h

参照

関連項目

CWinApp クラス

階層図

CCmdTarget::BeginWaitCursor

CCmdTarget::EndWaitCursor

CCmdTarget::RestoreWaitCursor

CWaitCursor クラス