:
|
ArcInfo Version 8.0 will contain the same core modules ArcInfo always has had but will also add three new application--ArcCatalog, ArcToolbox, and ArcMap. Attendees at the 1998 Esri user conference in San Diego, California, learned that these new applications represent a stimulating new approach to working with GIS. With ArcCatalog and ArcMap, both the customization environment and the applications are exciting and powerful. This will be the focus of this article. What Does It Mean to Customize Your Application?By definition, customization means the tailoring or altering of an object, according to a set of predetermined requirements or specifications. Application customization means to modify the user interface or functionality to fit the specific needs of a user or market niche. Users of the new ArcInfo Version 8.0 applications have the opportunity to customize in an environment that is highly flexible and extensible. The new applications, ArcCatalog and ArcMap, are based on Microsoft's Component Object Model (COM). As a result, the basic building block for application programming and problem solving is the object. There are requirements that any object needs to meet if it is to work properly in the object models employed by ArcInfo Version 8.0. Once these conditions are met, a custom object, tool, toolbar, or script can be plugged into the application framework of or ArcMap. What does this mean for ArcInfo users? It means customizing the user interface or extending the functionality of these new applications is easier and more robust than ever before. Every version of ArcCatalog and ArcMap will be shipped with a licensed version of Microsoft's Visual Basic for Applications (VBA). Microsoft designed VBA to be embedded in applications to provide a seamless, integrated programming environment throughout the application. VBA is built into the Microsoft Office line of products.Visual Basic (VB) is Microsoft's stand-alone programming environment. Both VB and VBA provide many useful tools and each offers a complete interactive development environment (IDE), helpful for easy application development. VB and VBA hide much of COM's complex nature, allowing users to focus on their work rather than spend valuable time learning a new programming language. VB has proven to be the most popular choice among developers due to its relatively short learning curve and its expansive capabilities. VB and VBA are not the only available choices for developers. Since ArcCatalog and ArcMap have been built on COM, any programming language that supports COM, such as Visual C++ (VC++), Visual J++, or Delphi, can be used for application development or customization.COM Basics COM consists of objects and interfaces to those objects. In COM, the interfaces provide the mechanism for object manipulation. The interfaces are composed of one or more related methods, properties, or events. Methods commonly represent some action the object is to take, such as rotate or draw. Properties monitor a particular condition of the object. Examples are count or name. Events are methods that notify the rest of the system when something has happened relating to its object. Interfaces then determine how clients of an object interact with, manipulate the object, and define what can and cannot be done with the object. This diagram illustrates this relationship. Should I Use VBA or Another Language That Supports COM? Anyone interested in customizing ArcCatalog or ArcMap has a choice in the development environment they wish to use. Should the product integrated programming language VBA be used or should some other language that fully supports COM be selected? There are definite advantages and disadvantages with either choice. Opting to use VBA as the vehicle for moving your customizations into ArcMap or ArcCatalog is a good choice because it is fully integrated within these applications. Using VBA, there is no overwhelming need to compile a Dynamic Link Library (DLL), register it onto the host computer, and load it into the application to execute it as a custom tool. VBA provides a run-time development environment for you to create custom processes enhancing your version of the application. For example, if you are using VBA for customization, ArcMap could already be running when you create a new macro. You could write the macro and run it without having to shut the application down. With VBA you have the ability to write and debug your macro while running the application. Variables and results can be checked and performance can be monitored, all without having to exit the host application. VBA is also the simplest choice to make as it is relatively easy to learn in comparison to other programming environments. Nevertheless, VBA does have drawbacks. Since the scripts you write are local to the map document file, source code can be exposed to a user. If you need your code compiled, encrypted, or inaccessible, you should be writing DLLs in a programming environment that will facilitate these requirement--you should not be using VBA.The code shown here is a simple VBA example showing how one could code the objects displayed in the diagram below. What are some other reasons to choose a programming language other than VBA? If you already know and are proficient with another language that supports COM, such as Visual C++, you can continue to use it. If you are a developer who is looking to create and distribute a command tool, such as a toolbar or menu, and don't want to be restricted to the scope of a single document file or just want to maintain proprietary code, then creating custom COM components is what you want to do. Creating custom COM commands requires a different approach. You must manage the interfaces and the implementation of the object programmatically. This diagram displays a simple COM object. In this example Parcel is an object and IUpdate and ITax are interfaces to it. IUpdate and ITax have methods such as Split and PropertyAssessment. Parcel inherits any properties that IZoning, another interface, posseses. How Can I Customize ArcCatalog and ArcMap? There are several ways ArcCatalog and ArcMap can be customized. As mentioned earlier, one way is to write code extending the base functionality. Simply adding or removing toolbars from the user interface can also customize ArcMap and ArcCatalog. Here is a sample toolbar present in the ArcMap application. A toolbar can be checked on or off so it may or may not display as a part of your user interface. You can also drag any toolbar to or from the user interface, docking or undocking it. An undocked toolbar can float about the desktop but is still able to operate with the application. Once you have written a custom script, it can be added to a toolbar by dragging and dropping it from a menu that manages the various tool categories that the application is aware of.
Once a tool is part of a toolbar, it need not remain there. Users have the option of removing a tool from the user interface by dragging a tool from a toolbar. A command tool can be repositioned anywhere on a toolbar or dragged to a different toolbar. ArcMap and ArcCatalog also come with an interface that allows users to map their keyboards. Users can set hot keys to perform actions typically performed by clicking a button or running a script. Another way for a user to customize the functionality of ArcMap or ArcCatalog is to execute scripts and macros directly without adding them to a command tool (i.e., physically adding them to the interface). Any and all of these changes can be made persistent, or saved, to the application. ArcMap and ArcCatalog come with templates that work in a fashion similar to the templates in Microsoft Word. The default template in ArcMap is called the normal template file. When ArcMap is started, the application creates a default document file. Users can add data and save any version of ArcMap to a document file. Customizations are then stored within the document file loaded when the application is started. These files can be re-opened in subsequent ArcMap sessions and any customizations made to those templates will be restored and reactivated. Technology available today, such as COM, has enabled Esri to create new applications to better serve you, the user community. These applications are designed to give the GIS world the tools necessary to solve those problems that haven't been solved yet and design better solutions for current issues. The customization environment available in the new applications in ArcInfo Version 8.0 will allow you to model real world objects in real world terms to create more meaningful and useful tools and applications. How Can I Learn More About COM and VBA? Customizing ArcCatalog and ArcMap is entirely based on using COM. If you're interested in learning more about COM and working with VBA, here are some books that may help. Chappel, D. Understanding ActiveX and OLE. Redmond, Washington. Microsoft Press; 1996.Rogerson, D. Inside COM. Redmond, Washington: Microsoft Press, 1997. Boctor, D. Step by Step Microsoft Office 97 Visual Basic., Redmond, Washington. Microsoft Press, 1997. Getz, K. and Gilbert M. VBA Developer's Handbook. Alameda, California. Sybex Inc., 1997. |