다음을 통해 공유


CWaitCursor::CWaitCursor

대기 커서를 표시 하려면 방금 선언 된 CWaitCursor 개체 코드 긴 작업을 수행 하기 전에.

CWaitCursor( );

설명

생성자는 자동으로 대기 커서가 표시 됩니다.

개체가 범위를 벗어날 때 (블록의 끝에는 CWaitCursor 개체 선언), 소멸자가 이전 커서에 커서를 설정 합니다.즉, 개체는 자동으로 필요한 정리를 수행합니다.

소멸자 (함수 끝 전에 수)는 블록의 끝에 대기 커서 함수 부분에만 사용 하 라고는 팩트를 활용할 수 있습니다.이 기술은 아래의 두 번째 예제에 나와 있습니다.

[!참고]

생성자 및 소멸자의 작동 방법, 때문에 CWaitCursor 개체는 항상 로컬 변수로 선언-전역 변수를 선언 하지는 않으며 할당 된 .

예제

// The following example illustrates the most common case
// of displaying the wait cursor during some lengthy
// processing.
void LengthyFunction()
{
   // perhaps you display a dialog box before displaying a
   // wait cursor

   CWaitCursor wait;   // display wait cursor

   // do some lengthy processing
   Sleep(1000);

}  // destructor automatically removes the wait cursor

// This example shows using a CWaitCursor object inside a block
// so the wait cursor is displayed only while the program is
// performing a lengthy operation.
void ConditionalFunction()
{
   if (SomeCondition)
   {
      CWaitCursor wait;   // display wait cursor in this block only

      // do some lengthy processing
      Sleep(1000);

   }  // at this point, the destructor removes the wait cursor
   else
   {
      // no wait cursor--only quick processing
   }
}

요구 사항

헤더: afxwin.h

참고 항목

참조

CWaitCursor 클래스

계층 구조 차트

CWaitCursor::Restore

CCmdTarget::BeginWaitCursor

CCmdTarget::EndWaitCursor