AnsweredAssumed Answered

Why can't FileCloseNotify fire when a swDoc Close

Question asked by Lenny Yang on May 9, 2019
Latest reply on May 10, 2019 by Lenny Yang

Hello Friend,

         I add a FileCloseNotify in my program,but it can't be trigger when I close a swDoc such as swPart or swAssembly.

         For testing,I also add another notify such as "ActiveDocChangeNotify", it can be trigger correctly.

        why????


Here is the code.This is just to make it easy to check if the code is correct.If you need to test my program on your computer, please download the attachment.

C# code=====================================================

private bool AttachSwEvents()
{
try
{
SwEventPtr.ActiveDocChangeNotify += new DSldWorksEvents_ActiveDocChangeNotifyEventHandler(OnDocChange);
SwEventPtr.FileCloseNotify += new DSldWorksEvents_FileCloseNotifyEventHandler(FileCloseNotify);
return true;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return false;
}
}

 

private bool DetachSwEvents()
{
try
{
SwEventPtr.ActiveDocChangeNotify -= new DSldWorksEvents_ActiveDocChangeNotifyEventHandler(OnDocChange);
SwEventPtr.FileCloseNotify -= new DSldWorksEvents_FileCloseNotifyEventHandler(FileCloseNotify);
return true;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return false;
}

}

 

public int OnDocChange()
{
return 0;
}

public int FileCloseNotify(string FileName, int reason)
{
return 0;
}

C# code=====================================================

Outcomes