1
votes

My dialog box derives from CPropertyPage.

I've overridden OnOK() in order to run some custom checks. However, it seems that Dynamic Data Exchange (DDX) has already completed and my class variables have already been updated when my handler gets called.

I thought DDX happens when I call CPropertyPage::OnOK(), which I'm doing at the end of my handler.

In addition, if my code decides the dialog box should not close and returns without calling CPropertyPage::OkOK(), the dialog still closes!

How can I run my custom checks before DDX has updated my class variables?

P.S. It doesn't appear that the MFC source code is installed by default any longer, and none of the install options mention the MFC source code. After Googling, I found a couple of options mentioned. I checked them and I still don't have the MFC source code.

1
These sorts of checks are (IIRC) run by an overridden DoDataExchange. Is that what you're looking for?1201ProgramAlarm
@1201ProgramAlarm: This check is more complicated. I'm comparing the selected value to another and then I'm seeing if the value exists within a list of values. Would be much simpler if I could just write code in OnOK().Jonathan Wood

1 Answers

2
votes

CPropertyPage::OnOK() doesn't do the same thing as CDialogEx::OnOK().

Property pages should override CPropertyPage::OnKillActive() instead. This method allows me to perform custom validation and return FALSE without calling CPropertyPage::OnKillActive() to prevent the dialog box from closing, or switching to another tab.