A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to uniquely identify explorer / inspector objects in Outlook 2007



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 3rd 07, 07:25 PM posted to microsoft.public.outlook.program_addins
gernot
external usenet poster
 
Posts: 4
Default How to uniquely identify explorer / inspector objects in Outlook 2007

I am always getting different interface pointers for same explorer
objects. The same happens for inspector objects. What can a do to
unquely identify these objects?

Scenario:

1. In the NewInspector handler I save the _Inspector pointer.
2. In an event handler from a control in this inspector I use
IRibbonControl::get_Context() to obtain the corresponding _Inspector
pointer.

These pointers are never the same (comparing IUnknown pointers). These
COM objects are not the same!

In the case of inspectors I get away identifying them by its creation
date.
What can I do to identify explorers? Is there any Outlook method to
compare these objects?

Thanks, Gernot

Ads
  #2  
Old September 4th 07, 04:36 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to uniquely identify explorer / inspector objects in Outlook 2007

Outlook 2007 allows you to test for equality of two Inspector or Explorer
objects using the C# == operator or the VB Is operator. Earlier versions of
Outlook don't allow that.

What I usually do is to test for the window.Caption and also for the window
rectangle dimensions and coordinates. I use the Explorer (or Inspector) Top,
Left, Height and Width properties compared to the window I get using
FindWindow (a Win32 API call). If it's the foreground window you're working
with you can use GetForegroundWindow instead of using FindWindow.

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


"gernot" wrote in message
ups.com...
I am always getting different interface pointers for same explorer
objects. The same happens for inspector objects. What can a do to
unquely identify these objects?

Scenario:

1. In the NewInspector handler I save the _Inspector pointer.
2. In an event handler from a control in this inspector I use
IRibbonControl::get_Context() to obtain the corresponding _Inspector
pointer.

These pointers are never the same (comparing IUnknown pointers). These
COM objects are not the same!

In the case of inspectors I get away identifying them by its creation
date.
What can I do to identify explorers? Is there any Outlook method to
compare these objects?

Thanks, Gernot


  #3  
Old September 5th 07, 12:32 PM posted to microsoft.public.outlook.program_addins
gernot
external usenet poster
 
Posts: 4
Default How to uniquely identify explorer / inspector objects in Outlook 2007

How does C# implement the == operator? It must be more than just
comparing COM objects.
The workaround with FindWindow() is alright ;-)

Thanks, Gernot


On Sep 4, 5:36 pm, "Ken Slovak - [MVP - Outlook]"
wrote:
Outlook 2007 allows you to test for equality of two Inspector or Explorer
objects using the C# == operator or the VB Is operator. Earlier versions of
Outlook don't allow that.

What I usually do is to test for the window.Caption and also for the window
rectangle dimensions and coordinates. I use the Explorer (or Inspector) Top,
Left, Height and Width properties compared to the window I get using
FindWindow (a Win32 API call). If it's the foreground window you're working
with you can use GetForegroundWindow instead of using FindWindow.

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

"gernot" wrote in message

ups.com...



I am always getting different interface pointers for same explorer
objects. The same happens for inspector objects. What can a do to
unquely identify these objects?


Scenario:


1. In the NewInspector handler I save the _Inspector pointer.
2. In an event handler from a control in this inspector I use
IRibbonControl::get_Context() to obtain the corresponding _Inspector
pointer.


These pointers are never the same (comparing IUnknown pointers). These
COM objects are not the same!


In the case of inspectors I get away identifying them by its creation
date.
What can I do to identify explorers? Is there any Outlook method to
compare these objects?


Thanks, Gernot- Hide quoted text -


- Show quoted text -



  #4  
Old September 5th 07, 02:14 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to uniquely identify explorer / inspector objects in Outlook 2007

It's just a comparison of the COM objects, just a normal C# equality
comparison. It's just that the Outlook team fixed Explorers and Inspectors
so that works in Outlook 2007.

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


"gernot" wrote in message
ups.com...
How does C# implement the == operator? It must be more than just
comparing COM objects.
The workaround with FindWindow() is alright ;-)

Thanks, Gernot


  #5  
Old September 8th 07, 01:04 AM posted to microsoft.public.outlook.program_addins
gernot
external usenet poster
 
Posts: 4
Default How to uniquely identify explorer / inspector objects in Outlook 2007

Finally I compare inspector objects by their entry id:

_Inspector *pInspector;

// get entry id
CComPtrIDispatch pDispCurrentItem;
HRESULT hr = pInspector-get_CurrentItem(&pDispCurrentItem);
if (FAILED(hr)) { ReportError(hr); return NULL; }

CComQIPtr_MailItem pMailItem(pDispCurrentItem);
if (!pMailItem) { ReportError(E_POINTER); return NULL; }

CComPtrIUnknown pUnkMessage;
hr = pMailItem-get_MAPIOBJECT(&pUnkMessage);
if (FAILED(hr)) { ReportError(hr); return NULL; }

CComQIPtrIMessage, &IID_IMessage pMessage(pUnkMessage);
if (!pMessage) { ReportError(E_POINTER); return NULL; }

SPropValue *pProp = NULL;
hr = HrGetOneProp(pMessage, PR_ENTRYID, &pProp);
if (FAILED(hr)) { ReportError(hr); return NULL; }

Now pProp-Value.bin has the entry id. To check if two entry ids are
equal:

// get compare function
CComPtr_NameSpace pSession;
hr = pInspector-get_Session(&pSession);
if (FAILED(hr)) { ReportError(hr); return NULL; }

CComPtrIUnknown pUnkSession;
pSession-get_MAPIOBJECT(&pUnkSession);
if (FAILED(hr)) { ReportError(hr); return NULL; }

CComQIPtrIMAPISession, &IID_IMAPISession
pMAPISession(pUnkSession);
if (!pMAPISession) { ReportError(E_POINTER); return NULL; }

pMAPISession-CompareEntryIDs() is used to compare ids.

Comparing the IUnknown pointers of two _Inspector interfaces does not
work for C++.


On Sep 5, 3:14 pm, "Ken Slovak - [MVP - Outlook]"
wrote:
It's just a comparison of the COM objects, just a normal C# equality
comparison. It's just that the Outlook team fixed Explorers and Inspectors
so that works in Outlook 2007.

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

"gernot" wrote in message

ups.com...



How does C# implement the == operator? It must be more than just
comparing COM objects.
The workaround with FindWindow() is alright ;-)


Thanks, Gernot- Hide quoted text -


- Show quoted text -



  #6  
Old September 11th 07, 09:11 PM posted to microsoft.public.outlook.program_addins
gernot
external usenet poster
 
Posts: 4
Default How to uniquely identify explorer / inspector objects in Outlook 2007

MAPI entry ids may not exist before the item is saved. In this case I
use the creation time to identify the item.

On Sep 8, 2:04 am, gernot wrote:
Finally I compare inspector objects by their entry id:

_Inspector *pInspector;

// get entry id
CComPtrIDispatch pDispCurrentItem;
HRESULT hr = pInspector-get_CurrentItem(&pDispCurrentItem);
if (FAILED(hr)) { ReportError(hr); return NULL; }

CComQIPtr_MailItem pMailItem(pDispCurrentItem);
if (!pMailItem) { ReportError(E_POINTER); return NULL; }

CComPtrIUnknown pUnkMessage;
hr = pMailItem-get_MAPIOBJECT(&pUnkMessage);
if (FAILED(hr)) { ReportError(hr); return NULL; }

CComQIPtrIMessage, &IID_IMessage pMessage(pUnkMessage);
if (!pMessage) { ReportError(E_POINTER); return NULL; }

SPropValue *pProp = NULL;
hr = HrGetOneProp(pMessage, PR_ENTRYID, &pProp);
if (FAILED(hr)) { ReportError(hr); return NULL; }

Now pProp-Value.bin has the entry id. To check if two entry ids are
equal:

// get compare function
CComPtr_NameSpace pSession;
hr = pInspector-get_Session(&pSession);
if (FAILED(hr)) { ReportError(hr); return NULL; }

CComPtrIUnknown pUnkSession;
pSession-get_MAPIOBJECT(&pUnkSession);
if (FAILED(hr)) { ReportError(hr); return NULL; }

CComQIPtrIMAPISession, &IID_IMAPISession
pMAPISession(pUnkSession);
if (!pMAPISession) { ReportError(E_POINTER); return NULL; }

pMAPISession-CompareEntryIDs() is used to compare ids.

Comparing the IUnknown pointers of two _Inspector interfaces does not
work for C++.

On Sep 5, 3:14 pm, "Ken Slovak - [MVP - Outlook]"
wrote:



It's just a comparison of the COM objects, just a normal C# equality
comparison. It's just that the Outlook team fixed Explorers and Inspectors
so that works in Outlook 2007.


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


"gernot" wrote in message


oups.com...


How does C# implement the == operator? It must be more than just
comparing COM objects.
The workaround with FindWindow() is alright ;-)


Thanks, Gernot- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to link contacts/objects in Outlook 2007 as I can in Outlook 2003 Nigel Freeney Outlook - General Queries 4 July 4th 07 05:08 PM
CreateItem change for Outlook 2007? E_NOINTERFACE for returned objects. msoliver Add-ins for Outlook 3 June 8th 07 12:29 AM
Outlook/Office 2007 on Vista--Is there any installation parameter to control Explorer Window Colors? Hollis Paul Outlook - Installation 1 January 3rd 07 12:42 AM
Outlook 2007: Problem with SinkEvents on first explorer news.microsoft.com Add-ins for Outlook 4 June 9th 06 08:46 AM
Help! Inspector.Close is fired before Inspector.Activate handler finishes Sergey Anchipolevsky Add-ins for Outlook 8 February 9th 06 09:51 AM


All times are GMT +1. The time now is 09:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.