I have VSPackagewith a dockable tool window containing form data. If there are unsaved changes in this form, I would like to cancel closing the tool window and the IDE visual studio if the user clicks the "Cancel" button when saving changes before closing. I can run a save test on close, but I don't see any event handler methods or other parameters to actually close the close.
Below is a snippet from the package:
private DTE2 _applicationObject = null;
public DTE2 ApplicationObject
{
get
{
if (_applicationObject == null)
{
DTE dte = (DTE)GetService(typeof(DTE));
_applicationObject = dte as DTE2;
}
return _applicationObject;
}
}
protected override void Initialize()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
base.Initialize();
if (ApplicationObject != null)
{
PackageWindowEvents = (WindowEvents)ApplicationObject.Events.get_WindowEvents(null);
PackageWindowEvents.WindowClosing += new _dispWindowEvents_WindowClosingEventHandler(PackageWindowEvents_WindowClosing);
PackageSolutionEvents = ApplicationObject.Events.SolutionEvents;
PackageSolutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(CheckOpenCurrentSolution);
PackageDTEEvents = ApplicationObject.Events.DTEEvents;
PackageDTEEvents.OnBeginShutdown += new _dispDTEEvents_OnBeginShutdownEventHandler(HandleVisualStudioShutdown);
}
}
void PackageWindowEvents_WindowClosing(Window window)
{
}
And some commercials from ToolWindowPanethat implement IVsWindowFrameNotify3:
protected override void OnClose()
{
base.OnClose();
}
public int OnClose(ref uint pgrfSaveOptions)
{
return (int)__FRAMECLOSE.FRAMECLOSE_PromptSave;
}
OnClose WindowClosing , . ? , ?