CommandsAndToolsfrmControls.frm
' Copyright 2006 ESRI
'
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
'
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
'
' See the use restrictions.
Option Explicit
Private m_pMxDoc As esriArcMapUI.IMxDocument
Private m_pCompNotify As esriSystemUI.ICompletionNotify
Public Property Set Doc(pDoc As esriArcMapUI.IMxDocument)
Set m_pMxDoc = pDoc
End Property
Public Property Set CompNotify(pCompNotify As esriSystemUI.ICompletionNotify)
Set m_pCompNotify = pCompNotify
End Property
' Fill the combobox with all layers in the current data frame
Public Sub UpdateLayerList()
Dim pMap As esriCarto.IMap
Set pMap = m_pMxDoc.FocusMap
Dim selLayerName As String
selLayerName = frmControls.cboLayers.Text
frmControls.cboLayers.Clear
' Add the layers
Dim pLayer As esriCarto.ILayer
Dim i As Integer
For i = 0 To pMap.LayerCount - 1
Set pLayer = pMap.Layer(i)
frmControls.cboLayers.AddItem pLayer.Name
Next
Dim cboIndex As Integer
For cboIndex = 0 To frmControls.cboLayers.ListCount - 1
If frmControls.cboLayers.List(cboIndex) = selLayerName Then
frmControls.cboLayers.ListIndex = cboIndex
Exit For
End If
Next
End Sub
Private Sub cboLayers_Click()
Dim pMap As esriCarto.IMap
Set pMap = m_pMxDoc.FocusMap
Dim selLayerName As String
selLayerName = frmControls.cboLayers.Text
Dim pLayer As esriCarto.ILayer
Dim i As Integer
For i = 0 To pMap.LayerCount - 1
If pMap.Layer(i).Name = selLayerName Then
Set pLayer = pMap.Layer(i)
End If
Next
Dim pEnv As esriGeometry.IEnvelope
Set pEnv = pLayer.AreaOfInterest
m_pMxDoc.ActiveView.Extent = pEnv
m_pMxDoc.ActiveView.Refresh
If Not m_pCompNotify Is Nothing Then m_pCompNotify.SetComplete
End Sub
Private Sub Form_Terminate()
Set m_pCompNotify = Nothing
Set m_pMxDoc = Nothing
End Sub