Kamal Vaghjiani
Posts: 5
Joined: 2006-02-15
|
I'm having problems trying to identify a inspector window when referenced from a toolbar button event.
I'm using System.Collections.SortedList to store the instance of outlook inspectors.
heres some code....
internal System.Collections.SortedList MySortedList = System.Collections.SortedList();
private void adxOutlookEvents_NewInspector(object sender, object inspector, string folderName)
{
MySortedList.Add(inspector.GetHashCode(),new myCustomObject());
}
private void adxOutlookEvents_InspectorClose(object sender, object inspector, string folderName)
{
MySortedList.Remove(inspector.GetHashCode());
}
// CommandBarButton Custom Event
private void btnClick_DoSomething(object sender)
{
Outlook._Inspector inspector = OutlookApp.ActiveInspector();
Object obj= MySortedList.GetByIndex(inspector.GetHashCode()));
}
InspectorClose event works fine, the inspector instance is found in MySortedList and Removed.
In btnClick_DoSomething it does not find the instance in MySortedList.
Could this be a problem with OutlookApp.ActiveInspector()
Please help.
|
|
Kamal Vaghjiani
Posts: 5
Joined: 2006-02-15
|
Sergey
Thanks for your email.
Where do you fill the SortedList - inspectors in the code you sent me
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
I do it in the InspectorActivate event handler.
Actually your code is correct. You just need to get rid of the ActiveInspector method as shown in my example. |
|
Kamal Vaghjiani
Posts: 5
Joined: 2006-02-15
|
Sergey
Thanks, I changed my code to store inspector interface in a SortedList.
The only change I had to make is to declare the following
internal object activeInspector = null; (as per your code)
internal IntPtr activeInspectorPointer = IntPtr.Zero; (new)
I added activeInspectorPointer because the following code would give me differant values when referenced toolbar btn click events
pointer = Marshal.GetIUnknownForObject(activeInspector);
So in the adxOutlookEvents_InspectorActivate event I added the following
activeInspectorPointer = Marshal.GetIUnknownForObject(activeInspector);
and used this to look up the inspector instance in my SortedList.
|
|
Sergey Grischenko
Add-in Express team
Posts: 7235
Joined: 2004-07-05
|
|