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

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

looping through all commandbars   Tom Schwartzman Nov 20, 2002
Re: looping through all commandbars   Sharad Garg Nov 20, 2002
Re: looping through all commandbars   Tom Schwartzman Nov 20, 2002
Re: looping through all commandbars   Sharad Garg Nov 20, 2002
Re: looping through all commandbars   Kirk Kuykendall Nov 20, 2002
Re: looping through all commandbars   Tom Schwartzman Nov 20, 2002
Re: looping through all commandbars   Kirk Kuykendall Nov 20, 2002
Re: looping through all commandbars   Tom Schwartzman Nov 21, 2002
Re: looping through all commandbars   Kirk Kuykendall Nov 21, 2002
Re: looping through all commandbars   Tom Schwartzman Dec 05, 2002
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject looping through all commandbars 
Author Tom Schwartzman 
Date Nov 20, 2002 
Message Perhaps I'm missing something basic, but I'd like to loop through all commandbars and do something to each one. I can't find any way to do this - Document.Commandbars does not let you iterate through the collection, and I do not have all the IDs of the toolbars.

Is there a way to do this? Perhaps gaining access to the ESRI MX Toolbars programmatically via component category manager?

Any help appreciated.

Thanks,

Tom S. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: looping through all commandbars 
Author Sharad Garg 
Date Nov 20, 2002 
Message i dont think what you are asking is possible in arc objects. is there something specific you wish to do to all the toolbars? as there might be some way out for to it without looping thru like you want.
sharad 
  Sharad Garg
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: looping through all commandbars 
Author Tom Schwartzman 
Date Nov 20, 2002 
Message well, the reason was to write a tool to save/restore visibility of toolbars. If I could loop through them, I could write/read a file with their name or UID or something and make them visible/invisible appropriately. And, then build a better toolbar visibility manager - the right-click list is ungrouped, unordered, and too long.

Tom 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: looping through all commandbars 
Author Sharad Garg 
Date Nov 20, 2002 
Message hmm this may not be the best approach but have you tried using templates to set the tools you need. apart from that i dont see any other way of doing this. actually arc map also uses the same concept. it stores everything in templates. sorry cant help you more than that.
Sharad 
  Sharad Garg
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: looping through all commandbars 
Author Kirk Kuykendall 
Date Nov 20, 2002 
Message try this 
 
Option Explicit
Sub Test()
    Dim pMI As IMultiItem
    Set pMI = CreateObject("esricore.ToolbarContextMenuItems")
    
    Dim l As Long
    For l = 0 To pMI.OnPopup(Application) - 1
        If pMI.ItemChecked(l) Then
            Debug.Print "ON: " & pMI.ItemCaption(l)
        Else
            Debug.Print "OFF: " & pMI.ItemCaption(l)
        End If
    Next l
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: looping through all commandbars 
Author Tom Schwartzman 
Date Nov 20, 2002 
Message That works perfectly!!

However, I can't see how then to get to the actual commandbar from the name provided by pMI.ItemCaption.

I'll need that to make it visible (or not visible) using "aCommandbar.dock esriDockShow" (since pMI.Itemchecked is read-only) when I read the info in from a file.

Any thoughts on how to go from the name of the commandbar to an actual commandbar object as commandbars.find wants an arcid reference or a UID?

Thanks much,

Tom

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: looping through all commandbars 
Author Kirk Kuykendall 
Date Nov 20, 2002 
Message I don't see a way to get the actual command bar ... but the code below should work to toggle visibility.

P.S. for arc9.0+ use esriFramework instead of esriCore.

kkeywords imultiitem 
 
Option Explicit
Sub Test()
    Debug.Print IsVisible("Effects")
    Toggle "Effects"
    Debug.Print IsVisible("Effects")
    
End Sub

Sub Toggle(sCaption As String)
    Dim pMI As IMultiItem
    Set pMI = CreateObject("esricore.ToolbarContextMenuItems")
    
    Dim l As Long
    For l = 0 To pMI.OnPopup(Application) - 1
        If UCase(pMI.ItemCaption(l)) = UCase(sCaption) Then
            pMI.OnItemClick (l)
        End If
    Next l
End Sub

Function IsVisible(sCaption As String) As Boolean

    Dim pMI As IMultiItem
    Set pMI = CreateObject("esricore.ToolbarContextMenuItems")
    
    Dim l As Long
    For l = 0 To pMI.OnPopup(Application) - 1
        If UCase(pMI.ItemCaption(l)) = UCase(sCaption) Then
            IsVisible = pMI.ItemChecked(l)
        End If
    Next l
End Function


 
  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: looping through all commandbars 
Author Tom Schwartzman 
Date Nov 21, 2002 
Message well, that's it - it works perfectly. Thanks much for taking the time to help.

Regards,

Tom 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: looping through all commandbars 
Author Kirk Kuykendall 
Date Nov 21, 2002 
Message see also http://forums.esri.com/Thread.asp?c=93&f=982&t=69679&mc=3#181793 
  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: looping through all commandbars 
Author Tom Schwartzman 
Date Dec 05, 2002 
Message the toolbar control works great and my toolbar manager works well when attached to a button. But I am now converting that button that fires the toolbar manager (treeview on a form) to a ContentsView and I want to 'listen' for any changes to the UI (toolbars turned on/off not using my manager, new toolbars).

I don't see any events that fire when the UI changes - do you know of any?

Thanks much,

Tom