castormalin

issue catching arcmap events in C++

Discussion created by castormalin on Jul 13, 2010
Hello,

I'm attempting to use IActiveViewEvents to catch any table of contents changes.

Following http://edndoc.esri.com/arcobjects/9.1/ArcGISDevHelp/DevelopmentEnvs/Cpp/ArcGIS%20Development/eventhandling.htm, I should instanciate my class extending IActiveViewEvents using new. However visual won't do that, as told in http://support.microsoft.com/kb/181265 due to the pure virtual function error.

Now I'm attempting to use IDispEventImpl as in http://msdn.microsoft.com/en-us/library/06wtz4t5%28v=VS.80%29.aspx . I should derive my class from IDispEventImpl. Putting
public IDispEventImpl</*nID*/ 1, CMyClass,&__uuidof(IActiveViewEvents)>

seems OK, but filling SINK_MAP failed, I used
 BEGIN_SINK_MAP(CMyClass)
  SINK_ENTRY(1,__uuidof(IActiveViewEvents), 3, OnContentsChanged)
 END_SINK_MAP()

Here, I'm stuck.
Should my class implement IActiveLayerEvents too ?

Thanks all.

Outcomes