📄 finddlg.frm
字号:
VERSION 5.00
Begin VB.Form findDlg
Caption = "Find "
ClientHeight = 6915
ClientLeft = 9390
ClientTop = 3210
ClientWidth = 5775
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 6915
ScaleWidth = 5775
Begin VB.TextBox zoomLevelTextBox
Height = 285
Left = 3240
TabIndex = 23
Text = "25"
Top = 5760
Width = 735
End
Begin VB.CommandButton closeButton
Caption = "Close"
Height = 495
Left = 600
TabIndex = 21
Top = 6120
Width = 1575
End
Begin VB.CommandButton findButton
Caption = "Find"
Height = 495
Left = 600
TabIndex = 20
Top = 5280
Width = 1575
End
Begin VB.TextBox refineItemTextBox
Enabled = 0 'False
Height = 375
Left = 3240
TabIndex = 19
Top = 4560
Width = 2295
End
Begin VB.TextBox findItemTextBox
Height = 375
Left = 240
TabIndex = 17
Top = 4560
Width = 2295
End
Begin VB.CheckBox otherBoundaryCheckBox
Caption = "Other Boundary"
Height = 255
Left = 3240
TabIndex = 15
Top = 3600
Width = 2295
End
Begin VB.CheckBox useRefineCheckBox
Caption = "Use Refining Info"
Height = 255
Left = 3240
TabIndex = 14
Top = 3000
Width = 2295
End
Begin VB.CheckBox closestAddressCheckBox
Caption = "Closest Address"
Height = 255
Left = 240
TabIndex = 13
Top = 3600
Width = 2295
End
Begin VB.CheckBox abbCheckBox
Caption = "Abbreviations"
Height = 255
Left = 240
TabIndex = 12
Top = 3000
Width = 2295
End
Begin VB.ComboBox refineFieldCombo
Enabled = 0 'False
Height = 315
Left = 3240
TabIndex = 11
Text = " "
Top = 2400
Width = 2295
End
Begin VB.ComboBox refineDatasetCombo
Enabled = 0 'False
Height = 315
Left = 3240
TabIndex = 9
Top = 1440
Width = 2295
End
Begin VB.ComboBox refineLayerCombo
Enabled = 0 'False
Height = 315
Left = 3240
TabIndex = 7
Top = 480
Width = 2295
End
Begin VB.ComboBox findFieldCombo
Height = 315
Left = 240
TabIndex = 5
Top = 2400
Width = 2295
End
Begin VB.ComboBox findDatasetCombo
Height = 315
Left = 240
TabIndex = 3
Top = 1440
Width = 2295
End
Begin VB.ComboBox findLayerCombo
Height = 315
Left = 240
TabIndex = 1
Top = 480
Width = 2295
End
Begin VB.Label zoomLevelUnitLabel
Caption = "Miles"
Height = 255
Left = 4080
TabIndex = 24
Top = 5880
Width = 495
End
Begin VB.Label zoomLevelMenuItem
AutoSize = -1 'True
Caption = "Zoom Level"
Height = 195
Left = 3240
TabIndex = 22
Top = 5280
Width = 840
End
Begin VB.Label refineItemLabel
AutoSize = -1 'True
Caption = "Refine Item"
Height = 195
Left = 3240
TabIndex = 18
Top = 4200
Width = 810
End
Begin VB.Label findItemLabel
AutoSize = -1 'True
Caption = "Find Item"
Height = 195
Left = 240
TabIndex = 16
Top = 4200
Width = 645
End
Begin VB.Label refineFieldLabel
AutoSize = -1 'True
Caption = "Refine Field"
Height = 195
Left = 3240
TabIndex = 10
Top = 2040
Width = 840
End
Begin VB.Label refineDatasetLabel
AutoSize = -1 'True
Caption = "Refine Dataset"
Height = 195
Left = 3240
TabIndex = 8
Top = 1080
Width = 1065
End
Begin VB.Label refineLayerLabel
AutoSize = -1 'True
Caption = "Refine Layer"
Height = 195
Left = 3240
TabIndex = 6
Top = 120
Width = 900
End
Begin VB.Label findFieldLabel
AutoSize = -1 'True
Caption = "Find Field"
Height = 195
Left = 240
TabIndex = 4
Top = 2040
Width = 675
End
Begin VB.Label findDatasetLabel
AutoSize = -1 'True
Caption = "Find Dataset"
Height = 195
Left = 240
TabIndex = 2
Top = 1080
Width = 900
End
Begin VB.Label findLayerLabel
AutoSize = -1 'True
Caption = "Find Layer"
Height = 195
Left = 240
TabIndex = 0
Top = 120
Width = 735
End
End
Attribute VB_Name = "findDlg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' This sample application and corresponding sample code is provided
' for example purposes only. It has not undergone rigorous testing
' and as such should not be shipped as part of a final application
' without extensive testing on the part of the organization releasing
' the end-user product.
Option Explicit
'Global variable to hold map object from main dialog
Public curMap As Object
Private Sub closeButton_Click()
'Hide the form
Hide
End Sub
Private Sub findButton_Click()
Dim findLayer As MapXLib.Layer
Dim ds As MapXLib.Dataset
Dim foundObj As MapXLib.FindFeature
'Set find layer
Set findLayer = curMap.Layers(findLayerCombo.Text)
'Set find dataset if there are datasets and if one was chosen
If curMap.Datasets.Count > 0 And findDatasetCombo.Text <> "NONE" Then
'if find layer and find dataset are not the same, display message
If findLayer.Name <> findDatasetCombo.Text Then
MsgBox "Find layer and Find Dataset must be the same"
Exit Sub
Else 'set find dataset and find field
Set ds = curMap.Datasets(findDatasetCombo.Text)
Set findLayer.Find.FindDataset = ds
Set findLayer.Find.FindField = ds.Fields(findFieldCombo.Text)
End If
Else
'make sure find dataset and field are reset to nothing
Set findLayer.Find.FindDataset = Nothing
Set findLayer.Find.FindField = Nothing
End If
'set values for check boxes
If abbCheckBox.Value = 1 Then
findLayer.Find.Abbreviations = True
Else
findLayer.Find.Abbreviations = False
End If
If closestAddressCheckBox.Value = 1 Then
findLayer.Find.ClosestAddr = True
Else
findLayer.Find.ClosestAddr = False
End If
If otherBoundaryCheckBox.Value = 1 Then
findLayer.Find.OtherBoundary = True
Else
findLayer.Find.OtherBoundary = False
End If
'Set up refining information
If useRefineCheckBox.Value = 1 Then
If refineLayerCombo.Text <> "NONE" Then
'reset refine dataset and refine field to nothing
Set findLayer.Find.RefineDataset = Nothing
Set findLayer.Find.RefineField = Nothing
'set Refine layer
Set findLayer.Find.RefineLayer = curMap.Layers(refineLayerCombo.Text)
'Perform find search with find item and refine item
Set foundObj = findLayer.Find.Search(findItemTextBox.Text, _
refineItemTextBox.Text)
Else
Set findLayer.Find.RefineLayer = Nothing
If refineDatasetCombo.Text <> "NONE" Then
'set refine dataset and refine field
Set ds = curMap.Datasets(refineDatasetCombo.Text)
Set findLayer.Find.RefineDataset = ds
Set findLayer.Find.RefineField = ds.Fields(refineFieldCombo.Text)
'Perform find search with find item and refine item
Set foundObj = findLayer.Find.Search(findItemTextBox.Text, _
refineItemTextBox.Text)
Else
'display message that check box was checked but no refine
'data was specified
Set findLayer.Find.RefineDataset = Nothing
Set findLayer.Find.RefineField = Nothing
MsgBox "No refining info specified but checkbox checked!"
Exit Sub
End If
End If
Else
Set findLayer.Find.RefineLayer = Nothing
Set findLayer.Find.RefineDataset = Nothing
Set findLayer.Find.RefineField = Nothing
'perform find search using no refine data
Set foundObj = findLayer.Find.Search(findItemTextBox.Text, "")
End If
'if find search code ends in 1 zoom to location of found object
If foundObj.FindRC Mod 10 = 1 Then
curMap.ZoomTo Val(zoomLevelTextBox.Text), 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()
'Set up controls every time form is activated by menu choice
Call resetControls
End Sub
Private Sub Form_Load()
'variable that points to MapX control
Set curMap = FindMain.Map1
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
'fill find layer comboBox
Dim lyr As MapXLib.Layer
findLayerCombo.Clear
For Each lyr In curMap.Layers
findLayerCombo.AddItem lyr.Name
Next
findLayerCombo.ListIndex = 0
'fill Find dataset comboBox
findDatasetCombo.Clear
findDatasetCombo.AddItem "NONE"
Dim ds As MapXLib.Dataset
For Each ds In curMap.Datasets
findDatasetCombo.AddItem ds.Name
Next
findDatasetCombo.ListIndex = 0
'fill find field comboBox initially
findFieldCombo.Clear
findFieldCombo.AddItem "NONE"
findFieldCombo.ListIndex = 0
'fill Refine Layer ComboBox
refineLayerCombo.Clear
refineLayerCombo.AddItem "NONE"
For Each lyr In curMap.Layers
refineLayerCombo.AddItem lyr.Name
Next
refineLayerCombo.ListIndex = 0
'fill refine dataset comboBox
refineDatasetCombo.Clear
refineDatasetCombo.AddItem "NONE"
For Each ds In curMap.Datasets
refineDatasetCombo.AddItem ds.Name
Next
refineDatasetCombo.ListIndex = 0
'fill refine field comboBox initially
refineFieldCombo.Clear
refineFieldCombo.AddItem "NONE"
refineFieldCombo.ListIndex = 0
Set lyr = Nothing
Set ds = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set curMap = Nothing
End Sub
Private Sub refineDatasetCombo_Click()
'Reset the refine field combo when the refine dataset changes
If refineDatasetCombo.Text <> "NONE" Then
refineFieldCombo.Clear
Dim fld As MapXLib.Field
Dim ds As MapXLib.Dataset
Set ds = curMap.Datasets(refineDatasetCombo.Text)
For Each fld In ds.Fields
refineFieldCombo.AddItem fld.Name
Next
refineFieldCombo.ListIndex = 0
Set fld = Nothing
Set ds = Nothing
Else
refineFieldCombo.Clear
refineFieldCombo.AddItem "NONE"
refineFieldCombo.ListIndex = 0
End If
End Sub
Private Sub refineLayerCombo_Click()
'if refine layer combo is set to NONE, enable the refine dataset and
'refine field combo boxes
If refineLayerCombo.Text = "NONE" And useRefineCheckBox.Value <> 0 Then
refineDatasetCombo.Enabled = True
refineFieldCombo.Enabled = True
Else 'disbable the refine dataset and refine field combo boxes
refineDatasetCombo.Enabled = False
refineFieldCombo.Enabled = False
End If
End Sub
Private Sub useRefineCheckBox_Click()
'if check box for using refine data is unchecked, disble the combo boxes and
'refine item text box
If useRefineCheckBox.Value = False Then
refineLayerCombo.Enabled = False
refineDatasetCombo.Enabled = False
refineFieldCombo.Enabled = False
refineItemTextBox.Enabled = False
Else
refineLayerCombo.Enabled = True
If refineLayerCombo.Text = "NONE" Then
refineDatasetCombo.Enabled = True
refineFieldCombo.Enabled = True
refineItemTextBox.Enabled = True
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -