Problem in invoking method on IActiveViewEvents.FocusMapChanged Event

362
1
11-15-2010 01:31 AM
vijipat
New Contributor
Hi All,

I am simply trying to invoke a method on IActiveViewEvents' s FocusMapChanged Event. But somehow method  given for its handler is not getting invoked on focusMap Change Event.

Following is the code I have used:
 
private IActiveViewEvents_FocusMapChangedEventHandler DFocusMapChangedE;
private Map m_map;

m_map = (Map)m_mxDoc.FocusMap;
           
DFocusMapChangedE = new IActiveViewEvents_FocusMapChangedEventHandler(PerformSelectionChanged);
m_map.FocusMapChanged += DFocusMapChangedE;

Similar code on writing for SelectionChanged Event gets involked properly on selection Change Event.

Please help.

Regards,
Viji
0 Kudos
1 Reply
SandhyaYamarthi
New Contributor
Hi,
You dont need to define any eventhandlers, you can try directly the inbuilt 'IActiveViewEvents_Event' interface from Carto library and call the 'FocusMap Changed' event on map.

try this code: (I'm working with ArcGIS 10 now, so the code is relevant to 10 APIs)
ESRI.ArcGIS.Carto.IActiveViewEvents_Event avEvent = ArcMap.Document.FocusMap as ActiveViewEvents_Event;
avEvent.FocusMapChanged += new ESRI.ArcGIS.Carto.IActiveViewEvents_FocusMapChangedEventHandler(avEvent_FocusMapChanged);

and now you can write what ever you want to implement on focus map changed.

void avEvent_FocusMapChanged)
{
    //....code to do what ever you like to..
}

Let me know if you you still have any question on it.
Thanks!
0 Kudos