📄 form1.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3120
ClientLeft = 165
ClientTop = 855
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3120
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command10
Caption = "图层可见"
Height = 615
Left = 8880
TabIndex = 14
Top = 9840
Width = 1575
End
Begin VB.CommandButton Command9
Caption = "图层不可见"
Height = 615
Left = 6840
TabIndex = 13
Top = 9840
Width = 1695
End
Begin VB.CommandButton Command8
Caption = "删除图层"
Height = 615
Left = 4440
TabIndex = 12
Top = 9840
Width = 1935
End
Begin VB.CommandButton Command7
Caption = "置底"
Height = 375
Left = 4320
TabIndex = 11
Top = 6120
Width = 735
End
Begin VB.CommandButton Command6
Caption = "置顶"
Height = 375
Left = 4320
TabIndex = 10
Top = 5640
Width = 735
End
Begin VB.CommandButton Command5
Caption = "加图层"
Height = 375
Left = 4320
TabIndex = 9
Top = 5160
Width = 735
End
Begin VB.CommandButton Command4
Caption = "删除"
Height = 375
Left = 4320
TabIndex = 8
Top = 4680
Width = 735
End
Begin VB.CommandButton Command3
Caption = "下"
Height = 375
Left = 4320
TabIndex = 7
Top = 4200
Width = 735
End
Begin VB.CommandButton Command2
Caption = "上"
Height = 375
Left = 4320
TabIndex = 6
Top = 3720
Width = 735
End
Begin VB.ListBox List1
Height = 1680
Left = 4200
TabIndex = 5
Top = 1920
Width = 975
End
Begin VB.CommandButton Command1
Caption = "数值查询"
Height = 495
Left = 4080
TabIndex = 4
Top = 1320
Width = 1335
End
Begin MSComctlLib.ListView ListView1
Height = 4815
Left = 120
TabIndex = 3
Top = 960
Width = 3735
_ExtentX = 6588
_ExtentY = 8493
View = 3
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 2
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "字段"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "数值"
Object.Width = 2540
EndProperty
End
Begin MSComctlLib.ImageList ImageList1
Left = 4080
Top = 600
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 4
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0000
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0112
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0224
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0336
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 615
Left = 0
TabIndex = 2
Top = 0
Width = 4680
_ExtentX = 8255
_ExtentY = 1085
ButtonWidth = 820
ButtonHeight = 926
Appearance = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 4
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "放大"
ImageIndex = 1
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "缩小"
ImageIndex = 2
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "移动"
ImageIndex = 3
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "恢复"
ImageIndex = 4
EndProperty
EndProperty
OLEDropMode = 1
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 2880
Top = 480
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MapObjects2.Map Map2
Height = 3255
Left = 240
TabIndex = 1
Top = 6120
Width = 2655
_Version = 131072
_ExtentX = 4683
_ExtentY = 5741
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form1.frx":0448
End
Begin MapObjects2.Map Map1
Height = 8775
Left = 5640
TabIndex = 0
Top = 840
Width = 9015
_Version = 131072
_ExtentX = 15901
_ExtentY = 15478
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form1.frx":0462
End
Begin VB.Menu mnuFile
Caption = "文件"
Begin VB.Menu mnuNew
Caption = "新建"
End
Begin VB.Menu mnuOpen
Caption = "打开"
End
Begin VB.Menu mnuSave
Caption = "保存"
End
Begin VB.Menu mnuExit
Caption = "退出"
End
End
Begin VB.Menu mnuHelp
Caption = "帮助"
Begin VB.Menu mnuUsage
Caption = "使用说明"
End
Begin VB.Menu mnuAbout
Caption = "关于"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim c As Integer
Private Sub Command1_Click()
Map1.MousePointer = moCross
c = 5
End Sub
Private Sub Command10_Click()
Map1.Visible = True
Map2.Visible = True
End Sub
Private Sub Command2_Click()
Dim lyr As MapLayer
If List1.ListIndex > 0 Then
Map1.Layers.MoveTo List1.ListIndex, List1.ListIndex - 1
Map1.Refresh
Call addlyrname
End If
End Sub
Private Sub addlyrname()
Dim i As Integer
Dim lyr As MapLayer
List1.Clear
For i = 0 To Map1.Layers.Count - 1
Set lyr = Map1.Layers(i)
List1.AddItem lyr.name
Next i
End Sub
Private Sub Command3_Click()
Dim lyr As MapLayer
If List1.ListIndex > 0 Then
Map1.Layers.MoveTo List1.ListIndex, List1.ListIndex + 1
Map1.Refresh
Call addlyrname
End If
End Sub
Private Sub Command4_Click()
Dim lyr As MapLayer
If List1.ListIndex > 0 Then
Map1.Layers.Remove List1.ListIndex
Map1.Refresh
Call addlyrname
End If
End Sub
Private Sub Command5_Click()
On Error Resume Next
CommonDialog1.Filter = "shapfile.|*.shp"
CommonDialog1.ShowOpen
Dim dc As New DataConnection
Dim name As String
name = Left(CommonDialog1.FileTitle, Len(CommonDialog1.FileTitle) - 4)
dc.Database = CurDir
Dim layer As New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset(name)
Map2.Layers.Add layer
Map1.Layers.Add layer
Map1.Refresh
Map2.Refresh
Call addlyrname
End Sub
Private Sub Command6_Click()
Dim lyr As MapLayer
If List1.ListIndex > 0 Then
Map1.Layers.MoveToTop List1.ListIndex
Map1.Refresh
Call addlyrname
End If
End Sub
Private Sub Command7_Click()
Dim lyr As MapLayer
If List1.ListIndex > 0 Then
Map1.Layers.MoveToBottom List1.ListIndex
Map1.Refresh
Call addlyrname
End If
End Sub
Private Sub Command8_Click()
Map1.Layers.Clear
Map2.Layers.Clear
End Sub
Private Sub Command9_Click()
Map1.Visible = False
Map2.Visible = False
End Sub
Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hDC As stdole.OLE_HANDLE)
If index = 0 Then
Map2.TrackingLayer.Refresh True
End If
End Sub
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim r As MapObjects2.Rectangle
If c = 1 Then
Set r = Map1.TrackRectangle
If r.Width > 1 And r.Top > 1 Then
Map1.Extent = r
Else
Set r = Map1.Extent
r.ScaleRectangle 0.5
Map1.Extent = r
End If
ElseIf c = 2 Then
Set r = Map1.Extent
r.ScaleRectangle 1.5
Map1.Extent = r
ElseIf c = 3 Then
Map1.Pan
ElseIf c = 5 Then
Call showarr(x, y)
ElseIf c = 4 Then
Map1.Extent = Map1.FullExtent
End If
End Sub
Private Sub showarr(x As Single, y As Single)
Dim objpnt As MapObjects2.Point
Dim i As Integer
Dim objmors As MapObjects2.Recordset
Dim objlyr As MapObjects2.MapLayer
Dim obj As Object
Dim objtds As MapObjects2.TableDesc
Dim objitem As ListItem
Dim strkey As String
Set objpnt = Map1.ToMapPoint(x, y)
Set objlyr = Map1.Layers(0)
Set objmors = objlyr.SearchShape(objpnt, moAreaIntersect, "")
Set obj = objmors.Fields("shape").Value
Map1.FlashShape obj, 2
ListView1.ListItems.Clear
Set objtds = objmors.TableDesc
For i = 0 To objtds.FieldCount - 1
strkey = objtds.FieldName(i)
Set objitem = ListView1.ListItems.Add(, strkey, strkey)
objitem.SubItems(1) = objmors.Fields(strkey).ValueAsString
Next i
End Sub
Private Sub mnuExit_Click()
End
End Sub
Private Sub mnuOpen_Click()
On Error Resume Next
CommonDialog1.Filter = "shapfile.|*.shp"
CommonDialog1.ShowOpen
Dim dc As New DataConnection
Dim name As String
If (Len(CommonDialog1.FileTitle) - 4) <> 0 Then
name = Left(CommonDialog1.FileTitle, Len(CommonDialog1.FileTitle) - 4)
dc.Database = CurDir
Else
End
End If
Dim layer As New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset(name)
Map1.Layers.Add layer
Map2.Layers.Add layer
End Sub
Private Sub Map2_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)
Dim sym As New Symbol
sym.OutlineColor = moBlue
sym.Size = 2
sym.Style = moTransparentFill
Map2.DrawShape Map1.Extent, sym
End Sub
Private Sub Map2_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim object As MapObjects2.Rectangle
Set object = Map2.TrackRectangle
If object.Width > 1 And object.Height > 1 Then
Set Map1.Extent = object
Else
Map1.CenterAt object.Center.x, object.Center.y
End If
Map1.Refresh
Map2.Refresh
End Sub
Private Sub mnuAbout_Click()
MsgBox "MO二次开发 Ver1.0 版权所有(C) 2006 朱晓晨", vbOKOnly, "关于"
End Sub
Private Sub mnuNew_Click()
Map1.Layers.Clear
Map2.Layers.Clear
End Sub
Private Sub mnuSave_Click()
MsgBox "我的机子帮助坏了,这段我想了很久没想出来,抱歉!如果你会,请跟朱晓晨联系", vbOKOnly, " 错误信息"
End Sub
Private Sub mnuUsage_Click()
MsgBox "使用说明文档可能已经被移除,请与朱晓晨联系。", vbOKOnly, " 抱歉"
End Sub
Private Sub form_load()
Dim dc As New DataConnection
Dim layer As MapLayer
dc.Database = "C:\Program Files\ESRI\MapObjects2\Samples\Samples\Data\Mexico"
If Not dc.Connect Then
MsgBox "无数据"
End
End If
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("states")
layer.Symbol.Color = moPaleYellow
Map1.Layers.Add layer
Map2.Layers.Add layer
Map1.Refresh
Map2.Refresh
MsgBox "此程序只供复习参考,不可用与非法勾当,后果自负。", vbOKOnly, " 友情提醒"
MsgBox "此程序有很多不足之处还请见谅。", vbOKOnly, " 友情提醒"
Call addlyrname
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If Button.index = 1 Then
Map1.MousePointer = moZoomIn
c = 1
ElseIf Button.index = 2 Then
Map1.MousePointer = moZoomOut
c = 2
ElseIf Button.index = 3 Then
Map1.MousePointer = moPan
c = 3
ElseIf Button.index = 4 Then
Map1.MousePointer = moCross
c = 4
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -