
| Home | Portfolio | Resume | Photos |
Lesson 3: Intro to Programming ArcObjects (Part 2)
Jim Kompanek
Reflection on Lesson 2
I found Lesson 2 to be greatly challenging. The first task was to write a small bit of code that loops through each available data frame within the map document and either expands a collapsed data frame's list of layers, or collapses an expanded data frame's list of layers. I found that the easiest portion of this code was writing a simple If Then block. Unfortunately, the real challenge was getting this apply to multiple data frames. After scouring through all of my available documentation, all signs pointed towards the IEnumMap interface, which also seemed very similar to some of the examples within the lesson. Unfortunately, this interface does not work with ArcGIS 9.2 but luckily, we were warned about this ahead of time. After re-rereading the concept gallery and textbook, I was able to put something together that "should" have worked. The code compiled and executed with no errors but it did not work; all it did was cause the last data frame in the Table of Contents (TOC) to become active. After a very frustrating period of time, it dawned on me that I forgot (even though it was specifically mentioned in the lesson) to call UpdateContents at the end. After doing so, everything appeared to work fine.
The second deliverable of this lesson involved writing a short piece of code that gets the first three letters of an input string and then convert those letters to all capitals. These letters would then be displayed in a text box. This deliverable served as a nice confidence builder, as it did not take much time to put together. I found that making a flow chart of exactly what I wanted to do made things very simple. At that point, it involved just going through the VB help file to figure out how to put it all together.
The last deliverable of this lesson was to modify the customization created in part I of this lesson. (Figure 1) The primary goal was to eliminate redundant code by using two separate modules (one for zooming in and one for zooming out). As with the previous deliverable, I found that creating a flow chart aided immensely. Unlike the first deliverable, I was able to complete this in a relatively short period of time. One somewhat annoying quirk that did develop (we were previously warned of this) was that the message reporting the old and new scales only flashed very briefly in the status bar. I attempted to fix this but was ultimately unable to. To verify that everything was working OK, I actually reported the results of the zoom in/out in a message box to see if everything worked OK. For the purpose of this lesson, I chose to use two modules (one for zooming in and one for zooming out). Even though the code is nearly identical, except for a single line, I chose to use two modules for simplicity. By using two modules, I was able to simply use one variable in the call function. If I had chosen to use more variables, I could have used one module to control both zooming in and zooming out.

Figure 1. "My Zoom" customization for Part II of this Lesson.
This document is published in fulfillment of an assignment by a student enrolled in an educational offering of The Pennsylvania State University. The student, named above, retains all rights to the document and responsibility for its accuracy and originality.