HOW TO
This document contains an ArcObjects code sample that shows how to programmatically flash features in ArcMap.
Note:
Code in the project's ThisDocument code module only runs in the current map document. To store the code in all map documents, open the Normal.mxt ThisDocument code module instead.
Code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub LoopThruFeaturesAndFlash()
Dim pFeatLyr As IFeatureLayer
Dim pMap As IMap
Dim pDoc As IMxDocument
Set pDoc = Document
Set pMap = pDoc.FocusMap
'Get the selected features from the map.
Dim pEnumFeat As IEnumFeature
Dim pFeat As IFeature
Set pEnumFeat = pMap.FeatureSelection
Set pFeat = pEnumFeat.Next
Do Until pFeat Is Nothing
FlashFeature pFeat, pDoc
Set pFeat = pEnumFeat.Next
Loop
End Sub
Public Sub FlashFeature(pFeature As IFeature, pMxDoc As IMxDocument)
' Start drawing on screen.
pMxDoc.ActiveView.ScreenDisplay.StartDrawing 0, esriNoScreenCache
' Switch functions based on Geometry type.
Select Case pFeature.Shape.GeometryType
Case esriGeometryPolyline
FlashLine pMxDoc.ActiveView.ScreenDisplay, pFeature.Shape
Case esriGeometryPolygon
FlashPolygon pMxDoc.ActiveView.ScreenDisplay, pFeature.Shape
Case esriGeometryPoint
FlashPoint pMxDoc.ActiveView.ScreenDisplay, pFeature.Shape
End Select
' Finish drawing on screen.
pMxDoc.ActiveView.ScreenDisplay.FinishDrawing
End Sub
Private Sub FlashLine(pDisplay As IScreenDisplay, pGeometry As IGeometry)
Dim pLineSymbol As ISimpleLineSymbol
Dim pSymbol As ISymbol
Dim pRGBColor As IRgbColor
Set pLineSymbol = New SimpleLineSymbol
pLineSymbol.Width = 4
Set pRGBColor = New RgbColor
pRGBColor.Green = 128
Set pSymbol = pLineSymbol
pSymbol.ROP2 = esriROPNotXOrPen
pDisplay.SetSymbol pLineSymbol
pDisplay.DrawPolyline pGeometry
Sleep 300
pDisplay.DrawPolyline pGeometry
End Sub
Private Sub FlashPolygon(pDisplay As IScreenDisplay, pGeometry As IGeometry)
Dim pFillSymbol As ISimpleFillSymbol
Dim pSymbol As ISymbol
Dim pRGBColor As IRgbColor
Set pFillSymbol = New SimpleFillSymbol
pFillSymbol.Outline = Nothing
Set pRGBColor = New RgbColor
pRGBColor.Green = 128
Set pSymbol = pFillSymbol
pSymbol.ROP2 = esriROPNotXOrPen
pDisplay.SetSymbol pFillSymbol
pDisplay.DrawPolygon pGeometry
Sleep 300
pDisplay.DrawPolygon pGeometry
End Sub
Private Sub FlashPoint(pDisplay As IScreenDisplay, pGeometry As IGeometry)
Dim pMarkerSymbol As ISimpleMarkerSymbol
Dim pSymbol As ISymbol
Dim pRGBColor As IRgbColor
Set pMarkerSymbol = New SimpleMarkerSymbol
pMarkerSymbol.Style = esriSMSCircle
Set pRGBColor = New RgbColor
pRGBColor.Green = 128
Set pSymbol = pMarkerSymbol
pSymbol.ROP2 = esriROPNotXOrPen
pDisplay.SetSymbol pMarkerSymbol
pDisplay.DrawPoint pGeometry
Sleep 300
pDisplay.DrawPoint pGeometry
End Sub
Get help from ArcGIS experts
Download the Esri Support App