outlook contact change selection event to a plugin

  • Thread starter Thread starter Acaccia
  • Start date Start date
A

Acaccia

Hi to all... I'm developing an Outlook 2003 Add-in by VC++ (.NET). The
question is: how is it possible to capture a 'selection change event' in
contact list item? I would to get name of contact selected in asynchronous
mode (I don't want extract these informations clicking a button). Any ideas?
Thank's in advance. Bye...
Andrea
 
Dmitry Streblechenko (MVP) said:
Use the Explorer.SelectionChange event

Please, can you make me a simple example in C++? I have searched in google
some informations about it, without any success! :o( ...... How can I
dispatch explorer events?
Andrea
 
Either use the class wrappers created by #import, or do it the standard COM
way - QI the IDispatch (Explorer) for IConnectionPointContainer, call
IConnectionPointContainer::FindConnectionPoint(ExplorerEvents, ...), call
IConnectionPoint::Advise passing your implementation of IDispatch (only
Invoke needs to be implemented). When events fire, your implemenattion of
IDispatch::Invoke will be called with the appropriate dispid (0xF007 in case
of the SelectionChange event).

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Dmitry Streblechenko (MVP) said:
Either use the class wrappers created by #import, or do it the standard
COM
[snip]

Ok, another option without IConnectionPointContainer, I try it:


//ADDIN.H
extern _ATL_FUNC_INFO OnSelectionChangeInfo;

class ATL_NO_VTABLE CAddin :
//...
IDispEventSimpleImpl<1,CAddin,&__uuidof(Outlook::ExplorerEvents)>
{
//...
BEGIN_SINK_MAP(CAddin)

SINK_ENTRY_INFO(1,__uuidof(Outlook::ExplorerEvents),0xf007,OnSelectionChange
,&OnSelectionChangeInfo)
END_SINK_MAP()

void __stdcall OnSelectionChange();

public:
STDMETHOD(OnConnection)(IDispatch * Application, ext_ConnectMode
ConnectMode, IDispatch * AddInInst, SAFEARRAY * * custom)
{
//...
spApp->ActiveExplorer(&m_spExplorer);
HRESULT hr
=ExpEvents::DispEventAdvise((IDispatch*)m_spExplorer,&__uuidof(Outlook::Expl
orerEvents));
if(FAILED(hr))
return hr;
//...
}
};


//ADDIN.CPP
_ATL_FUNC_INFO OnSelectionChangeInfo ={CC_STDCALL,VT_EMPTY,0};
//...
void __stdcall CAddin::OnSelectionChange()
{
AfxMessageBox("Selection is changed!");
}

Ok, it works as well.
Bye!
Andrea
 
Back
Top