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

📄 form010.frm

📁 给出了详细的vb环境下mo基本功能的代码 如图层的加载
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form10 
   Caption         =   "墨西哥地图"
   ClientHeight    =   5220
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5970
   LinkTopic       =   "Form1"
   ScaleHeight     =   5220
   ScaleWidth      =   5970
   StartUpPosition =   2  '屏幕中心
   Begin VB.OptionButton Option2 
      Caption         =   "纵向"
      Height          =   420
      Left            =   1680
      TabIndex        =   3
      Top             =   4680
      Width           =   975
   End
   Begin VB.OptionButton Option1 
      Caption         =   "横向"
      Height          =   420
      Left            =   600
      TabIndex        =   2
      Top             =   4680
      Value           =   -1  'True
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "打印"
      Height          =   420
      Left            =   3480
      TabIndex        =   1
      Top             =   4680
      Width           =   1215
   End
   Begin MapObjects2.Map Map1 
      Height          =   3855
      Left            =   120
      TabIndex        =   0
      Top             =   720
      Width           =   5775
      _Version        =   131072
      _ExtentX        =   10186
      _ExtentY        =   6800
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form010.frx":0000
   End
   Begin VB.Label Label1 
      Caption         =   "Label1"
      Height          =   255
      Left            =   120
      TabIndex        =   4
      Top             =   240
      Width           =   5535
   End
End
Attribute VB_Name = "Form10"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/5/10
'实现打印功能;

Option Explicit


'左键放大,右键缩小;
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  Dim r As MapObjects2.Rectangle
  If Button = vbLeftButton Then
    Set Map1.Extent = Map1.TrackRectangle
  ElseIf Button = vbRightButton Then
    Set r = Map1.Extent
    r.ScaleRectangle 2
    Map1.Extent = r
  End If
End Sub

Private Sub Command1_Click()
  On Error GoTo err1
  'Map1.PrintMap "MyMap", "test1", Option1.Value
  Map1.PrintMap "MyMap", "", Option1.Value
  MsgBox "打印完成。"
  Exit Sub
err1:
  MsgBox Err.Description + ",程序停止。"
  Unload Me
End Sub

Private Sub Command2_Click()
  On Error GoTo err1
  Printer.Print
  Map1.OutputMap Printer.hdc
  Printer.EndDoc
  MsgBox "打印完成。"
  Exit Sub
err1:
  MsgBox Err.Description + ",程序停止。"
  Unload Me
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
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Rivers")
  layer.Symbol.Color = moRed
  Map1.Layers.Add layer
  Map1.Refresh
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Cities")
  layer.Symbol.Color = moBlue
  Map1.Layers.Add layer
End Sub

Private Sub Form_Load()
  DrawLayer
  Label1.Caption = "你使用的打印机是:" & Printer.DeviceName
End Sub

⌨️ 快捷键说明

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