MFC
CXTPPropertyPage OK 버튼 누르고 종료 여부 체크 방법
leo21c
2022. 7. 15. 18:55
https://docs.microsoft.com/en-us/cpp/mfc/reference/cpropertypage-class?view=msvc-170
CPropertyPage Class
Learn more about: CPropertyPage Class
docs.microsoft.com
MSDN을 참고하면 된다.
간단하게 설명하면 OK, Cancel 버튼을 누렀을 때 아래 함수가 각각 순서대로 호출이 된다.
먼저 OK버튼을 눌렀을 경우이다.
int nCompare = 1;
// The default MFC implementation of OnApply() would call OnOK().
BOOL CColorPage::OnApply()
{
if (nCompare == 2) return FALSE;//cancel OK commnad
return CPropertyPage::OnApply();
}
// After OnApply()
void CColorPage::OnOK()
{
CPropertyPage::OnOK();
}
OK 버튼을 누르면 먼저 OnApply()함수가 호출이 된다. 이곳에서 OK를 진행할지 여부를 체크한다. 위의 예제에서는 nCompare가 2인지 여부를 체크하고 2이면 OK를 취소한다.
virtual BOOL OnQueryCancel(); 함수는 OnCancel() 함수 호출 전에 불려진다.
따라서 Cancel 여부도 OnQueryCancel() 함수에서 return FALSE를 하면 처리되지 않는다.
LIST