Reputation: 1
I'm creating an Add-In for Outlook in C# with VSTO.
Before sending a MailItem some special tasks will be done within the send-event. While this tasks are done, a modal form with a progress bar will be shown. That works fine. But while the progress bar is shown, the user cannot interact with Outlook. Whole Outlook is frozen. -> I want that the user can interact with Outlook while the tasks are done on the MailItem to be send.
So I created a new thread for the special tasks including showing the progress bar. Following steps will be done in the send-event:
Check a bool variable if the tasks were already done.
This also works fine. But then the modal form with the progress bar isn't modal anymore.. The user can interact with Outlook (good!). But he can also interact with the MailItem while the tasks are running and the progress bar is showing (not good!)...
So question is, how can I block the MailItem, set it into readonly or something different to avoid that the user can modify the MailItem while showing a progress bar?
Upvotes: 0
Views: 246
Reputation: 49455
You just need to specify the parent window handle (of the opened inspector window) to the ShowDialog method. In that case users will not be able to interact with the opened email until the progress bar is hidden.
An instance of the Inspector window can be cast to the IOleWindow interface where you can get the window handle. See the IOleWindow::GetWindow method for more information.
Upvotes: 0