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

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

Turning off toolbars with a extension   Mark Banas Apr 19, 2002
Re: Turning off toolbars with a extension   Kirk Kuykendall Apr 19, 2002
Re: Turning off toolbars with a extension   Sirikarn Hall Apr 19, 2002
Re: Turning off toolbars with a extension   André van der Maarel Mar 04, 2004
Re: Turning off toolbars with a extension   Sirikarn Hall Mar 04, 2004
Re: Turning off toolbars with a extension   Kirk Kuykendall Mar 04, 2004
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Turning off toolbars with a extension 
Author Mark Banas 
Date Apr 19, 2002 
Message Hi all,

I'm trying to create an extension in VB that will control when a toolbar is visable or not. I have created the extension using IExtension/IExtensionconfig and have created my toolbar using IToolBarDef. Now I want to add functionality that will turn the toolbar off when I uncheck the extension and turn the toolbar on when I check the extension. What interface/methods can I use to see when the extension is turned on or off? Thanks for the help. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Turning off toolbars with a extension 
Author Kirk Kuykendall 
Date Apr 19, 2002 
Message IExtensionConfig.State 
  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: Turning off toolbars with a extension 
Author Sirikarn Hall 
Date Apr 19, 2002 
Message Hi,

You need to implement IExtensionConfig. Please see VB Code.

'== VB Code for turning on/off toolbar

Private m_pExtState As esriExtensionState

Private Property Get IExtensionConfig_State() As esriCore.esriExtensionState
IExtensionConfig_State = m_pExtState
End Property

Private Property Let IExtensionConfig_State(ByVal RHS As esriCore.esriExtensionState)

If m_pExtState = esriESEnabled Then
Dim pbars As ICommandBars
Set pbars = m_pDoc.CommandBars
Dim pUID As UID
Set pUID = New UID
''Below is a toolbar in this project (clsToolbar..."
pUID.Value = "ProjectName.clsToolBar"
Dim pbar As ICommandBar
Set pbar = pbars.Find(pUID)
pbar.Dock esriDockFloat
End If

Exit Property

Handler:
MsgBox Err.Description
End Property 
  @^_^@

Sirikarn Tantipanarat Hall (Siri)
Sirikarn.Hall@Chevron.com
=======================================
Chevron Pipe Line Company
4800 Fournace Place, Room E330B
Bellaire, TX 77401
www.chevron-pipeline.com

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Turning off toolbars with a extension 
Author André van der Maarel 
Date Mar 04, 2004 
Message I just read your message about turning toolbars off using an extension, I have an similar problem.
When I open an existing mdx in which my extension is turned on I try to add my custom menu-option in the IPerstistVariant_Load. Apperantly this is not the right place because the custom menu-option does not appear at the index I want it to appear.
Worse when I try to remove it (turn extension off) the File-menu disappears.
I use the same subs that work well in a fresh created project.
When then extension is turned off at the moment of saving the mxd there is no problem at reopening the mxd. Even so you can turn the extension on whitout a problem.

Is the IpersistVariant_load not the right place ( is ArcGis still busy organising its own toolbars or something like that?)

André van der Maarel
Royal Haskoning
Rotterdam
the Netherlands
www.RoyalHaskoning.com
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Turning off toolbars with a extension 
Author Sirikarn Hall 
Date Mar 04, 2004 
Message First of all, if you want to add you custom menu, I would recommend you to create/delete your custom menu at IExtensionConfig_State.

If RHS = esriESEnabled Then
Call CreateMenu(m_pApp)
Else
Call DeleteMenu(m_pApp)
End If

Then when you implement IPersistVariant, you would set IPersistVariant_ID to your extension
Private Property Get IPersistVariant_ID() As esriCore.IUID
IPersistVariant_ID.Value = "Project.clsExtension"
End Property

The second problem is about the index of your custom menu. I think you get the wrong index number for your custom menu. I attach the example code how to get the index number of your custom menu.


 
  @^_^@

Sirikarn Tantipanarat Hall (Siri)
Sirikarn.Hall@Chevron.com
=======================================
Chevron Pipe Line Company
4800 Fournace Place, Room E330B
Bellaire, TX 77401
www.chevron-pipeline.com

 
  modMenuOnOff.bas (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Turning off toolbars with a extension 
Author Kirk Kuykendall 
Date Mar 04, 2004 
Message The startup sequence is not very well documented, I haven't tested it lately, but in earlier versions the commandbars are not accessible until a document has been opened. Since IExtensionConfig.State is called by arcmap at startup before the document is opened, special care is needed

http://forums.esri.com/Thread.asp?c=93&f=993&t=50129&mc=2#122523

kkeywords iextensionconfig 
  Kirk Kuykendall
AmberGIS Programming Services & Sales
http://www.ambergis.com
Now Answering questions at:
http://gis.stackexchange.com/