Thread: Ref leaks
View Single Post
  #8  
Old August 9th 09, 12:34 AM posted to microsoft.public.outlook.program_addins
John Erickson[_2_]
external usenet poster
 
Posts: 27
Default Ref leaks

Thanks to your advise I'm now advising my eventing object at NewInspector and
NewExplorer times so that I can catch the Close() events and clean up. I
still need to tie things together at BeforeFormRegionShow time though. I need
to know at that time if this is being issued for an Explorer or an Inspector
and which instance of which so that I can tie my form region objects to the
appropriate inspector or explorer. That way when the appropriate explorer or
inspector Close()s I can clean up my custom form object as well. The way I am
currently doing that is by doing a pFormRegion-get_Inspector. If that
returns null, than I assume it's being called on behalf of an explorer rather
than an inspector. I then use an Outlook::Application-ActiveExporer call to
determine which (if there can be more than one) explorer this
BeforeFormRegionShow is beind called for. The results of those two calls
allow me to tie my form objects with the appropriate explorer or inspector.
The get_Inspector call doesn't seem to be creating a new Inspector since it
returns null if the BeforeFormRegionShow call is for an explorer. Am I
missing something? Is there a better way to determine who
BeforeFormRegionShow is being called for? Has my custom form already been
added to the explorer or inspector by the time a NewInspector or NewExplorer
call has been made? I assumed not, but if it is I could initialize my custom
form at that time instead of at BeforeFormRegionShow time. But, I dont see a
way to get the _FormRegion object then. It would be nice if the
BeforeFormRegionShow or the _FormRegion object could tell me it's owner. Does
get_Parent return the Explorer or Inspector object the region is for?

John

"Ken Slovak - [MVP - Outlook]" wrote:

The problem with the get* events for Inspector or Explorer are they open a
window of that type if one isn't already opened. If one is opened they use
that. So if something is being read in the preview pane and isn't open,
using get_Inspector() will open the item.

Better to handle NewInspector(), that way you get the handle when the item
is being opened.

--
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


"John Erickson" wrote in message
...
Sorry I meant get_Inspector not get_Explorer.

"John Erickson" wrote:

Thanks for the quick reply Ken. From Outlook::_FormRegion I see a
get_Explorer method. Can I use that method in both scenerios to hook the
close event?



Ads