📄 form2.frm
字号:
VERSION 5.00
Begin VB.Form Form2
BorderStyle = 3 'Fixed Dialog
Caption = "Form2"
ClientHeight = 2490
ClientLeft = 45
ClientTop = 330
ClientWidth = 5235
LinkTopic = "Form2"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2490
ScaleWidth = 5235
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.ComboBox findLayerCombo
Height = 315
Left = 90
TabIndex = 5
Top = 510
Width = 2295
End
Begin VB.ComboBox findDatasetCombo
Height = 315
Left = 2820
TabIndex = 4
Top = 510
Width = 2295
End
Begin VB.ComboBox findFieldCombo
Height = 315
Left = 90
TabIndex = 3
Top = 1290
Width = 2295
End
Begin VB.TextBox findItemTextBox
Height = 375
Left = 2820
TabIndex = 2
Top = 1230
Width = 2295
End
Begin VB.CommandButton findButton
Caption = "Find"
Height = 495
Left = 750
TabIndex = 1
Top = 1950
Width = 1575
End
Begin VB.CommandButton closeButton
Caption = "Close"
Height = 495
Left = 3090
TabIndex = 0
Top = 1950
Width = 1575
End
Begin VB.Label findLayerLabel
AutoSize = -1 'True
Caption = "Find Layer"
Height = 195
Left = 90
TabIndex = 9
Top = 150
Width = 735
End
Begin VB.Label findDatasetLabel
AutoSize = -1 'True
Caption = "Find Dataset"
Height = 195
Left = 2820
TabIndex = 8
Top = 150
Width = 900
End
Begin VB.Label findFieldLabel
AutoSize = -1 'True
Caption = "Find Field"
Height = 195
Left = 90
TabIndex = 7
Top = 930
Width = 675
End
Begin VB.Label findItemLabel
AutoSize = -1 'True
Caption = "Find Item"
Height = 195
Left = 2820
TabIndex = 6
Top = 870
Width = 645
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public curMap As Object
Private Sub closeButton_Click()
Hide
End Sub
Private Sub findButton_Click()
Dim findLayer As MapXLib.Layer
Dim ds As MapXLib.Dataset
Dim foundObj As MapXLib.FindFeature
Set findLayer = curMap.Layers(findLayerCombo.Text)
If curMap.DataSets.Count > 0 And findDatasetCombo.Text <> "NONE" Then
If findLayer.Name <> findDatasetCombo.Text Then
MsgBox "Find layer and Find Dataset must be the same"
Exit Sub
Else
Set ds = curMap.DataSets(findDatasetCombo.Text)
Set findLayer.Find.FindDataset = ds
Set findLayer.Find.FindField = ds.Fields(findFieldCombo.Text)
End If
Else
Set findLayer.Find.FindDataset = Nothing
Set findLayer.Find.FindField = Nothing
End If
Set foundObj = findLayer.Find.Search(findItemTextBox.Text)
Set foundObj = findLayer.GetFeatureByKey(findItemTextBox.Text)
If foundObj.FindRC Mod 10 = 1 Then
curMap.ZoomTo 25, foundObj.CenterX, foundObj.CenterY
Else
MsgBox "Exact Match Not found"
End If
Set findLayer = Nothing
Set ds = Nothing
Set foundObj = Nothing
End Sub
Private Sub findDatasetCombo_Click()
'fill find field comboBox
If findDatasetCombo.Text <> "NONE" Then
findFieldCombo.Clear
Dim fld As MapXLib.Field
Dim ds As MapXLib.Dataset
Set ds = curMap.DataSets(findDatasetCombo.Text)
For Each fld In ds.Fields
findFieldCombo.AddItem fld.Name
Next
findFieldCombo.ListIndex = 0
Else
findFieldCombo.Clear
findFieldCombo.AddItem "NONE"
findFieldCombo.ListIndex = 0
End If
Set fld = Nothing
Set ds = Nothing
End Sub
Private Sub Form_Activate()
Call resetControls
End Sub
Public Sub resetControls()
If curMap.Layers.Count = 0 Then
MsgBox "There are no layers in map. Find cannot be performed."
Hide
End If
Dim lyr As MapXLib.Layer
findLayerCombo.Clear
For Each lyr In curMap.Layers
findLayerCombo.AddItem lyr.Name
Next
findLayerCombo.ListIndex = 0
findDatasetCombo.Clear
findDatasetCombo.AddItem "NONE"
Dim ds As MapXLib.Dataset
For Each ds In curMap.DataSets
findDatasetCombo.AddItem ds.Name
Next
findDatasetCombo.ListIndex = 0
findFieldCombo.Clear
findFieldCombo.AddItem "NONE"
findFieldCombo.ListIndex = 0
Set lyr = Nothing
Set ds = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set curMap = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -