📄 放所移删全查.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 = 3150
ClientLeft = 60
ClientTop = 390
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 11040
ScaleWidth = 15240
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command15
Caption = "Command15"
Height = 615
Left = 360
TabIndex = 19
Top = 7080
Width = 1215
End
Begin VB.CommandButton Command10
Caption = "状态条"
Height = 735
Left = 120
TabIndex = 18
Top = 8640
Width = 1215
End
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 1335
Left = 0
TabIndex = 17
Top = 9705
Width = 15240
_ExtentX = 26882
_ExtentY = 2355
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 3
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "新宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 10440
Top = 360
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command14
Caption = "删除"
Height = 375
Left = 9480
TabIndex = 16
Top = 5880
Width = 1215
End
Begin VB.CommandButton Command11
Caption = "置底"
Height = 375
Left = 9480
TabIndex = 15
Top = 5400
Width = 1215
End
Begin VB.CommandButton Command9
Caption = "置顶"
Height = 375
Left = 9480
TabIndex = 14
Top = 4920
Width = 1215
End
Begin VB.CommandButton Command8
Caption = "下"
Height = 375
Left = 9480
TabIndex = 13
Top = 4440
Width = 1215
End
Begin VB.CommandButton Command7
Caption = "上"
Height = 375
Left = 9480
TabIndex = 12
Top = 3960
Width = 1215
End
Begin VB.CommandButton Command4
Caption = "全屏"
Height = 375
Left = 3120
TabIndex = 11
Top = 480
Width = 855
End
Begin VB.CommandButton Command13
Caption = "图层可见"
Height = 495
Left = 7560
TabIndex = 10
Top = 360
Width = 1215
End
Begin VB.CommandButton Command12
Caption = "图层不可见"
Height = 495
Left = 6240
TabIndex = 9
Top = 360
Width = 1215
End
Begin VB.ListBox List1
Height = 2760
Left = 9360
TabIndex = 8
Top = 1080
Width = 1575
End
Begin MapObjects2.Map Map2
Height = 2535
Left = 6840
TabIndex = 7
Top = 3960
Width = 2295
_Version = 131072
_ExtentX = 4048
_ExtentY = 4471
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "放所移删全查.frx":0000
End
Begin MSComctlLib.ListView ListView1
Height = 2775
Left = 6840
TabIndex = 6
Top = 1080
Width = 2295
_ExtentX = 4048
_ExtentY = 4895
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 = "ziduan"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "shuzhi"
Object.Width = 2540
EndProperty
End
Begin VB.CommandButton Command6
Caption = "属性查询"
Height = 495
Left = 5160
TabIndex = 5
Top = 360
Width = 975
End
Begin MapObjects2.Map Map1
Height = 5415
Left = 240
TabIndex = 4
Top = 1080
Width = 6495
_Version = 131072
_ExtentX = 11456
_ExtentY = 9551
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "放所移删全查.frx":01DF
End
Begin VB.CommandButton Command5
Caption = "删除图层"
Height = 495
Left = 4200
TabIndex = 3
Top = 360
Width = 855
End
Begin VB.CommandButton Command3
Caption = "移动"
Height = 495
Left = 2040
TabIndex = 2
Top = 360
Width = 975
End
Begin VB.CommandButton Command2
Caption = "缩小"
Height = 495
Left = 1080
TabIndex = 1
Top = 360
Width = 855
End
Begin VB.CommandButton Command1
Caption = "放大"
Height = 495
Left = 0
TabIndex = 0
Top = 360
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim t As Integer
Private Sub Command1_Click()
Map1.MousePointer = moZoomIn
t = 1
End Sub
Private Sub Command10_Click()
StatusBar1.Panels(1).Text = "sgsgh"
End Sub
Private Sub Command11_Click()
If List1.ListIndex >= 0 And List1.ListIndex < Map1.Layers.Count - 1 Then
Map1.Layers.MoveToBottom List1.ListIndex
addlyrname (Map1.Layers.Count - 1)
End If
End Sub
Private Sub Command12_Click()
Map1.Visible = False
Map2.Visible = False
End Sub
Private Sub Command13_Click()
Map1.Visible = True
Map2.Visible = True
End Sub
Private Sub Command14_Click()
If List1.ListIndex > 0 Then
Map1.Layers.Remove List1.ListIndex
addlyrname (0)
End If
End Sub
Private Sub Command15_Click()
Dim dc As New DataConnection
Dim strp As Integer
Dim p As Integer
Dim j As Integer, i As Integer
Dim FileName As String
Dim FileNames() As String
CommonDialog1.Filter = "shapfile1.|*.shp"
CommonDialog1.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
CommonDialog1.ShowOpen
If Len(CommonDialog1.FileName) > 0 Then
dc.Database = CurDir
strp = 1
p = InStr(strp, CommonDialog1.FileName, Chr(0))
If p = 0 Then '导入一个文件
Set layer = New MapLayer
Dim name As String
name = Left(CommonDialog1.FileTitle, Len(CommonDialog1.FileTitle) - 4)
Set layer.GeoDataset = dc.FindGeoDataset(name)
Map1.Layers.Add layer
Map2.Layers.Add layer
Else '导入多个文件
CommonDialog1.FileName = CommonDialog1.FileName & Chr(0)
strp = 1
j = 0
For i = 1 To Len(CommonDialog1.FileName)
i = InStr(strp, CommonDialog1.FileName, Chr(0))
If i = 0 Then Exit For
ReDim Preserve FileNames(i)
FileNames(j) = Mid(CommonDialog1.FileName, strp, i - strp)
strp = i + 1
j = j + 1
Next
For i = 1 To j - 1
FileName = FileNames(i)
Set layer = New MapLayer
name = Left(FileName, Len(FileName) - 4)
Set layer.GeoDataset = dc.FindGeoDataset(name)
Map1.Layers.Add layer
Map2.Layers.Add layer
Next i
End If
End If
End Sub
Private Sub Form_Load()
addlyrname (0)
End Sub
Private Sub Command2_Click()
Map1.MousePointer = moZoomOut
t = 2
End Sub
Private Sub Command3_Click()
Map1.MousePointer = moPan
t = 3
End Sub
Private Sub Command4_Click()
Set Map1.Extent = Map1.FullExtent
End Sub
Private Sub Command5_Click()
Map1.Layers.Clear
End Sub
Private Sub Command6_Click()
t = 6
Map1.MousePointer = moCross
End Sub
Private Sub Command7_Click()
If List1.ListIndex > 0 Then
Map1.Layers.MoveTo List1.ListIndex, List1.ListIndex - 1
addlyrname (List1.ListIndex - 1)
End If
End Sub
Sub addlyrname(idx As Integer)
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
Map1.Refresh
List1.Selected(idx) = True
End Sub
Private Sub Command8_Click()
If List1.ListIndex >= 0 And List1.ListIndex < Map1.Layers.Count - 1 Then
Map1.Layers.MoveTo List1.ListIndex, List1.ListIndex + 1
addlyrname (List1.ListIndex + 1)
End If
End Sub
Private Sub Command9_Click()
If List1.ListIndex > 0 Then
Map1.Layers.MoveToTop List1.ListIndex
addlyrname (0)
End If
End Sub
Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)
Map2.Refresh
End Sub
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim r As MapObjects2.Rectangle
If t = 1 Then
Set r = Map1.TrackRectangle
If r.Width > 1 And r.Top > 1 Then
Set Map1.Extent = r
Else
Set r = Map1.Extent
r.ScaleRectangle 0.5
Map1.Extent = r
End If
ElseIf t = 2 Then
Set r = Map1.Extent
r.ScaleRectangle 1.5
Map1.Extent = r
ElseIf t = 3 Then
Map1.Pan
End If
If t = 6 Then
Call showarr(X, Y)
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, "")
If objmors.Count <= 0 Then
Exit Sub
End If
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 Map1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim pt As New MapObjects2.Point
Set pt = Map1.ToMapPoint(X, Y)
StatusBar1.Panels(2).Text = "x=" & pt.X
StatusBar1.Panels(3).Text = "y=" & pt.Y
End Sub
Private Sub Map2_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)
Dim object As MapObjects2.Rectangle
Dim objsym As New MapObjects2.Symbol
Set object = Map1.Extent
With objsym
.Outline = True
.OutlineColor = vbBlue
.Style = moTransparentFill
.Style = moTransparentFill
End With
Map2.DrawShape object, objsym
Set object = Nothing
Set objsym = Nothing
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
Map1.Refresh
Else: Map1.CenterAt object.Center.X, object.Center.Y
End If
Set object = Nothing
End Sub
Private Sub Map2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim pt As New MapObjects2.Point
Set pt = Map1.ToMapPoint(X, Y)
StatusBar1.Panels(2).Text = "x=" & pt.X
StatusBar1.Panels(3).Text = "y=" & pt.Y
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -