Consider the following scenario:
| • | You design a new Microsoft Visual C# Add-in project for Microsoft Office InfoPath 2007. |
| • | You use the following code example to change the OnConnection event method. This code example also changes the applicationObject definition to
Private ApplicationClass applicationObject;.applicationObject = (ApplicationClass)application;
addInInstance = addInInst;
((ApplicationEventsClass)applicationObject.Events).XDocumentBeforeClose += new _ApplicationEvents_XDocumentBeforeCloseEventHandler(Connect_XDocumentBeforeClose);
|
| • |
You add a method definition that resembles the following code example.void Connect_XDocumentBeforeClose(_XDocument pDocument, ref bool pfCancel)
{
System.Windows.Forms.MessageBox.Show("Connect_XDocumentBeforeClose");
} |
| • | You build and install the new add-in. |
| • | You open the form in InfoPath 2007. |
| • | You exit InfoPath 2007 without first closing the form. |
In this scenario, the
XDocumentBeforeClose event does not occur.
Back to the top
This behavior occurs because the
XDocumentBeforeClose event may prevent InfoPath 2007 to shut down by returning "fCancel=true".
However, if the
XDocumentBeforeClose event is called, the event is ignored, and the returned value may confuse some third-party developers.
Therefore, use the
Application::Quit command if you must perform cleanup tasks related to opened documents.
Back to the top
This behavior is by design.
Back to the top