Note that there are some explanatory texts on larger screens.

plurals
  1. POOutlook 2010 add-in, how do I cancel close event, minimize window? (C#)
    text
    copied!<p>After a few hrs of experimentation and google searches I have finally come to the end of what I can figure out on my own, so here is what I have now:</p> <pre><code>private void ThisAddIn_Startup(object sender, System.EventArgs e) { Application.Startup += new Outlook.ApplicationEvents_11_StartupEventHandler( ApplicationObject_Startup); ((Outlook.ApplicationEvents_11_Event)Application).Quit += new Outlook.ApplicationEvents_11_QuitEventHandler( ApplicationObject_Quit); } void ApplicationObject_Startup() { MessageBox.Show("Startup Event"); ((Outlook.ExplorerEvents_10_Event)Application.ActiveExplorer()).Close += new Outlook.ExplorerEvents_10_CloseEventHandler( ExplorerObject_Close); } void ApplicationObject_Quit() { MessageBox.Show("Quit Event"); } void ExplorerObject_Close() { MessageBox.Show("Explorer Close Event"); } </code></pre> <p>All of this works, and when I close outlook I see the explorer close event and quit event message boxes in order. However by this point outlook seems to already have closed, and I have no idea how to cancel these events (for some other events there is a bool Cancel passed in that you can set to false, but not for these events?), or send a minimize event (I haven't been able how to figure this out at all).</p> <p>If anyone has any suggestions I'd really appreciate it. I had some spare time at work and figured I'd try to learn some addin dev stuff, and solve a really annoying part of outlook at the same time!</p> <p>EDIT: I have also tried:</p> <pre><code>Application.ActiveExplorer().WindowState = Outlook.OlWindowState.olMinimized; </code></pre> <p>at startup to just immediately minimize the window. It does minimize outlook, but not to the systen tray, only onto the bar (which is funny, and probably actually a bug, since minimize is set to minimize to tray...) Still, if I could just get rid of the close/quit event(s) I could at least just minimize the window to the taskbar.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload