.netautocad

AutoCAD .NET API - Interrupting the close pallete/window/user control command


I'm developing my own user controls for AutoCAD 2011 and cant for the life of me figure out how to interrupt the close on the User Control and insert my own functions before carrying on with the close.

Just for clarity here is a capture.

Basically before the window closes I need to clear a few of my own layers hidden behind the model space, because if the user can just close the tool and carry on without performing the wipe its going to cause issues eventually when it comes to adding new objects/saving/etc. I certainly cant trust a user to click a "Wipe" button on the UC before exiting, that's just asking for trouble.

So my question is: Where am I looking in the API for the code that closes the user control?


Solution

  • Acad palettes are not actually closed (disposed) when you click on the 'X' mark. They are just hidden. You might want to try the PaletteState::StateChanged event. It might be triggered when you 'close' the palette set. Just register a delegate for that event and see if it is called. Might work.

    * EDIT * Now that I think more about it, you should be able to catch that event by registering a delegate to the Control.VisibleChanged event of your custom control. The one that you add as a child to the PaletteSet. That should work.