Avenue Wraps Samples
1. Getting Started
Document Related Samples
2. How to create a New Frame (View)
3. How to activate a Specific Frame (View)
4. How to change from a Data View to the Layout View
5. How to change from the Layout View to a Data View
6. How to get a list of active (selected) themes in the view
7. How to get a list of all themes in the view
8. How to get a list of all themes in the view expanding group layers
9. How to get a list of all feature layers in the view
10. How to get a list of all visible themes in the view
11. How to get a list of all tables in the view
12. How to add a Layer File programmatically
Theme and Table Related Samples
13. How to get the attribute table (FTab) for a theme
14. How to get the virtual table (VTab) for a table
15. How to determine theme type (point, polyline, polygon)
16. How to select all features in a theme
17. How to select a specific feature in a theme
18. How to delete all features in a theme
19. How to delete the selected features in a theme
20. How to delete a specific feature in a theme
21. How to select all records in a table
22. How to select a specific record in a table
23. How to delete all records in a table
24. How to delete the selected records in a table
25. How to delete a specific record in a table
26. How to uniquely classify a theme
27. How to store a value in a specific field for a specific record in a theme
28. How to store a value in a specific field for a specific record in a table
29. How to cycle through all features in a theme
30. How to cycle through the selected features for a theme
31. How to programmatically create a shapefile and add it to the view
32. How to prompt the user for the name of a shapefile and add it to the view
33. How to programmatically create a table and add it to the view
34. How to cycle through all records in a table
35. How to cycle through the selected features for a table
36. How to determine the type of a field
37. How to get the unique values of a field for a theme or a table
38. How to determine the type of a theme
File I/O Samples
39. How to write and read data to an ASCII file - Example 1
40. How to write and read data to an ASCII file - Example 2
Utility Samples
41. How to create and sort a collection (list)
42. How to display a progress bar without a stop or cancel button
43. How to display a progress bar with a stop or cancel button
44. Formatting numbers as strings
45. Hot to get and format the current Date
46. Drawing Graphic Text
Legend and Classification Samples
47. How to assign a unique classification to a theme
48. How to process labels and symbols in a classification
Feature Geometry Samples
49. How to create polyline geometry from a list of coordinates
50. How to process polyline geometry
51. How to process polygon geometry
Message Box Samples
52. How to create a dialog box combining data line and combo-box items
Join and Link Samples
53. How to join a table to a theme
54. How to link a table to a theme
55. How to link two themes and zoom to the Selected Features
Graphic Elements Samples
56. How to find graphic elements in an Annotation Group layer
57. How to parse the graphic elements in the Layout View
58. How to find all of the graphic text elements in a Data View
59. How to find all of the graphic text elements in the Layout View
60. How to convert selected graphic text elements into Callouts
Printing Samples
61. How to print the current map
62. How to print the current map from the Layout View
Attribute Editing Sample
63. How to display and edit the attributes of a selected feature
1. Getting Started
The first step in using the Avenue Wraps "wraparounds" is to reference the Avenue Wraps DLL file, avwraps.dll. It is recommended that the DLL implementation, rather than the Avenue Wraps document file, avwraps.mxd, be used, essentially for two reasons. The first is that the document file requires ArcGIS Version 8.2. If the user is not using this version, the user will not be able to open the document file. The second reason is that the DLL implementation does not include the Avenue Wraps code so that the application which the user develops will be smaller in size. If the user wishes to modify the Avenue Wraps "wraparounds", the VB project file, avwraps.vbp, can be used to create a new DLL version of the Avenue Wraps "wraparounds".
The following steps describe how to reference the avwraps.dll file in a new ArcMap document file (8.x or 9.x).
1 Invoke ArcMap.
2 Accept the default selection to create a new empty map, and click at the OK button.
3 Click at the Tools menu and then at the Macros and Visual Basic Editor sub-menus.
4 Click at the Tools menu and then at the References... sub-menu.
5 Click at the Browse button to display the Add Reference file dialog box.
6 Navigate to the directory in which the avwraps.dll file is located.
7 Click at the name of the avwraps.dll file.
8 Click at the Open button.
9 Click at the OK button to confirm.
10 Click in the square containing the plus (+) character to the left of the folder called ArcMap Objects under the Project group in the Project window.
11 Double-click on the ThisDocument module name.
12 Scroll down in the Object drop-down list and select the MxDocument name.
13 Scroll down in the Procedure drop-down list and select the OpenDocument name.
14 Insert the line Call avInit(Application) in the OpenDocument procedure.
15 Click the Run Sub/UserForm tool to execute the subroutine. This will initialize the Avenue Wraps global variables.
The avwraps.dll has now been referenced in the VBA application, and all of the Avenue Wraps are now available to the developer. The user can now create new modules and begin to convert existing Avenue code or develop new code using the Avenue Wraps "wraparounds".
Note that any time a new module is inserted in the ArcMap document file, the OpenDocument procedure will need to be re-executed. The OpenDocument procedure is a good location to perform any initialization that may be required.
2. How to create a New Frame (View)
'
Dim pMxApp As IMxApplication
Dim pmxDoc As IMxDocument
Dim pActiveView As IActiveView
Dim pMap As IMap
'
' ---Get the active view
Call avGetActiveDoc(pMxApp, pmxDoc, pActiveView, pMap)
'
' ---Create a new frame or view
Set pMap = avViewMake
'
' ---Activate the new frame or view
Set pActiveView = pmxdoc.ActiveView
'
' ---Check if we are in Layout view
If TypeOf pActiveView Is IPageLayout Then
Set pmxdoc.ActiveView.FocusMap = pMap
' ---Handle case when we are in Data view
Else
Set pmxdoc.ActiveView = pMap
End If
'
' ---Define the name of the new frame
pMap.Name = "New_View"
'
' ---Update the Table of Contents to reflect the name change
' ---of the new frame or view
Call avInvalidateTOC(Null)
'
' ---Set the map and distance units for the new frame
pMap.MapUnits = esriInches
pMap.DistanceUnits = esriInches
3. How to activate a Specific Frame (View)
This sample illustrates how a list of the data frames in the
current
document can be presented to the user in a
choice message box, from which,
the user can select one, which then becomes
the active data frame in
the current document. If this procedure is run from the Layout
View,
the code below will change the map display
to be in Data View after
activating the data frame.
'
Dim pMxApp As IMxApplication
Dim pmxDoc As IMxDocument
Dim pActiveView As IActiveView
Dim pMap As IMap
Dim aList As New
Collection
Dim pMaps As IMaps
Dim D As
Long
Dim aMap As IMap
Dim ians
As Variant
Dim doc_name As Variant
Dim pApp
As IApplication
Dim pUID As New UID
Dim pCmdItem As
ICommandItem
'
' ---Handle any
errors that may occur
On Error GoTo
Errorhandler
'
' ---Get the active view
Call avGetActiveDoc(pMxApp, pmxDoc, pActiveView, pMap)
'
' ---
' ---Get a list of
the maps in the current document
' ---
Call CreateList(aList)
Set pMaps = pmxdoc.Maps
For D = 1 To pMaps.Count
Set aMap = pMaps.Item(D - 1)
aList.Add (aMap.Name)
Next
'
' ---
' ---Sort the data
frames alphabetically in an ascending order
' ---
Call SortTwoLists(aList, Nothing,
Null, True)
'
' ---
' ---Get the data
frame that is to be activated
' ---
Call avMsgBoxChoice(aList, _
"Select the Data Frame to be Activated:",
_
"Activate Data Frame", ians)
'
' ---Check if the
command is to be aborted
If (IsNull(ians))
Then
Exit Sub
End If
'
' ---
' ---Find the data
frame and set the IMap object
' ---
doc_name = Null
For D = 1 To pMaps.Count
Set aMap = pMaps.Item(D - 1)
If (UCase(aMap.Name) = UCase(ians)) Then
doc_name = ians
Exit For
End If
Next
'
' ---
' ---Check if an
existing frame or view was found
' ---
If (Not IsNull(doc_name)) Then
'
' ---Activate the data
frame
Set pActiveView =
pmxdoc.ActiveView
'
' ---Determine if we are
in a Data View or the Layout View
If TypeOf pActiveView Is IPageLayout Then
'