📄 maptips.frm
字号:
VERSION 5.00
Begin VB.Form frmMapTip
Caption = "地图提示"
ClientHeight = 1800
ClientLeft = 60
ClientTop = 345
ClientWidth = 5250
LinkTopic = "Form1"
ScaleHeight = 1800
ScaleWidth = 5250
StartUpPosition = 2 'CenterScreen
Begin VB.ComboBox cboSelectFiled
Height = 315
Left = 960
TabIndex = 6
Top = 600
Width = 4095
End
Begin VB.CommandButton CommandCabcel
Caption = "取消"
Height = 375
Left = 2280
TabIndex = 5
Top = 1200
Width = 1095
End
Begin VB.CommandButton CommandApply
Caption = "应用"
Height = 375
Left = 3600
TabIndex = 4
Top = 1200
Width = 1095
End
Begin VB.CheckBox chkShowTips
Caption = "显示提示"
Height = 375
Left = 960
TabIndex = 1
Top = 1200
Width = 1095
End
Begin VB.ComboBox cboDataLayer
Height = 315
Left = 960
TabIndex = 0
Top = 120
Width = 4095
End
Begin VB.Label Label3
Caption = "显示字段:"
Height = 255
Left = 120
TabIndex = 3
Top = 600
Width = 975
End
Begin VB.Label Label1
Caption = "图 层:"
Height = 255
Left = 120
TabIndex = 2
Top = 120
Width = 615
End
End
Attribute VB_Name = "frmMapTip"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cboDataLayer_Click()
'Disable field combo if feature layer is not selected and exit
If Not TypeOf frmMDIMap.MapControl.Layer(cboDataLayer.ListIndex) Is IFeatureLayer Then
cboSelectFiled.Clear
cboSelectFiled.Enabled = False
Exit Sub
End If
'Get IFeatureLayer interface
Dim pFeatureLayer As IFeatureLayer
Set pFeatureLayer = frmMDIMap.MapControl.Layer(cboDataLayer.ListIndex)
isCheckTipListIndex = cboDataLayer.ListIndex
'Query inteface for ILayerFields
Dim pLayerFields As ILayerFields
Set pLayerFields = pFeatureLayer
Dim i As Long
Dim j As Long
j = 0
Dim pField As IField
cboSelectFiled.Clear
cboSelectFiled.Enabled = True
'Loop through the fields
For i = 0 To pLayerFields.FieldCount - 1
'Get IField interface
Set pField = pLayerFields.Field(i)
'If the field is not the shape field
If pField.Type <> esriFieldTypeGeometry Then
'Add field name to the control
cboSelectFiled.AddItem pField.name, j
'If the field name is the display field
If pField.name = pFeatureLayer.DisplayField Then
'Select the field name in the control
cboSelectFiled.ListIndex = j
End If
j = j + 1
End If
Next i
ShowLayerTips
End Sub
Private Sub chkShowTips_Click()
On Error Resume Next
ShowLayerTips
If isCheckTip = False Then
isCheckTip = 1
Else
isCheckTip = 0
End If
chkShowTips.Value = isCheckTip
End Sub
Private Sub CommandApply_Click()
'Get IFeatureLayer interface
Dim pFeatureLayer As IFeatureLayer
If cboDataLayer.ListIndex = -1 Then Exit Sub
Set pFeatureLayer = frmMDIMap.MapControl.Layer(cboDataLayer.ListIndex)
'Query interface for IlayerFields
Dim pLayerFields As ILayerFields
Set pLayerFields = pFeatureLayer
Dim i As Long
Dim pField As IField
'Loop through the fields
For i = 0 To pLayerFields.FieldCount - 1
'Get IField interface
Set pField = pLayerFields.Field(i)
'If the field name is the name selected in the control
If pField.name = cboSelectFiled.List(i) Then
'Set the field as the display field
pFeatureLayer.DisplayField = pField.name
Exit For
End If
Next i
End Sub
Private Sub CommandCabcel_Click()
Unload Me
End Sub
Private Sub Form_Load()
'Add the layer names to combo
Dim i As Integer
For i = 0 To frmMDIMap.MapControl.LayerCount - 1
cboDataLayer.AddItem frmMDIMap.MapControl.Layer(i).name, i
Next i
chkShowTips.Value = isCheckTip
'Select first layer in control
' ListField.ListIndex = 0
'Enable controls if disabled
If frmMDIMap.MapControl.LayerCount > 0 Then
If chkShowTips.Enabled = False Then chkShowTips.Enabled = True
If cboDataLayer.Enabled = False Then cboDataLayer.Enabled = True
Else
'Disable controls
chkShowTips.Enabled = False
cboDataLayer.Enabled = False
End If
End Sub
Private Sub ShowLayerTips()
Dim i As Long
Dim pLayer As ILayer
'Loop through the maps layers
For i = 0 To frmMDIMap.MapControl.LayerCount - 1
'Get ILayer interface
Set pLayer = frmMDIMap.MapControl.Layer(i)
'If is the layer selected in the control
If cboDataLayer.ListIndex = i Then
'If want to show map tips
If chkShowTips.Value = 1 Then
pLayer.ShowTips = True
Else
pLayer.ShowTips = False
frmMDIMap.MapControl.ToolTipText = ""
End If
Else
pLayer.ShowTips = False
End If
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -