Explorer' Close event not fired

J

j

Hi All,

I have Outtlook Addin (C# 2.0, VSTO 2005, Outlook 2003),

i subscribed to close event:

explorerEvents.Close += new
Outlook.ExplorerEvents_10_CloseEventHandler(OnExplorerClose);

but i never get there, why???

Only if i open another explorer (right click on folder--> Open in new
folder), and close it , then i get the close event fired, but when i
have only one explorer (main explorer) it's seem to be never fired.



P.S. I also susbscribe to FolderSwitch and SelectionChange explorer
events , they works fine.

Any suggestions??
 
K

Ken Slovak - [MVP - Outlook]

It sounds like you're not subscribing to the correct Explorer's events and
that you're not using a wrapper collection for open Explorers. If you were
you wouldn't get Close on the first Explorer after opening a second
Explorer.

Are you getting ActiveExplorer and subscribing to that in the Startup event
handler in your VSTO addin?

FWIW I do get all Explorer events including on the first Explorer and
separate events in my Explorer wrappers for each Explorer event I subscribe
to including Close().
 
J

j

Thanks,

It sounds like you're not subscribing to the correct Explorer's events and
but also i subscribed to FolderSwitch, and SelectionChange events, and
they fires well.
that you're not using a wrapper collection for open Explorers. If you were
you wouldn't get Close on the first Explorer after opening a second
Explorer.
Sorry probably i didn't explain right my problem, but if open another
explorer (NewWindow) on this just opened explorer
on closing it teh Close event will fire. On main explorer (explorer
that i get when Outlook is starts) i never get close event.

Are you getting ActiveExplorer and subscribing to that in the Startup event
handler in your VSTO addin?
Yes that exactly what i'm doing.



Any other suggestions??, Things that i should check??


Thanks in Advance.
 
K

Ken Slovak - [MVP - Outlook]

Not offhand. Post the parts of the code you're using to set up your Explorer
events handlers. Maybe we'll see something.
 
J

j

Thanks,

outlookExplorer is hold reference to Explorer

Outlook.ExplorerEvents_10_Event explorerEvents =
(Outlook.ExplorerEvents_10_Event)outlookExplorer ;

explorerEvents.Close += new
Outlook.ExplorerEvents_10_CloseEventHandler(OnExplorerClose);
explorerEvents.FolderSwitch += new
Outlook.ExplorerEvents_10_FolderSwitchEventHandler(explorerEvents_FolderSwitch);
explorerEvents.SelectionChange += new
Outlook.ExplorerEvents_10_SelectionChangeEventHandler(explorerEvents_SelectionChange);


thats All, tnx
 
K

Ken Slovak - [MVP - Outlook]

And this is called in your Startup() event handler? And outlookExplorer is
declared at class level and not in the procedure? What you show looks OK to
me.

I usually test for something like this:

if(Outlook.ActiveExplorer() != null)
{
outlookExplorer = Outlook.ActiveExplorer();

// then I add the Explorer events
}
 
J

j

Thanks,

And this is called in your Startup() event handler?
Yes this is exactly what i'm doing, and outlookExplorer is declared at
class level.


Another suggestions???


Thanks in Advance.
 
K

Ken Slovak - [MVP - Outlook]

The only other things I can think of is for you to show more of your code,
the complete Startup() event handler where you are instantiating your
Explorer event handler and the event handler itself. Maybe that will show
something, or to go to look at the Explorer handler sample in C# at
http://www.outlookcode.com/codedetail.aspx?id=789 and see how that compares
to your code.

The code I use is similar to Helmut's code in his Explorer wrapper example
referenced above.
 
J

j

Thanks,

I created new Addin that have nothing besides subscribing to
BeforeFolderSwitch and Explorer close events:


public partial class ThisApplication
{

Outlook.ExplorerClass expl;



private void ThisApplication_Startup(object sender, System.EventArgs
e)

{

expl = this.ActiveExplorer() as Outlook.ExplorerClass;


expl.ExplorerEvents_10_Event_Close += new
Microsoft.Office.Interop.Outlook.ExplorerEvents_10_CloseEventHandler(expl_ExplorerEvents_10_Event_Close);

exp.ExplorerEvents_Event_BeforeFolderSwitch += new
Microsoft.Office.Interop.Outlook.ExplorerEvents_BeforeFolderSwitchEventHandler(exp_ExplorerEvents_Event_BeforeFolderSwitch);



}


void exp_ExplorerEvents_Event_BeforeFolderSwitch(object NewFolder,
ref bool Cancel)
{
MessageBox.Show("Expl before folderSwitch event");
}

void expl_ExplorerEvents_10_Event_Close()

{

MessageBox.Show("Explorer Close!");

}

private void ThisApplication_Shutdown(object sender, System.EventArgs
e)
{
MessageBox.Show("Application_Shutdown");
}



All events fired but close NOT.

Technologies i'm using: .Net 2.0, Outlook 2003, VSTO 2005


Any suggestion???



Thanks in advance.
 
K

Ken Slovak - [MVP - Outlook]

It looks like that's going to be normal for VSTO. I do get Explorer_Close
events even on that first Explorer, but I'm using an Explorer wrapper
collection and the close event is firing in the close handler of my
wrappers. A close in the ThisApplication class is not firing under those
conditions.
 

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