CDialog::OnCancel

프레임 워크를 클릭할 때이 메서드를 호출 취소 또는 모달 또는 모덜리스 대화 상자에서 ESC 키를 누르는 있습니다.

virtual void OnCancel( );

설명

작업 (예: 이전 데이터 복원)를 수행 하도록이 메서드를 재정의 합니다. 사용자가 닫을 때 대화 상자를 클릭 하 여 취소 또는 ESC 키를 눌러.기본 호출 하 여 모달 대화 상자를 닫습니다 EndDialog 하 고 DoModal IDCANCEL이 반환 합니다.

구현할 클래스는 취소 단추 보다 우선 해야 모덜리스 대화 상자에는 OnCancel 메서드 및 호출 DestroyWindow 안에.호출 되므로 기본 클래스 메서드를 호출 하지 마십시오 EndDialog는 되지만 대화 상자는 보이지 않게 파괴 하지.

[!참고]

사용 하는 경우이 메서드를 재정의할 수 없습니다는 CFileDialog 개체에는 Windows XP에서 컴파일되는 프로그램입니다.CFileDialog에 대한 자세한 내용은 CFileDialog 클래스를 참조하십시오.

예제

void CSimpleDlg::OnCancel()
{
   // TODO: Add extra cleanup here

   // Ensure that you reset all the values back to the
   // ones before modification. This handler is called
   // when the user doesn't want to save the changes.

   if (AfxMessageBox(_T("Are you sure you want to abort the changes?"), 
      MB_YESNO) == IDNO)
   {
      // Give the user a chance if he has unknowingly hit the
      // Cancel button. If he says No, return. Don't reset. If
      // Yes, go ahead and reset the values and close the dialog.
      return; 
   }

   m_nMyValue = m_nPrevValue;
   m_pMyString = NULL; 

   CDialog::OnCancel();
}

요구 사항

Header:afxwin.h

참고 항목

참조

CDialog 클래스

계층 구조 차트

CDialog::OnOK

CDialog::EndDialog