View Single Post
  #8  
Old March 25th 10, 01:35 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook 2007 Add-in strange load behavior

The samples on my Web site are from my book. As with any samples like that
they don't cover every single possible use case. In this case I would not
use VSTO or I'd structure things to purposely not provide UI if a use case
was discovered that wasn't good with VSTO.

For example, I might add code to disable providing ribbon UI if
Explorers.Count == 0 so that Simple MAPI Inspectors wouldn't get ribbon UI
unless an Explorer was showing. Or I might just disconnect my addin if I
discovered that case.

Another thing to bear in mind is when Startup is going to fire for you in a
VSTO addin. Internally VSTO is handling the extensibility events but waits
until OnStartupComplete() to fire the VSTO startup event.

What you are describing is what I call a "ghost Inspector". In many cases if
you do any processing at all on an item you will get that Inspector that
hangs around after it should be closed and that doesn't respond to code. One
case where that happens is if you do things in item.Send(), for example.
What I do in cases where those ghosts might appear, and Simple MAPI
Inspectors are the worst for that, is to make sure the window gets closed by
forcing it.

In the last event I'm working with for that item, say Send(), I'll
instantiate and start a timer when I'm ready to let the event finish. I
usually use 100 mS to allow time for WordMail to finish autoformatting an
item if necessary. In the timer handler I call the Inspector.Close() method.
That forces the window to be closed.

In some cases I've actually had to force the window closed by getting the
window hWnd using the Win32 API FindWindow() call and then posting a
WM_CLOSE message to the window, but that's a last ditch thing that I only
use where necessary.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"SomewhereSomehow" wrote in
message ...
One more thing just discovered, the same behavior in the sample code you
provided on your site http://www.slovaktech.com.

I downloaded VSTO_CSOutlookProject, ran it, then ran excel, then created
new
message from excel.
Then if you try to close the window everything will be ok, but if you
first
select your tab VSTO_CS Addin, and then close the window - it will stay on
the screen

(As I understand as soon as customized ribbon is loaded/rendered the
window
could'n close properly, my ribbon is added to the TabMailMessage so it
loads/renders as soon as window is shown, in your sample as soon as i
select
VSTO_CS Addin tab - then in both cases the window stays on the screen...


Ads