Link to home
Start Free TrialLog in
Avatar of ehandojo
ehandojo

asked on

How to add confirmation message box when a Dialog's CANCEL button is pressed

How can I add a confirmation message box when a CANCEL button of a dialog box is pressed ?
Where should I create the confirmation message box. The confirmation message box will have a Yes and No button.
If the No button is selected then I don't want to close the dialog box. If the Yes button is selected then I want to continue closing of the dialog box.
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ehandojo
ehandojo

ASKER

Thanks for the answer. Why can't I do the same thing for a CPropertyPage derived class used in CPropertySheet as a wizard ?
I tried to override the OnCancel virtual function on my CPropertyPage derived class and add a confirmation message box, but either Yes and No answer will still close the wizard.
That is different. CPropertyPage is derived from CDialog, but CPropertyPage is integrated into CPropertySheet and the close operation is done by CPropertySheet. In this case, override CPropertyPage::OnQueryCancel().

CPropertyPage::OnQueryCancel
virtual BOOL OnQueryCancel( );

Return Value

Returns FALSE to prevent the cancel operation or TRUE to allow it.

Remarks

This member function is called by the framework when the user clicks the Cancel button and before the cancel action has taken place.

Override this member function to specify an action the program takes when the user clicks the Cancel button.

The default implementation of OnQueryCancel returns TRUE.


thank you for the answer.