I have a combobox that I would like to keep a list of all open projects.
Meaning that it would need to be updated when a project opens or closes. I have already implemented the ProjectOpen event, but am having trouble with finding a solution for when a project closes.
Just using the ProjectBeforeCloseEvent will not be enough, because it triggers before the save project popup occurs, and the user might cancel.
At the moment, I am using a combination of the ProjectBeforeCloseEvent and the WindowActivateEvent as a workaround.
However, there is no way to detect whether or not the user cancels the closing of the last open project (Since WindowActivateEvent is never triggered).
I would prefer to not have to use a timer that checks if the project closed or not after a period of time.
Here is my code in case anyone would like to see,
private void _prjApp_WindowActivateEvent(MSP.Window activatedWindow)
{
if (didProjectClose.Item1)
{
DeleteMSPInComboBox(didProjectClose.Item2);
didProjectClose = (false, null);
}
}
private void _prjApp_ProjectBeforeCloseEvent(MSP.Project pj, ref bool cancel)
{
if (cancel == false)
{
didProjectClose = (true, pj.FullName);
}
}