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

📄 form1.frm

📁 GIS二次开发
💻 FRM
字号:
VERSION 5.00
Object = "{C552EA90-6FBB-11D5-A9C1-00104BB6FC1C}#1.0#0"; "MapControl.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   7455
   ClientLeft      =   165
   ClientTop       =   855
   ClientWidth     =   10095
   LinkTopic       =   "Form1"
   ScaleHeight     =   7455
   ScaleWidth      =   10095
   StartUpPosition =   3  'Windows Default
   Begin esriMapControl.MapControl MapControl1 
      Height          =   7455
      Left            =   0
      OleObjectBlob   =   "Form1.frx":0000
      TabIndex        =   0
      Top             =   0
      Width           =   10095
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   9600
      Top             =   6720
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Menu LoadMap 
      Caption         =   "载入图层"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub LoadMap_Click()
  Dim pFilePaths As String
  Dim name As String
  CommonDialog1.DialogTitle = "选择图层文件"
  
  CommonDialog1.Filter = "Shape File (*.shp)|*.shp"
  CommonDialog1.ShowOpen
  pFilePaths = CommonDialog1.FileName
  If pFilePaths = "" Then Exit Sub
  
  Dim pFileName As IFileName
  Set pFileName = New FileName
  pFileName.Path = pFilePaths
  CreateLayer pFileName

End Sub
Public Sub CreateLayer(pName As IName)
  
  On Error GoTo ErrorHandler
  

  MapControl1.MousePointer = esriPointerHourglass
  

  Dim pLayerFactoryHelper As ILayerFactoryHelper
  Set pLayerFactoryHelper = New LayerFactoryHelper
  

  Dim pEnumLayer As IEnumLayer
  Set pEnumLayer = pLayerFactoryHelper.CreateLayersFromName(pName)
  pEnumLayer.Reset
   
  Dim pLayer As ILayer
  Set pLayer = pEnumLayer.Next
  Do While Not pLayer Is Nothing
    MapControl1.AddLayer pLayer
    Set pLayer = pEnumLayer.Next
  Loop
  

  MapControl1.MousePointer = esriPointerDefault
  
  Exit Sub
ErrorHandler:

    MsgBox "载入失败"
    MapControl1.MousePointer = esriPointerDefault


End Sub

⌨️ 快捷键说明

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