strange problem while adding button to inspector window

V

vidishasharma

Hi,

In was trying to add button in inspector window. I
used .InspectorsEvents_NewInspectorEventHandler(myInspectors_NewInspector);
event and in this event I called a wrapper class where I configured
ItemEvents_10_OpenEventHandler(myMailItem_Open);

In this event I tried to create a button.

The problem over here is the button does not get created. However,
when I click on reply to this mail a new inspector is opened up where
I can reply to my mail and then a button on the reading inspector is
added.

I do not understand why this is happening.
 
K

Ken Slovak - [MVP - Outlook]

NewInspector is not a good event in which to create CommandBar UI. Depending
on the Outlook version and whether it's a WordMail object or not the
CommandBars collection of the Inspector may or may not be completely
instantiated in that event handler. In Outlook 2007 you explicitly get a
weak object reference to Inspector in NewInspector, in which many properties
of the Inspector or Inspector.CurrentItem aren't fully exposed to you yet.

I always create any UI for an Inspector in the first Inspector.Activate()
event that fires. At that time all UI elements are fully instantiated and
exposed to you.
 
V

vidishasharma

Hi Ken,

Thanks for answering my question.

I am trying to add win32 button next to 'to:' when you read a mail in
an inspector (same way I did for reading pane)

In my
InspectorsEvents_NewInspectorEventHandler(myInspectors_NewInspector)

I registered the following event
((Ol.InspectorEvents_Event)Inspector).Activate+=new
Microsoft.Office.Interop.Outlook.InspectorEvents_ActivateEventHandler(Connect_Activate);

however In Connect_Activate() I find that
applicationObject.ActiveInspector() is still 'null' means my inspector
is not activated and therefore button does not get added

when I try to reply that mail applicationObject.ActiveInspector() has
valid value as now the inspector where we read our mail is active and
therefore the button gets added in that inspector.

I tried the same thing in
((Ol.InspectorClass)Inspector).InspectorEvents_10_Event_Activate +=
new
Microsoft.Office.Interop.Outlook.InspectorEvents_10_ActivateEventHandler(Connect_InspectorEvents_10_Event_Activate);

however no luck. Can you guide what is wrong I am doing....
 
V

vidishasharma

I was able to solve this.

when the NewInspector event is registered
myInspectors.NewInspector += new
Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(myInspectors_NewInspector);

the following is created
myInspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector
Inspector)
{}

I used Inspector insted of applicationObject.ActiveInspector() and
that in
((Ol.InspectorClass)Inspector).InspectorEvents_10_Event_Activate +=
new
Microsoft.Office.Interop.Outlook.InspectorEvents_10_ActivateEventHandler(Co­
nnect_InspectorEvents_10_Event_Activate);

and that did the charm.

Thanks Ken for your suggestion.
 
K

Ken Slovak - [MVP - Outlook]

Why would you need to grab ActiveInspector() in the Inspector.Activate()
event? You already know what Inspector it is. Just use the Inspector that
fired the Activate() event. Or am I missing something?
 
V

vidishasharma

When I register
((Ol.InspectorEvents_Event)Inspector).Activate+=new
Microsoft.Office.Interop.Outlook.InspectorEvents_ActivateEventHandler(Connect_Activate);


Following method is craeted

void Connect_Activate()
{}

This has no defination for inspector there in new inspector wher I get
my current inspector I used that inspector object insted.

Let me know if I am know in implementing things.
 
K

Ken Slovak - [MVP - Outlook]

If you use Inspector wrapper classes as has been recommended then each
wrapper class has an Inspector object that's set when you create the wrapper
class instance in NewInspector. You use your constructor code for that
wrapper class to set the Inspector object and to add your event handlers.
When Activate() fires it fires only in that one wrapper class, therefore the
Inspector object in that wrapper class is the one you're handling events
for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top