Explorer.SelectionChange event triggered multiple times

D

Dorian

Sometimes when I change the selection in the explorer the SelectionChange
event gets triggered twice, other times it gets triggered once. I've been
able to fix it somewhat by filtering out when a MailItem is UnRead, but when
clicking through my read emails, I still get multiple triggers per MailItem.

I hookup the event in the addin Startup event and I've been breakpointing it
to make sure it only gets triggered once.

The functionality that I want is to trigger the event everytime a new
Explorer selection is made.
 
D

Dmitry Streblechenko

Why is this a problem? How and when the event fores depends on the kind of
folder, you are in, how the messages are selected, etc.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
D

Dorian

It's a problem because everytime a message is selected I go through some very
time intensive tasks, and having it occurring twice tends to slow things
down. The messages are being selected in the Inbox folder. They are being
single selected by clicking on them with the cursor.
 
D

Dmitry Streblechenko

When the event fires up twice, do you get the same message both times (look
at MailItem.EntryID)?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
D

Dorian

One other thing I've noticed. I added MessageBox.Show(item.EntryID) to check
the EntryID of my selected items. I couldn't for the life of me recreate the
problem. So I got rid of that and did a Debug.Print(item.EntryID) instead,
and I was able to recreate the problem again.
 
D

Dmitry Streblechenko

So here you go: store teh value of the last processed entry id and check to
see if the newly selected messgae is identical to the previous one. If yes,
do nothing.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
D

Dmitry Streblechenko

Taking the focus away the list to a message box woudl certainly change how
selection is processed, this is hardly surprising.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 

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