我有一個繼承自CPropertyPage類的類。我有一個OnOk()方法和一個OnKillActive()方法。 每當我按下對話框上的確定。 OnKillActive()被調用,但OnOk()永遠不會被調用。 問題取決於條件,我不想按Ok鍵關閉對話框。但是按下Ok進行對話。CPropertyPage對話如果出現錯誤,OnOk不應該關閉對話框
當我按下OK時,如何防止對話結束?
代碼:
In MyClass.h:
class MyClass : public CPropertyPage {
}
In MyClass.cpp:
void MyClass::OnOK(){
if (condition true) {
return; // This should prevent the dialogue from closing but still the dialogue closes
}
return CPropertyPage::OnOk();
}
BOOL MyClass::OnKillActive() {
if (condition true) {
CDialog::DoModal();
return FALSE; // This should prevent the dialogue from closing but still the dialogue closes
}
return CPropertyPage::OnKillActive();
}