|
using System;
using System.Collections.Generic;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace CustomOutlookDialog {
internal class InspectorWrapper {
public event EventHandler<Guid> InspectorClosed;
public Guid ID { get; private set; }
public Outlook.Inspector Inspector { get; private set; }
public InspectorWrapper(Outlook.Inspector inspector) {
Inspector = inspector;
ConnectEvents();
}
void ConnectEvents() {
((Outlook.InspectorEvents_10_Event)Inspector).Close += new Outlook.InspectorEvents_10_CloseEventHandler(InspectorWrapper_Close);
((Outlook.InspectorEvents_10_Event)Inspector).Activate += new Outlook.InspectorEvents_10_ActivateEventHandler(InspectorWrapper_Activate);
((Outlook.InspectorEvents_10_Event)Inspector).Deactivate += new Outlook.InspectorEvents_10_DeactivateEventHandler(InspectorWrapper_Deactivate);
}
void DisconnectEvents() {
((Outlook.InspectorEvents_10_Event)Inspector).Close -= new Outlook.InspectorEvents_10_CloseEventHandler(InspectorWrapper_Close);
((Outlook.InspectorEvents_10_Event)Inspector).Activate -= new Outlook.InspectorEvents_10_ActivateEventHandler(InspectorWrapper_Activate);
((Outlook.InspectorEvents_10_Event)Inspector).Deactivate -= new Outlook.InspectorEvents_10_DeactivateEventHandler(InspectorWrapper_Deactivate);
}
void InspectorWrapper_Close() {
DisconnectEvents();
Inspector = null;
GC.Collect();
GC.WaitForPendingFinalizers();
// inform the application to release al references.
if (InspectorClosed != null) InspectorClosed(this, ID);
}
private IntPtr _invisibleWindow;
private void InspectorWrapper_Activate() {
if (_invisibleWindow != IntPtr.Zero) {
// Close the invisible window
WinApiProvider.PostMessage(_invisibleWindow, WinApiProvider.WM_CLOSE, 0, 0);
FormRecipientDialog customDialog = new FormRecipientDialog(Inspector.CurrentItem);
customDialog.ShowDialog();
}
}
void InspectorWrapper_Deactivate() {
int languageId = Inspector.Application.LanguageSettings.get_LanguageID(Microsoft.Office.Core.MsoAppLanguageID.msoLanguageIDUI);
_invisibleWindow = WinApiProvider.SearchForAddressbookWindow(languageId);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm a 1968 model, made in Germany.
After School transformed into an electronic engineer and started repairing computers in 1986. From PET till now In the IT-world. Currently employed as softwaredeveloper in a company creating solutions for pharmacies.
MCSE2000, MCSD, MCTS - Team Foundation Server, MCTS - Visual Studio Tools for Office.
Specialized in Outlook/Exchange custom development. Languages: german, english, C#, C++, VB.Net, VB6, SQL.
In 2006 received an award as MVP - Visual Developer VSTO by Microsoft.
Homepage: [http://www.x4u.de]