📄 form03.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Begin VB.Form Form03
Caption = "墨西哥地图"
ClientHeight = 6750
ClientLeft = 60
ClientTop = 345
ClientWidth = 7710
LinkTopic = "Form1"
ScaleHeight = 6750
ScaleWidth = 7710
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 1800
TabIndex = 5
Top = 6240
Width = 1335
End
Begin VB.ComboBox Combo3
Height = 300
Left = 6120
TabIndex = 4
Text = "Combo3"
Top = 6120
Width = 1335
End
Begin VB.ComboBox Combo2
Height = 300
Left = 4560
TabIndex = 3
Text = "Combo2"
Top = 6360
Width = 1335
End
Begin VB.ComboBox Combo1
Height = 300
Left = 4560
TabIndex = 2
Text = "Combo1"
Top = 5880
Width = 1335
End
Begin MapObjects2.Map Map1
Height = 5415
Left = 120
TabIndex = 0
Top = 240
Width = 7455
_Version = 131072
_ExtentX = 13150
_ExtentY = 9551
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form03.frx":0000
End
Begin VB.Label Label1
Caption = "Label1"
Height = 375
Left = 960
TabIndex = 1
Top = 5880
Width = 2415
End
End
Attribute VB_Name = "Form03"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/5/17
'SearchExpression练习;
'可以从COMBO中任意选用表达式中的属性数据,从MO的帮助“SearchExpression”中修改而来。
Option Explicit
Dim g_symSelection As MapObjects2.Symbol
Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hDC As stdole.OLE_HANDLE)
Dim strExpression As String
Dim recSelection As MapObjects2.Recordset
If index > 0 Then Exit Sub
If Map1.Layers(0).Records.Fields(Combo1.List(Combo1.ListIndex)).Type = moString Then
'strExpression = Combo1.List(Combo1.ListIndex) & " " & Combo2.List(Combo2.ListIndex) & " '" & Combo3.Text & "'"
strExpression = Combo1.List(Combo1.ListIndex) & Combo2.List(Combo2.ListIndex) & " '" & Combo3.Text & "'"
Else
'strExpression = Combo1.List(Combo1.ListIndex) & " " & Combo2.List(Combo2.ListIndex) & " " & Combo3.Text
strExpression = Combo1.List(Combo1.ListIndex) & Combo2.List(Combo2.ListIndex) & Combo3.Text
End If
Set recSelection = Map1.Layers(0).SearchExpression(strExpression)
If Not recSelection.EOF Then
Map1.DrawShape recSelection, g_symSelection
End If
Set recSelection = Nothing
End Sub
Private Sub Command1_Click()
Map1.Refresh
End Sub
Private Sub Form_Resize()
Map1.Move 60, 60, Me.ScaleWidth - 180, Me.ScaleHeight - 2000
Label1.Move Map1.Left, Map1.Top + Map1.Height + 180, Map1.Width / 2, 400
Combo1.Move Label1.Left, Label1.Top + Label1.Height + 60, Map1.Width * 0.4
Combo2.Move Combo1.Left + Combo1.Width + 60, Combo1.Top, (Map1.Width * 0.2) - 60
Combo3.Move Combo2.Left + Combo2.Width + 60, Combo1.Top, Map1.Width * 0.4
Command1.Move (Me.ScaleWidth / 2) - 600, Combo1.Top + Combo1.Height + 300, 1200, Combo1.Height
End Sub
Private Sub Form_Load()
DrawLayer
If Not Map1.Layers.Count = 1 Then End
Label1.Caption = "选择表达式:"
Command1.Caption = "查找"
With Combo1
Dim fldLyr As MapObjects2.Field
For Each fldLyr In Map1.Layers(0).Records.Fields
If fldLyr.Type < 20 Then
.AddItem fldLyr.Name
End If
Next fldLyr
.ListIndex = 0
End With
With Combo2
.AddItem "="
.AddItem "<"
.AddItem ">"
.AddItem "<="
.AddItem ">="
.AddItem "Like"
.ListIndex = 0
End With
Combo3.Text = "<Field Values>"
Call ListValues
Set g_symSelection = New MapObjects2.Symbol
With g_symSelection
.SymbolType = Map1.Layers(0).Symbol.SymbolType
.color = moDarkGreen
End With
End Sub
Private Sub Combo1_Click()
Call ListValues
End Sub
Private Sub ListValues()
Dim recLyr As MapObjects2.Recordset
Dim strName As String
If Len(Combo1.List(Combo1.ListIndex)) > 0 Then
Set recLyr = Map1.Layers(0).Records
strName = Combo1.List(Combo1.ListIndex)
Combo3.Clear
Do While Not recLyr.EOF
Combo3.AddItem recLyr.Fields(strName).ValueAsString
recLyr.MoveNext
Loop
End If
End Sub
Sub DrawLayer()
Dim dc As New DataConnection
Dim layer As MapLayer
dc.Database = App.Path + "\..\" + "Mexico"
If Not dc.Connect Then
MsgBox "在指定的文件夹下没找到图层数据文件!"
End
End If
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("States")
layer.Symbol.color = moYellow
Map1.Layers.Add layer
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -