How to use c++ to write Extension to listen to document open or save events

291
3
06-15-2013 12:18 AM
taishengchen
New Contributor
I want to listen to open mxd file event in arcmap extension. I find a interface:IDocumentEvents, but I don't know how to use it in C++ and What is the listener for IDocumentEvents.
0 Kudos
3 Replies
RichardWatson
Regular Contributor III
The class that you are probably looking for is MxDocument:

http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/000v/000v000000nn000000.htm

Steps:

  • Get IApplication

  • From IApplication call get_Document to get IDocument

  • Call AtlAdvise to subscribe to the document events


If the above is not sufficient information then I'd suggest to install and dig through the C++ samples associated with the ArcObjects SDK.

In general, programming in C# would be easier but your post indicated that you wanted to use C++.

Best of luck!
0 Kudos
taishengchen
New Contributor
The class that you are probably looking for is MxDocument:

http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/000v/000v000000nn000000.htm

Steps:

  • Get IApplication

  • From IApplication call get_Document to get IDocument

  • Call AtlAdvise to subscribe to the document events


If the above is not sufficient information then I'd suggest to install and dig through the C++ samples associated with the ArcObjects SDK.

In general, programming in C# would be easier but your post indicated that you wanted to use C++.

Best of luck!


The question is how to Call AtlAdvise to subscribe to the document events. For IActiveviewEvents, we can use CLSID_ActiveViewEventsListener, but for IDocumentEvents, what is the Listener?
0 Kudos
taishengchen
New Contributor
The question is how to Call AtlAdvise to subscribe to the document events. For IActiveviewEvents, we can use CLSID_ActiveViewEventsListener, but for IDocumentEvents, what is the Listener?


I use  "AtlAdvise(m_spDocument, m_spVGEDocumentEvents, __uuidof(IDocumentEvents), &m_dwDocEventsCookie);"
sucessful. thankyou
0 Kudos