Reputation: 10660
I have a custom task pane and now I am trying to catch the close event of the custom task pane. I have seen that there is no such event, instead there is the VisibleChanged event with does exactly the same, it is raised when visibility changes or it is closed.
When user clicks on close button or select close from the context menu, I would like to display a messagebox saying it is not permitted to close it and not allow user to close it.
I have seen an approach here or this user a thread but this is causing flickering when showing it again (you can see that it is hidden and then make visible again quickly). Is there any other way to achieve this? Also where is the best place in those approaches to show the messagebox?
Upvotes: 0
Views: 235
Reputation: 49453
Custom task panes don't provide any event which is fired when the pane is about to close. There is no trivial way to get the job done, you need to implement workarounds described on forum threads. Also you may consider using Advanced Outlook view and form regions instead.
Note, Outlook form regions provide the following events out of the box:
Event | Description |
---|---|
FormRegionInitializing | Occurs before the form region is initialized. You can check conditions in this event handler to determine whether Outlook should display the form region. For more information, see How to: Prevent Outlook from displaying a form region. |
FormRegionShowing | Occurs after an instance of the form region is created but before the form region appears. |
FormRegionClosed | Occurs before the form region is closed. |
Upvotes: 1