We have a bunch of forms written in C# as ArcMap commands, which are running happily in the normal way from command buttons. The forms interact with the map by creating layers and symbologies, and by listening for selections on the layers to update their own display.

For a number of annoying reasons, we now have to convert these to run from an external executable, but still interact with ArcMap. I'm attempting to use the approach of ArcMap "automation" so the forms are created by the executable, which also creates an ArcMap instance and passes it to the forms to allow them to interact.

I've got past the process-space issues of not being able to use "new" instantiation in the form's code for ArcObjects (layers, etc) that ArcMap has to interact with, and using IObjectFactory to get ArcMap to create them for me instead.

But I am struggling with events. The form needs to listen to events like SelectionChanged in the map and update itself. If I create an event handler in the normal way like

   dSelChangedE = new IActiveViewEvents_SelectionChangedEventHandler(OnSelectionChanged);
   m_pMap.SelectionChanged += dSelChangedE;

Then my OnSelectionChanged event method in the form fires correctly, but ArcMap seems to miss the event itself (even when it was ArcMap that created it, e.g. by interactive feature selection): the selection isn't displayed on screen! I guess this is process-space issues again but I don't know how to get around them. I can't see any way to make IObjectFactory make the event handler, for instance.

This thread on the old ESRI forums is similar the problem I'm having http://forums.esri.com/Thread.asp?c=93&f=993&t=213577 but in my case it's the other way around: I can get my controlling application to listen to the events, but then Arcmap loses track of them.

  • Thinking further, I'm not actually certain that it is the event being blocked; it may be that ArcMap is failing to refresh itself properly. If I do something like change the Arcmap window size, then the selection will show. I've tried every combination I can think of with PartialRefresh and Refresh, and even programatically zooming the map out and in again, but no luck. I saw palladiumconsulting.com/blog/sebastian/2008/02/… and tried this, but no clear idea as to what routines I need to wrap in the message-pump code. Commented Oct 5, 2012 at 14:32

1 Answer 1


If anyone's interested ... this just seemed to be one of the many things that is just broken in ArcMap 9.2.

We tried it in 9.3 and it works just fine - with a slight delay, sometimes, in refreshing the display, but overall it's usable. Obviously something terminally wrong with the screen refresh code in 9.2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.