I am currently working on a C # .NET add-in for Microsoft Outlook. The purpose of the add-in is to capture the search obtained from Outlook Instant Search and display your own search results in custom panels.
This works very well, and with the subclassing of the Outlook window using my own window, I get a search string, and it already passes it to my panel.
The problem is that when you close the add-in (via "File-> Options-> Add-Ins-> COM Add-Ins", but not from the X to the panel), the add-in ends instantly and I cannot call searchboxWindow.ReleaseHandle() in advance to restore the WndProc chain. Outlook just crashes without visible errors.
protected override void WndProc(ref Message m) { base.WndProc(ref m); switch ((uint)m.Msg) { case WindowMessages.WM_DESTROY: case WindowMessages.WM_QUIT: case WindowMessages.WM_NCDESTROY: this.ReleaseHandle(); return; case WindowMessages.WM_KEYUP: case WindowMessages.WM_LBUTTONDOWN: case WindowMessages.WM_RBUTTONDOWN: OnKeyUp(); break; case WindowMessages.WM_EXITSIZEMOVE: OnResize(); break; } }
I have already tried to listen to several window messages that should be called when the add-in closes, but these messages appear only when Outlook closes in the usual way.
In addition, events in the main Add-In source file such as AppDomain.CurrentDomain.ProcessExit , this.Shutdown or ((Outlook.ApplicationEvents_10_Event)this.Application).Quit not called.
In what event can I listen (reliably) when the add-in starts? There are some? If not, what alternatives do I have to solve my problem?
c # outlook wndproc outlook-addin
Florian schöffl
source share