C# Run a function in ArcMap everytime A Map Document is Openend/Loaded

3261
6
Jump to solution
09-29-2014 08:11 AM
JamariPowers
New Contributor III

I am working with ArcObjects and C#

I am having trouble figuring out a starting point to my issue. I have an add-in written in C# that I will be adding to. The add-in is always running. One of the functions that I will need to include is some kind of check or message box or some kind of indicator that runs every time a map document is opened/loaded into ArcMap. Every time this happens, it would be nice to just get a message box to display saying,..."Map Loaded".

I can make it more complex later on, but for simplistic terms, I'm just stuck on how to run this message box every time a map document is opened or loaded.

Any help on this topic would be greatly appreciated. Thanks in advance for your help.

0 Kudos
1 Solution

Accepted Solutions
CodyScott
Occasional Contributor

I would recommend using an Extension Addin if you haven't already done this.

ArcObjects 10 .NET SDK Help

The extension addin will give you access to the OnLoad()/OnStartup() functions which would satisfy what you're looking for.

If you already have an existing addin that you'd like to hook into as well, you can create some static methods/wrappers to utilize it. Basically the extension would function as the event listener, and the existing addin would remain as normal.

Hope this helps (assuming you haven't solved the issue already)!

View solution in original post

0 Kudos
6 Replies
TimothyHales
Esri Notable Contributor

I've moved your post into the ArcObjects SDK space. You will get a much better answer here as the GeoNet Help is intended for community help and feedback. You can see more on the community structure, and what topics are under each space from the following documents:

GeoNet Community Structure

ArcGIS Discussion Forums Migration Strategy

Thanks!

Timothy

0 Kudos
JamariPowers
New Contributor III

Thanks for moving my discussion. Sorry about posting in the wrong area. Still learning the forums.

DuncanHornby
MVP Notable Contributor

Sounds like you are asking about the IDocumentEvents interface? This has an on openDocument listener. Have a look at the snippet section of the SDK help for the snippet Add Event Wiring for New and Open Documents Snippet.

0 Kudos
JamariPowers
New Contributor III

Thanks for your input. Having trouble finding that exact title (still new to the site), but I did a search on it and some items have come up. Thanks again. I will take a look and continue researching

0 Kudos
CodyScott
Occasional Contributor

I would recommend using an Extension Addin if you haven't already done this.

ArcObjects 10 .NET SDK Help

The extension addin will give you access to the OnLoad()/OnStartup() functions which would satisfy what you're looking for.

If you already have an existing addin that you'd like to hook into as well, you can create some static methods/wrappers to utilize it. Basically the extension would function as the event listener, and the existing addin would remain as normal.

Hope this helps (assuming you haven't solved the issue already)!

0 Kudos
JamariPowers
New Contributor III

Yes, this is what I was looking for. I have indeed changed it to an Extension AddIn. In my extension I was able to utilize the OnStartup, On_OpenDocument, and On_NewDocument. With these functions (with the help of Wired Document Events), I am able to run specific functions on these events. Thanks for your assistance.

0 Kudos