1
votes

What is the MFC equivalent of System.Windows.Forms.CloseReason for a CDialog?

How to capture FormClosing event in MFC CDialog?

2

2 Answers

1
votes

There is no way to distinguish the reason that closed a Dialog, after it is closed. When I look at the list of CloseReasons most of the reasons create different Messages (like shutdown). The only way I see is to implement message handler for the events/situations that are important for you.

Note: That some of the CloseReasons don't make sense for a modal Dialog in an MFC application (like FormOwnerClosing)...

0
votes

CDialog::DoModal returns a value, depending on how it is closed (could be IDOK, IDCANCEL or other value - see this reference: http://msdn.microsoft.com/en-us/library/619z63f5%28v=vs.90%29.aspx).

You can use various messages from the dialog to tell when it is closing - OnCancel (http://msdn.microsoft.com/en-us/library/kw3wtttf%28v=vs.90%29.aspx) or OnOK (http://msdn.microsoft.com/en-us/library/66b3y2ab%28v=vs.90%29.aspx) being a couple of the more interesting ones.