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

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

iTool Acccess to an iToolControl   Fred Griggs Sep 27, 2005
Re: iTool Acccess to an iToolControl   Kirk Kuykendall Sep 27, 2005
Re: iTool Acccess to an iToolControl   Neil Clemmons Sep 27, 2005
Re: iTool Acccess to an iToolControl   Fred Griggs Sep 28, 2005
Re: iTool Acccess to an iToolControl   Fred Griggs Oct 04, 2005
Re: iTool Acccess to an iToolControl   Jason Eklund Oct 04, 2006
Re: iTool Acccess to an iToolControl   Kirk Kuykendall Oct 04, 2006
Re: iTool Acccess to an iToolControl   Jason Eklund Oct 04, 2006
Re: iTool Acccess to an iToolControl   Kirk Kuykendall Oct 05, 2006
Re: iTool Acccess to an iToolControl   Jason Eklund Oct 04, 2006
Re: iTool Acccess to an iToolControl   Jason Eklund Oct 04, 2006
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject iTool Acccess to an iToolControl 
Author Fred Griggs 
Date Sep 27, 2005 
Message I have a ComboBox on a form, implementing iCommand & iToolControl.

In a second class within this vb.net project, I have a tool for MouseDown edits, implementing iCommand & iTool.

Though this builds OK, I can neither add to the named Customization Category, nor can I load the generated dll/tlb file.

Can anyone please advise:
1) Should I implement iCommand in both classes?
2) Should the second class be a COM class?

For the record, I've had each working thro separate DLLs linked with iToolbarControlDef -- but was unable to pass info between them! (ref: 'Accessing a ToolControl from iTool', at http://forums.esri.com/Thread.asp?c=93&f=993&t=169922#500587).

Suggestions would be really appreciated,
Fred
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: iTool Acccess to an iToolControl 
Author Kirk Kuykendall 
Date Sep 27, 2005 
Message I would try adding a method to the class that implements IToolControl that returns whatever the current item is in the combobox.

Your class that implements ITool would call ICommandBars.Find, passing a UID for the class that implements IToolControl. It would then QI ICommandItem.Command for the (default) interface that has the method on it described in first paragraph.

Not sure about the registration problem ... Are you using .NET? If so, are you registering your classes with the interop? If not, have you set binary compatibility? 
  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: iTool Acccess to an iToolControl 
Author Neil Clemmons 
Date Sep 27, 2005 
Message To build on Kirk's response, both classes must implement ICommand. In .NET, any ArcObjects interface you implement must be done inside a COM Class (a regular class module will not do) because registration with COM interop is required. Use the Component Registrar add in to register your classes with the component categories (you cannot use the Customize dialog in ArcMap to do this). When installing on machines other than your development machine, you will need to add an Installer class to your project to fire off the registration code and create a .NET installer project to perform the install. 
  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: iTool Acccess to an iToolControl 
Author Fred Griggs 
Date Sep 28, 2005 
Message Very many thanks to both Kirk and Neil.

Will work on your suggestions, and return should I encounter another 'brick wall'.

Fred


 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: iTool Acccess to an iToolControl 
Author Fred Griggs 
Date Oct 04, 2005 
Message Thanks again Kirk and Neil.

Adopting your suggestions I now have both COM classes (iToolContol & iTool) in a single project file, and working, from a call in a separate file implementing iToolBarDef.
However, the mechanism for retrieving the selected combobox value eludes me!
Would you be (very) kind enough to clarify on the code below?
Fred 
 
vb.net:
Dim pCmdBars As ICommandBars
Dim pCmdItem As ICommandItem

pCmdBars = m_Doc.CommandBars
pCmdItem = pCmdBars.Find(pUID) 'ok, using CLSID

Dim cmd As ICommand
cmd = pCmdItem.Command()  'ok but can't see my own iToolControl methods (only iCommand methods)

'However:
'proj_name.Form1.ComboBox1.SelectedIndex works,
'where ComboBox1 declaration set to Shared.

Fred
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: iTool Acccess to an iToolControl 
Author Jason Eklund 
Date Oct 04, 2006 
Message Kirk,

I know this post was about a year ago, but could you be a little more detailed about your explaination for passing the combo box value from the class that implements IToolControl back to a class that implements an ITool? 
  Jason Eklund
GIS Coordinator
Kittitas County, WA 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: iTool Acccess to an iToolControl 
Author Kirk Kuykendall 
Date Oct 04, 2006 
Message Write a class (MyClass) that implements ICommand and IToolControl. Put a getter on it called SelectedItem and have it return the item selected in the dropdown.

Either manually add MyClass to a commandbar, or write a toolbardef that has MyClass on it.

Use ICommandbars.Find and pass it the progid of MyClass.
This should return a reference to a ICommandItem.

You should be able to cast ICommandItem.Command to MyClass and call SelectedItem();

It might be better architecture though, to write an arcmap extension that MyClass is tied to. (This is sometimes called "model view controller" pattern). That way the tool and the command don't talk directly to one another, only to the IExtension.

 
  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: iTool Acccess to an iToolControl 
Author Jason Eklund 
Date Oct 04, 2006 
Message Got it, makes sense.

With IExension then, this is just a new class that implements IExtension, but not defined in the IToolbarDef class?

Thanks for the post. 
  Jason Eklund
GIS Coordinator
Kittitas County, WA 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: iTool Acccess to an iToolControl 
Author Kirk Kuykendall 
Date Oct 05, 2006 
Message Correct, the class that implements IExtension would represent the model in the Model-View-Controller pattern. Probably would want to have it raise an event when the value is changed so that later other view elements (e.g. other comboboxes) could be updated to reflect a change in the combobox. 
  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: iTool Acccess to an iToolControl 
Author Jason Eklund 
Date Oct 04, 2006 
Message One more thing...

I'm having a hard time figuring out how to cast this back to my class. Here is what I've got so far..

 
 
//' UID for clsGetWrisTargetLayerDropDown  

            UID pUID = new UIDClass();
            pUID.Value = "{8FA1304C-957C-434e-BF85-FEADC143107D}";

            ICommandItem pCommandItem = m_app.Document.CommandBars.Find(pUID, false, false);
      
 
  Jason Eklund
GIS Coordinator
Kittitas County, WA 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: iTool Acccess to an iToolControl 
Author Jason Eklund 
Date Oct 04, 2006 
Message Ok, I got it! Here is what worked for all you that have been following the post. Thanks Kirk for your help with this. I've only been programming in C# for about 2 months. 
 
//' UID for clsGetWrisTargetLayerDropDown  

            UID pUID = new UIDClass();
            pUID.Value = "{8FA1304C-957C-434e-BF85-FEADC143107D}";

            ICommandItem pCommandItem = m_app.Document.CommandBars.Find(pUID, false, false);
            ICommand pCommand = pCommandItem.Command;

            clsGetWrisTargetLayerDropDown oTargetLayerDropdown = new clsGetWrisTargetLayerDropDown();
            oTargetLayerDropdown = (clsGetWrisTargetLayerDropDown)pCommandItem.Command;
            string sTargetLayerName = oTargetLayerDropdown.proTargetLayerName;
 
  Jason Eklund
GIS Coordinator
Kittitas County, WA