다음을 통해 공유


CCmdTarget::BeginWaitCursor

명령을 실행 하는 시간이 간격을 원하는 경우 커서를 모래 시계 모양으로 표시 하려면이 함수를 호출 합니다.

void BeginWaitCursor( );

설명

프레임 워크에서 호출 하는 경우 처럼 약속 있음을 사용자에 게 표시 하려면이 함수는 CDocument 개체를 로드 하거나 자체를 파일에 저장 합니다.

작업의 BeginWaitCursor 항상 다른 작업으로 같은 메시지를 단일 처리기 외부에서 적용 됩니다 OnSetCursor 커서 처리를 변경할 수 있습니다.

호출 EndWaitCursor 이전 커서를 복원 합니다.

예제

// The following example illustrates the most common case 
// of displaying the hourglass cursor during some lengthy 
// processing of a command handler implemented in some 
// CCmdTarget-derived class, such as a document or view. 
void CMyView::OnBeginSleepEnd()
{
   BeginWaitCursor(); // display the hourglass cursor 
   // do some lengthy processing
   Sleep(3000);
   EndWaitCursor(); // remove the hourglass cursor
}

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

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

// If the dialog is invoked from a member function of 
// some non-CCmdTarget, then you can call CWinApp::DoWaitCursor 
// with a 0 parameter value to restore the hourglass cursor. 
void CMyObject::OnDlgDoWait()
{
   CFileDialog dlg(TRUE);
   dlg.DoModal();
   AfxGetApp()->DoWaitCursor(0); // same as CCmdTarget::RestoreWaitCursor   
}

요구 사항

헤더: afxwin.h

참고 항목

참조

CCmdTarget 클래스

계층 구조 차트

CWaitCursor 클래스

CCmdTarget::EndWaitCursor

CCmdTarget::RestoreWaitCursor

CWinApp::DoWaitCursor