Original User: ScoleThanks, Neil. What you describe makes sense. I decided to pursue your suggestion and implemented an event listener on the AfterDraw event. I wasn't quite sure how to do it since I've never done one before but, after some reading up on the issue, it seems to work like I want it to. For the benefit of others, here's what I did:I used the event listener code for the .NET snippet named "Add Event Wiring for All IActiveViewEvents Snippet." To backtrack, my code to zoom to a parcel's extent is contained in the click event of a dialog form. In the declaractions part of the VB code for the form, I inserted: Private m_ActiveViewEventsAfterDraw As ESRI.ArcGIS.Carto.IActiveViewEvents_AfterDrawEventHandler
Dim pGeometry As ESRI.ArcGIS.Geometry.IGeometry = Nothing
The event handler requires a small subroutine to initiate it so I added the following into the main body of VB code for my form: Private Sub SetupActiveViewEvents(ByVal map As ESRI.ArcGIS.Carto.IMap)
If map Is Nothing Then
Return
End If
Dim activeViewEvents As ESRI.ArcGIS.Carto.IActiveViewEvents_Event = TryCast(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event)
'Create an instance of the delegate, add it to AfterDraw event
m_ActiveViewEventsAfterDraw = New ESRI.ArcGIS.Carto.IActiveViewEvents_AfterDrawEventHandler(AddressOf OnActiveViewEventsAfterDraw)
AddHandler activeViewEvents.AfterDraw, m_ActiveViewEventsAfterDraw
End Sub
That could is straight off of the snippet. Nothing custom yet. The next thing I inserted was the subroutine that gets triggered by the AfterDraw event and it is also inserted into the main body of VB code: Private Sub OnActiveViewEventsAfterDraw(ByVal display As ESRI.ArcGIS.Display.IDisplay, ByVal phase As ESRI.ArcGIS.Carto.esriViewDrawPhase)
'Highlight the parcel's shape on screen
Dim pFillSymbol As ESRI.ArcGIS.Display.ISimpleFillSymbol
Dim pLineSymbol As ESRI.ArcGIS.Display.ILineSymbol
Dim pRgbColor As ESRI.ArcGIS.Display.IRgbColor
Dim pScreenDisplay As ESRI.ArcGIS.Display.ScreenDisplay = Nothing
Dim pActiveView As ESRI.ArcGIS.Carto.IActiveView
If Not pGeometry Is Nothing And phase = ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewForeground Then
pActiveView = My.ArcMap.Document.FocusMap
pFillSymbol = New ESRI.ArcGIS.Display.SimpleFillSymbol
pRgbColor = New ESRI.ArcGIS.Display.RgbColor
pLineSymbol = pFillSymbol.Outline
pRgbColor.Red = 255
pLineSymbol.Width = 2.25
pLineSymbol.Color = pRgbColor
pFillSymbol.Color = pRgbColor
pFillSymbol.Outline = pLineSymbol
pFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSHollow
pScreenDisplay = pActiveView.ScreenDisplay
pScreenDisplay.StartDrawing(pScreenDisplay.hDC, CShort(ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache))
pScreenDisplay.SetSymbol(pFillSymbol)
pScreenDisplay.DrawPolygon(pGeometry)
pScreenDisplay.FinishDrawing()
pGeometry = Nothing
End If
End Sub
Everything in the sub is what I wrote. I had to give this subroutine a way to access the parcel's geometry so that is why I declared it globally at the top of the class. I also discovered that the AfterDraw event is triggered multiple times during one redraw (due to the various "phases"). The esriViewForeground is the last phase in the sequence so that's why I specifcally mention it in my IF..THEN block.It's also important to set the geometry to Nothing at the end of this routine. If you do not, it will keep drawing the shape on the screen (even though the form is dismissed).The last step is very simple. In the subroutine for my form's OK button click event, I added this line to actually fire off the event listener:SetupActiveViewEvents(pMap)
That's it. The display zooms to the parcel and it gets a red outline. The next display refresh wipes it clean. Thanks again for the pointing me in the right direction, Neil!Cheers,Steve