共用方式為


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
}

需求

Header: afxwin.h

請參閱

參考

CWinApp 類別

階層架構圖

CCmdTarget::BeginWaitCursor

CCmdTarget::EndWaitCursor

CCmdTarget::RestoreWaitCursor

CWaitCursor 類別