You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

Implementing TOCView   Chad Koenig Mar 26, 2002
Re: Implementing TOCView   Neil Clemmons Mar 26, 2002
Re: Implementing TOCView   Chad Koenig Mar 26, 2002
Re: Implementing TOCView   Neil Clemmons Mar 26, 2002
Re: Implementing TOCView   Kirk Kuykendall Mar 26, 2002
Re: Implementing TOCView   Chad Koenig Mar 26, 2002
Re: Implementing TOCView   Kirk Kuykendall Mar 26, 2002
Re: Implementing TOCView   Brian Flood Mar 26, 2002
Re: Implementing TOCView   dathan pabon Mar 27, 2002
Re: Implementing TOCView   Chad Koenig Mar 27, 2002
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Implementing TOCView 
Author Chad Koenig 
Date Mar 26, 2002 
Message I'm trying to listen for the selection changed event in the table of contents using IActiveViewEvents, but TOCView is an abstract class and I'm not sure how to create an object of that class. The code below is what I have so far. Any suggestions? 
 
Private WithEvents m_pEvents As MxDocument


Private Sub ICommand_OnCreate(ByVal hook As Object)
  ' The hook argument is a pointer to Application object.
  ' Establish a hook to the application
  Set m_pApp = hook
  
  Dim pMxDoc As IMxDocument
  Set pMxDoc = m_pApp.Document
  
  Dim pToc As IContentsView
  Set pToc = pMxDoc.ContentsView(0)
  Set m_pEvents = pToc
End Sub
 
  Chad Koenig
Pioneer Hi-Bred
http://www.pioneer.com 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author Neil Clemmons 
Date Mar 26, 2002 
Message This is how you set up the event listener, does the event not fire? You could put a message box inside the SelectionChanged event to see if it is firing. 
  Neil Clemmons
Senior GIS Developer
Geographic Information Services, Inc.
Birmingham, AL
http://www.gis-services.com

Check out our blog:
http://blog.gis-services.com/ 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author Chad Koenig 
Date Mar 26, 2002 
Message I have a message box in the SelectionChanged event, but it doesn't fire. 
  Chad Koenig
Pioneer Hi-Bred
http://www.pioneer.com 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author Neil Clemmons 
Date Mar 26, 2002 
Message The documentation says that each coclass implements the IActiveViewEvents interface differently. The SelectionChanged event may not be implemented for the TOCDisplayView coclass. You might want to give Tech support a call and ask them. 
  Neil Clemmons
Senior GIS Developer
Geographic Information Services, Inc.
Birmingham, AL
http://www.gis-services.com

Check out our blog:
http://blog.gis-services.com/ 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author Kirk Kuykendall 
Date Mar 26, 2002 
Message Brian has written a helper function that listens for click events in the TOC ... it might be a workaround.
http://forums.esri.com/Thread.asp?c=93&f=993&t=49460&mc=10#134985
 
  Kirk Kuykendall
AmberGIS Programming Services & Sales
http://www.ambergis.com
Now Answering questions at:
http://gis.stackexchange.com/


 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author Chad Koenig 
Date Mar 26, 2002 
Message Thanks all for your help. It appears that neither the TOCDisplayView or TOCCatolgView classes support the WithEvents keyword, which I don't understand why. The IActiveViewEvents interface is listed as one you can use in both classes. Brian's method may work, but I think his program is over my head at this point. 
  Chad Koenig
Pioneer Hi-Bred
http://www.pioneer.com 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author Kirk Kuykendall 
Date Mar 26, 2002 
Message Yes I think this is a bug ... the code below generates a compile error saying "Object does not source automation events".

Also, the OMD should have a filled lollipop.

(ArcGIS 8.1 SP1) 
 
Option Explicit
Private WithEvents m_TOC As TOCDisplayView
Sub Test()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Set m_TOC = pMxDoc.ContentsView(0)
End Sub
 
  Kirk Kuykendall
AmberGIS Programming Services & Sales
http://www.ambergis.com
Now Answering questions at:
http://gis.stackexchange.com/


 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author Brian Flood 
Date Mar 26, 2002 
Message Chad

Are you just looking for an event when the TOC's selected node changes? I'm a little confused as to what you are looking for.

brian 
  Brian Flood
bFlood@spatialDataLogic.com
http://www.Arc2Earth.com
http://www.spatialDataLogic.com
http://www.spatialdatalogic.com/CS/blogs/brian_flood/

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author dathan pabon 
Date Mar 27, 2002 
Message Hello Chad,

If you look in Exploring ArcObjects.PDF it says that
TOCDisplayView and TOCSourceView do not currently provide
an implementation for IActiveViewEvents::SelectionChanged.
At this point, the only way to fire any code in response
to the selected layer being changed is to develop a dummy button in standalone VB using the ICommand_Enabled sub-procedure to check if the selected layer has been changed.
The enabled procedure is fired every couple of seconds.
Open VB and stub out the code for the ICommand interface.
In the ICommand_Enabled sub write code that gets the currently selected layer and compares its name to the current value of a string variable. If the value has changed, then call a function that carries out whatever task you want carried out.
I have provided a sample. Compile the module into
a .dll and then add the button to your mxd.
When the selected layer is changed, the sub-routine
that the ICommand_Enabled procedure calls will execute.

 
 
Option Explicit
 
Private m_pApp As IApplication
 
Implements ICommand
 
Private Property Get ICommand_Enabled() As Boolean
    
'Add your code here!!!!!!!!!!************

'If layer name has changed, then call your sub.!!!!!****

End Property
 
Private Property Get ICommand_Checked() As Boolean
    
    ICommand_Checked = False
    
End Property
 
Private Property Get ICommand_Name() As String
    
    
    
End Property
 
Private Property Get ICommand_Caption() As String
    
    
    
End Property
 
Private Property Get ICommand_Tooltip() As String
    
    
End Property
 
Private Property Get ICommand_Message() As String
    
End Property
 
Private Property Get ICommand_HelpFile() As String
    
    
End Property
 
Private Property Get ICommand_HelpContextID() As Long
    
    ' TODO: Add your implementation here
    
End Property
 
Private Property Get ICommand_Bitmap() As esriCore.OLE_HANDLE
    
    ' TODO: Add your implementation here
    
End Property
 
Private Property Get ICommand_Category() As String
    
    ICommand_Category = "AddData Test"
    
End Property
 
Private Sub ICommand_OnCreate(ByVal hook As Object)
    
    Set m_pApp = hook
    
End Sub
 
Private Sub ICommand_OnClick()

End Sub
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Implementing TOCView 
Author Chad Koenig 
Date Mar 27, 2002 
Message Thanks Dathan. I used this alternative and it works fine for my purposes. 
  Chad Koenig
Pioneer Hi-Bred
http://www.pioneer.com