Some tips and tricks for customizing ArcView 3x using Avenue
User Interface Modifications
- You cannot have a tool selected and invisible at startup as of ArcView version 3.1.
- A common symptom of menu bars without menu items is that the portion of the screen occupied by the menu bar is not refreshed properly. To force ArcView to refresh the menu bar display you must have at least one menu item present on the menu bar, even if it is invisible.
- To delete custom icons from the icon list do the following. First, get a reference to the icon using the name dictionary. Next, clone the existing system icon dictionary and take the returned key-value pair from step one to remove the entry in the dictionary. Copy this new dictionary, minus one icon, back into the system icon dictionary.
- Making the legend of themes in the View invisible can be a useful technique for making the the View document TOC appear less cluttered, particularly when there are a lot of themes in a View.
- Tool tips can be generated by placing two forward slashes (\) followed by the tool tip text in the help string associated with a control.
- When developing a GUI, take a screen shot and mark it up with the names of scripts associated with each control to facilitate organizing the scripts associated with a particular document.
- Stacks are useful data structures to use to remember previous user actions and enable “undo” functionality in your applications.
- The Activate request associates a GUI with a document for one time only. The next time the document is opened the original GUI will be associated with it.
- The project table of contents window, the window from which you manage all of the Views, Tables, Charts, Layouts, and Scripts, can have the width of its table of contents (TOC) modified. This is particularly useful if you introduce a new document type that has a unique icon to display in the TOC. However, modifications to the project document window width must be restored to the original default width prior to closing the project to avoid crashing ArcView.
Data Loading and Query
- The only way to check if a filename is valid for a datasets is to use the static File.Exists(SrcName.AsFileName) request.
- The GetFullName request is useful for expanding filenames which have an environment variable into full pathnames free of the environment variable.
- To select all of features within “x” distance of the currently selected features use the SelectByTheme request with the same theme as controlling object and in the argument list.
- If you want to preserve an existing selected set, clone the bitmap prior to performing the new selections. When finished, copy the cloned bitmap back to restore the originally selected set.
- There are two types of bitmaps, selection and definition, which corresond to the query and definition items in the “Theme Properties” dialog. The former causes selected features to display with the selected color, yellow by default. The latter limits the display of features to only those in the selected set.
- A persistent dictionary is associted with every extension object called the extension preferences dictionary. Use this dictionary to store persistent global properties used by your extension.
- Use the the $HOME environment variable to define a directory to store your extensions. When launched, ArcView will search for extensions in multiple locations, including the directory associated with the $HOME environment variable as well as the ext32 subdirectory in the ArcView installation directory. You can set this environment variable in Windows 95 and 98 using the autoexec.bat file and in Windows NT from the System->Properties->Environment tab in the Control Panel.
- Whenenver you modify the default document graphical user interface (GUI), you will have to write a script to reload the original, unmodified GUI when it comes time to close the extension. One option is to write the existing controls, which themselves may contain modifications of the default document GUI, to a temporary object (ODB) file on disk. When you unload the extension, open the ODB file and reload the user’s original GUI. Remember to delete the temporary ODB file you created.
- When passing arguments to scripts that are single objects, use the SELF keywrd to retrieve the object inside of the called script. In contrast, arguments passed as lists must be retrieved by index eg SELF.Get(2).
- Always use “return NIL” at the conclusion of your scripts rather than “exit”, which terminates the current script as well as any other executing scripts.
- The av.FindScript() request is more comprehensive than av.GetProject.FindScript().
- The ExecuteSyncronous request should be used with system commands if you need to use the outcome of the system command immediately.
- There is a limit to the number of charcters supplied to the System.Execute request. Use a batch file if you must excede this limit.
- If an object has been copied to the clipboard during its lifetime, then purge the clipboard of its associated objects prior to deleting it to avoid an ArcView crash.
- Remember to use the av.GetProject.SetModified(true) request whenever modifying GUIs or deeleting themes from a document via Avenue.
- To limit the amount of error checking in your code use the Update property associated with controls to enable or diable the script from being called under inappropriate conditions.
- List data structures must be cloned before you can delete mutable objects otherwise you will get an array access error.
- The SetDynamicBreak request can be used for conditional debugging such as when you want to break at the 10th iteration in a loop rather than the first iteration.
- ObjectTags associated with controls, documents, themes, and graphics provide another means for persistent storage of objects. Since they remain even when project is saved and closed, use this mechanism only when necessary to avoid the accumulation of these objects and subsequent ballooning of project files.
- When using dialogs created from the dialog document type you must have the dialog designer extension (avdlog.avx) loaded, otherwise, when dialogs are created directly from Avenue code, you only need to have avdlog.dll and avdlog.dat in the system path to create dialogs.
- Use the Flush request before launching a modal dialog over a Display object to prevent ghosting behind the dialog should the user move the dialog around.