How to use the samples

This topic provides general information on how to setup and remove Tool samples that are commands, toolbars, menus, or other types that work with component categories. Instructions on how to add the samples to and remove the samples from the ArcGIS applications are provided here. Additionally, each sample has a help topic with detailed instructions on how to use that particular sample.

Source code location
Add sample commands, toolbars, and menus to an ArcGIS application
Add other samples that work with Component Categories to an ArcGIS application
Remove sample commands, toolbars, and menus from an ArcGIS application
Remove other types of samples from an ArcGIS application

Source code location

The source code for Tools samples is located in the 'C:\arcgis\arcexe83\ArcObjects Developer Kit\Samples\' folder. The Samples folder has the same sub-folder structure as the Samples TOC in the help system.

Run the ArcObjects Developer Kit setup to get the full ArcObjects Developer Kit installed on you computer. The ArcGIS Desktop setup program provides the option to install the ArcObjects Developer Kit at the end of the installation process. If you did not choose to install the ArcObjects Developer Kit during the initial ArcGIS Desktop installation, you can start the installation at any time using the setup.exe located on the ArcGIS Desktop CD #1 in the \ArcGIS\ArcObjects Developer Kit folder.

Also, on ArcObjects Online (http://www.esri.com/arcobjectsonline) every sample page has a download associated with it containing the actual source code files.

Add sample commands, toolbars, and menus to an ArcGIS application

For sample commands (buttons, tools, or toolcontrols), toolbars, or menus you need to register the DLL and also add the sample to the appropriate component category. The easiest way to do this is to use Add from file button on the Customize dialog in ArcGIS application for which this sample was designed.

How to add custom commands, toolbars, and menus using Add from File

  1. Start the ArcGIS application (ArcMap, ArcCatalog, or ArcScene) that you are adding the sample to.
  2. Click the Tools menu and click Customize.
  3. Click Add from file.
  4. Navigate to the DLL file containing the custom command, toolbar, or menu.
  5. Click the file and click Open.
    The Added Objects dialog box appears, reporting which new objects have been registered with ArcMap, ArcCatalog, or ArcScene.
  6. Click OK.
    The DLL has been registered on your computer and the command, toolbar, and menu components contained in the DLL have been added to the proper component categories.
  7. Click the Toolbars tab.
  8. Check the custom toolbar that was added or check the toolbar to which you want to add the custom command or menu.
  9. Click the Commands tab.
  10. If the sample is a command, click Developer Samples in the Categories list.
    If the sample is a menu, click Menus in the Categories list.
  11. Click and drag the command or menu from the Commands list and drop it on the toolbar.
  12. Click Close.

The sample is now ready to use. Refer to the Requires section in the help topic of the sample to see if you need to do anything before using the sample such as adding specific data, starting an edit session, etc.

Add other samples that work with Component Categories to an ArcGIS application

For other types of samples (extensions, tasks, views, renderers, etc) that require adding the sample a component category other than commands or commandbars, follow these steps.

  1. Register the DLL for this sample by compiling the source code project file for the sample or by using Regsvr32.exe.
    • To register a component using Regsvr32
      1. From the Taskbar click Start>Run
      2. Type:
           regsvr32 <your file path name>
        For example:
           regsvr32 D:\Samples\Application Framework\Sample Extension\SampleExtension.dll
      3. Click OK.
  2. Use the Component Category Manager utility to add the sample to the appropriate component category. Refer to the help topic on the in the Utilities section of the help for information on how to use this utility. The How to use section of the help topic for the sample will tell you what component category the sample needs to be added to. Once the sample is added to the appropriate component category, the ArcGIS application will automatically know about the new objects.
  3. Shutdown and restart the ArcGIS application that this sample is designed for.
  4. Refer to the How to use and Requires section in the help topic of the sample to see if you need to do anything else before using the new functionality.

Remove sample commands, toolbars, and menus from an ArcGIS application

If you no longer want a sample command, toolbar, or menu to be available in the ArcGIS applications, you need to manually remove the sample from the component category that it's registered with. Refer to the help topic on the in the Utilities section of the help to learn how to remove an object from a component category. You will remove the sample from one of the following component categories.

Sample Type Component Category
ArcMap commandsESRI Mx Commands
ArcMap toolbars and menusESRI Mx CommandBars
ArcCatalog commandsESRI GX Commands
ArcCatalog toolbars and menusESRI GX Command Bars
ArcScene commandsESRI Sx Commands
ArcScene toolbars and menusESRI Sx Command Bars

How to remove sample commands and menus

  1. Remove the sample command or menu from all toolbars and menus that it appears on in the Normal template.
    1. Start the ArcGIS application (ArcMap, ArcCatalog, or ArcScene) that the sample was added to.
    2. Click the Tools menu and click Customize.
    3. Click the Commands tab on the Customize dialog box.
    4. Select the Normal template (Normal.mxt. Normal.gxt, or Normal.sxt) in the Save in combo box.
    5. Drag the sample command or menu off all toolbars and menus.
    6. Click Close.
      The Normal template will automatically get saved when you create a new document, open a document, or exit the application.

    NOTE: Instead of following Step 1, you could alternatively delete the Normal template file for the ArcGIS application the sample was added to.

    • ArcMap: Normal.mxt
    • ArcCatalog: Normal.gxt
    • ArcScene: Normal.sxt

  2. Remove the sample command or menu from all toolbars and menus that it appears on in all ArcMap and ArcScene documents.
    1. Start the ArcGIS application (ArcMap or ArcScene) that the sample was added to.
    2. Open a document that has the sample command or menu saved on a toolbar or menu.
    3. Click the Tools menu and click Customize.
    4. Click the Commands tab on the Customize dialog box.
    5. Select the current document in the Save in combo box.
    6. Drag the sample command or menu off all toolbars and menus.
    7. Click Close.
    8. Save the document.
    9. Repeat steps 2 a-h for all documents that uses this sample.
  3. Remove the sample command or menu from all toolbars and menus that it appears on in all ArcMap templates.
    1. Start the ArcMap.
    2. Open a template file using File/Open.
    3. Click the Tools menu and click Customize.
    4. Click the Commands tab on the Customize dialog box.
    5. Select this template in the Save in combo box.
    6. Drag the sample command or menu off all toolbars and menus.
    7. Click Close.
    8. Save the template.
    9. Repeat steps 3 a-h for all templates that use this sample.
  4. Run the Component Category Manager and remove the sample from the component category that it's registered with. Refer to the table above to find out what category to remove the sample from.

NOTE: If you are not using any of the components that are contained in the DLL for this sample now, it is also a good idea to unregister the sample DLL.

  • To unregister a command or menu using Regsvr32
    1. From the Taskbar click Start>Run
    2. Type:
         regsvr32 /u <your file path name>
      For example:
         regsvr32 /u D:\Samples\Application Framework\Sample Extension\SampleExtension.dll
    3. Click OK.

How to remove sample toolbars

  1. Delete the Normal template file for the ArcGIS application the sample was added to.
    • ArcMap: Normal.mxt
    • ArcCatalog: Normal.gxt
    • ArcScene: Normal.sxt
    The next time you start the ArcGIS applications, a new Normal template will be generated.
    Note, if your Normal template contains other customizations that you would like to keep, you could unregister the DLL for this sample instead of deleting the Normal template. See note below for information on how to unregister the DLL.
  2. Run the Component Category Manager and remove the sample from the component category that it's registered with. Refer to the table above to find out what category to remove the sample from.

NOTE: If you are not using any of the components that are contained in the DLL for this sample now, it is also a good idea to unregister the sample DLL.

  • To unregister a toolbar using Regsvr32
    1. From the Taskbar click Start>Run
    2. Type:
         regsvr32 /u <your file path name>
      For example:
         regsvr32 /u D:\Samples\Application Framework\Sample Extension\SampleExtension.dll
    3. Click OK.

Remove other types of samples from an ArcGIS application

If you no longer want a sample to be available in the ArcGIS applications, you can remove the sample from the component category that it's registered with. Refer to the help topic on the in the Utilities section of the help to learn how to remove an object from a component category. The How to use section of the help topic for the sample will tell you what component category this sample is registered with.