Can closing file be canceled?

I tried to prevent user closing dgn file if a certain task hasn't been finished using C#.

Is there an event handler on file closing and some parameter can be set so that the closing action can be canceled?

Gang

Parents Reply
  • Hi Gang,

    Unknown said:
    I didn't find the exact place for handling the closing event.

    In you addin inherited from Addin class a delegate NewDesignFileEventHandler exists, so in e.g. Run method use:

    this.NewDesignFileEvent += UDialog_NewDesignFileEvent;

    and the method should be like this:

    void UDialog_NewDesignFileEvent(Bentley.MicroStation.AddIn sender, Bentley.MicroStation.AddIn.NewDesignFileEventArgs eventArgs)
    {
        if (eventArgs.WhenCode == NewDesignFileEventArgs.When.BeforeDesignFileClose)
        {
            // do what you need here
        }
    }

    The problem is you can use this code to monitor that the file will be closed but there is no a way (I am not aware about any) how to close the running closing process from the method. Maybe somebody else know how to do it.

    But in general existing NET API (which is VBA/COM API) is not the good tool for such close integration with MicroStation and as Robert wrote, C MDL API or C++ MicroStationAPI provide more options.

    With regards,

      Jan

Children