⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form02.frm

📁 VB+M0开发GIS代码
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Begin VB.Form Form02 
   Caption         =   "循环查找并闪烁结果"
   ClientHeight    =   6495
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7710
   LinkTopic       =   "Form1"
   ScaleHeight     =   6495
   ScaleWidth      =   7710
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton Command1 
      Caption         =   "查找"
      Height          =   375
      Left            =   4920
      TabIndex        =   2
      Top             =   5880
      Width           =   1095
   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        =   "Form02.frx":0000
   End
   Begin VB.Label Label1 
      Caption         =   "Label1"
      Height          =   255
      Left            =   960
      TabIndex        =   1
      Top             =   5880
      Width           =   2415
   End
End
Attribute VB_Name = "Form02"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/5/18
'SearchExpression练习;
'从STATE_ID为1起,到最后为止,闪烁显示各个STATE。

Option Explicit
Dim g_symSelection As MapObjects2.Symbol
Dim Sbl As Boolean
Dim Si As Integer
Dim Smax As Integer
Dim recSelection As MapObjects2.Recordset


Private Sub Command1_Click()
  Dim shp As MapObjects2.Polygon
  Dim strExpression As String
  Label1.Caption = "找到第" & Si & "个州。"
  
  '查找;
  strExpression = "STATE_ID = " & Si
  Set recSelection = Map1.Layers(0).SearchExpression(strExpression)
  
  '打开显示开关;
  Sbl = True
  
  '设置闪烁2次;
  Set shp = recSelection.Fields("Shape").Value
  Map1.FlashShape shp, 5
  
  '调用Map1_AfterLayerDraw显示查找结果;
  Map1.Refresh
  
  '找到下一个州的序号;
  If Si < Smax Then
    Si = Si + 1
  Else
    Si = 1
  End If
End Sub

Private Sub Form_Load()
  '初始设置;
  Sbl = False
  Si = 1
  Label1.Caption = "点击“查找”"
  
  '添加图层;
  DrawLayer
  
  '设置显示模式;
  Set g_symSelection = New MapObjects2.Symbol
  With g_symSelection
    .SymbolType = Map1.Layers(0).Symbol.SymbolType
    .color = moDarkGreen
  End With
End Sub

Sub DrawLayer()
  Dim dc As New DataConnection
  Dim layer As MapLayer
  Dim recs As MapObjects2.Recordset
  
  '添加图层;
  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
  
  '找到最大记录数;
  Set recs = layer.Records
  Smax = recs.Count
End Sub

'显示查询结果;
Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hDC As stdole.OLE_HANDLE)
  If Sbl Then
    If Not recSelection.EOF Then
      Map1.DrawShape recSelection, g_symSelection
    End If
    Set recSelection = Nothing
  End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -