Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / May 2004

Tip: Looking for answers? Try searching our database.

Inspector wrapper and Inspector::OnClose event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Henry Gusakovsky - 26 May 2004 10:28 GMT
Hi there,

I have problem with Inspector::OnClose event.
Add-in is written using VC++.
I add custom toolbars and advise Inspector events in the
OnNewInspector event.

void __stdcall CConnect::OnNewInspector(IDispatch
* /*Outlook::_Inspector**/ Ctrl)
{
   
    USES_CONVERSION;

    Outlook::_InspectorPtr pInspector(Ctrl);

    CInspectorHandler * pInspectorHandler = new
CInspectorHandler( pInspector,m_lpSession, m_pAdrBook );

The problem is:
When user clicks SaveAndClose button Inspector::OnClose is
not fired. But if you press Ctrl-F4 or click on X in right
upper conner of the window this event fires.

To workaroud that problem I used Inspector::Deactivate
event. It fires always. In this event I check if current
ispector is in active inspectors collection via
Inspector.Application.Inspectors. I compare object
pointers. A peace of code:

BOOL FindInspectorInActiveInspectors( const
Outlook::_InspectorPtr & pInspector )
{
    BOOL bFound = FALSE;

    HRESULT hResult = S_OK;

    Outlook::_ApplicationPtr pApplication;
    Outlook::_InspectorsPtr pInspectors;
    Outlook::_InspectorPtr pInspectorTemp;

    hResult = pInspector->get_Application
(&pApplication);

    if ( SUCCEEDED(hResult) )
    {
        hResult = pApplication->get_Inspectors
(&pInspectors);

        if ( SUCCEEDED(hResult) )
        {
            LONG lCount = 0;
            pInspectors->get_Count(&lCount);

            for(LONG i = 1; i <= lCount; i++)
            {
                CComVariant varIndex(i);
                hResult = pInspectors->Item
(varIndex,&pInspectorTemp);

                if ( FAILED(hResult) )
                    break;

                if( pInspectorTemp ==
pInspector)
                {
                    bFound = TRUE;
                    break;
                } // if
            } // for

        }  // if

    }  // if

    return bFound;
}
Outlook Objects are imported like:
#import "msoutl9.olb" rename_namespace("Outlook")
raw_interfaces_only named_guids
 
That aproach works in Outlook 2000 and in Outlook XP.
In Outlook 2003 i have a problem. When i change current
window (not closing it) Inspector::Deactivate comes. But i
don't not find current inspector in the inspectors
collection.

Using only inspector i found out:
Inspectors.Count == 1 but
address of the object i get via Inspectors.Item[i] is
differ from my current inspector.

Some additional investigation says that
OOM for every Object return some sort of lightweight proxy
object
for example:

m_pApp is object passed in OnConnect event.
void __stdcall CConnect::OnNewInspector(IDispatch
* /*Outlook::_Inspector**/ Ctrl)
{
    Outlook::_InspectorsPtr pInspectors;
    Outlook::_InspectorPtr pInspector(Ctrl);
    m_pApp->getInspectors(&pInspectors);
   
    Outlook::_InspectorPtr pInspector1;
    Outlook::_InspectorPtr pInspector2;
    CComVariant varIndex(1);

    pInspectors->Item(varIndex, pInspector1);
    pInspectors->Item(varIndex, pInspector2);
    //there address of object in the pInspector1
    //differ from address of object in the pInspector2
}

As a result if i try to find current inspector in the
Inspectors collection I never find it.

I think that design change is because of improving
security model.

Any ideas how to workaround that problem.
I mean How to find current inspector in the inspectors
collection.

WBR
Henry
Henry Gusakovsky - 27 May 2004 11:05 GMT
I have some ideas how to workaround these problems:

1. Inspector::OnClose is not fired
 check Inspector.CurrentItem in the OnDeactivate event
 if CurrentItem is empty so Inspector is closed.

2. How to find current inspector in the inspectors
collection in Outlook 2003.
 Obtain Inspector.CurrentItem.EntryID and compare
 Items EntryIDs. I've noticed that Outlook never open
 new Inspector for the same already opened Object.

So guys what do you think about it.
Any comments ?

WBR
Henry

>Hi there,
>
[quoted text clipped - 122 lines]
>WBR
>Henry
Ken Slovak - [MVP - Outlook] - 27 May 2004 17:08 GMT
If you compare ID's don't use a straight string comparison. MAPI ID's might
not be identical but still might map to the same object. Use something like
CDO 1.21's Session.CompareIDs method or the equivalent methods for
Redemption or Extended MAPI.

Signature

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

> I have some ideas how to workaround these problems:
>
[quoted text clipped - 13 lines]
> WBR
> Henry
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.