I am working on Outlook 2002 AddIn using VB.NET.
Basically, it works, BUT:
I noticed that Inspector's Close event is not fired when user presses "Save
and Close" button, e.g. in Contact form.
Is anybody aware of this issue?
How do I catch the moment an inspector actually closes? I need this to
clean-up/destroy event handlers, otherwise they keep accumulating in memory.
Thank you
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Alex K." <Al...@discussions.microsoft.com> wrote in message
news:2B54594E-C93F-4328...@microsoft.com...
In C# I'd use something like this:
// at class level
private Outlook.ItemsEvents_Event m_events;
private Outlook.ContactItem m_contact;
// in init code
m_events = (Outlook.ItemEvents_Event)m_contact;
m_events.Close += new Outlook.ItemEvents_CloseEventHandler(m_contact_Close);
// event handler
private void m_contact_Close(ref bool Cancel)
{
// whatever
}
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Alex K." <Al...@discussions.microsoft.com> wrote in message
news:3F611E6D-52B5-43B5...@microsoft.com...
"Ken Slovak - [MVP - Outlook]" wrote:
i tried to use ur code block in C# VS2008...:
// at class level
private Outlook.ItemsEvents_Event m_events;
private Outlook.ContactItem m_contact;
// in init code
m_events = (Outlook.ItemEvents_Event)m_contact;
m_events.Close += new Outlook.ItemEvents_CloseEventHandler(m_contact_Close);
// event handler
private void m_contact_Close(ref bool Cancel)
{
// whatever
}
but i am getting two errors as below:
1) 'Microsoft.Office.Interop.Outlook.ItemsEvents_Event' does not contain a
definition for 'Close' and no extension method 'Close' accepting a first
argument of type 'Microsoft.Office.Interop.Outlook.ItemsEvents_Event' could
be found (are you missing a using directive or an assembly reference?)
2) Cannot implicitly convert type
'Microsoft.Office.Interop.Outlook.ItemEvents_Event' to
'Microsoft.Office.Interop.Outlook.ItemsEvents_Event'. An explicit conversion
exists (are you missing a cast?)
plz help me on this..... by providing solution on how to disable the
default close(x) button of Inspector window
--OR--
let me know how to catch the Item.close event / Inspector.Close Event...
Thanks
Regards
Md.A.RaheeM
First of all, if you look at the object browser you will see that the
Inspector.Close() event does not have a Cancel argument. The event cannot be
cancelled. The ContactItem.Close() event (and other item types) does have a
Cancel argument, so if you want to cancel closing the item based on certain
conditions you should be handling that event and not Inspector.Close().
For an item.Close() handler you wouldn't use Outlook.ItemsEvents_Event, but
you could use Outlook.ItemEvents_Event. Note that your code uses ItemsEvents
and the following uses ItemEvents with no "s" in Item.
If you were to use that way of handling ContactItem.Close() you would
instantiate it as follows:
// at class level
private Outlook.ItemEvents_Event _itemEvents = null;
// init code
_itemEvents = (Outlook.ItemEvents_Event)m_contact;
// hook up the ContactItem Close event handler
_itemEvents.Close += new Outlook.ItemEvents_CloseEventHandler(OnItem_Close);
--
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
"Md.A.RaheeM" <Md.A....@discussions.microsoft.com> wrote in message
news:1045F108-EDB4-4495...@microsoft.com...