form05.frm

来自「一个关于基于MO编程的参考资料希望对大家的交流和学习有帮助」· FRM 代码 · 共 105 行

FRM
105
字号
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form05 
   Caption         =   "线段数组"
   ClientHeight    =   3735
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5865
   LinkTopic       =   "Form1"
   ScaleHeight     =   3735
   ScaleWidth      =   5865
   StartUpPosition =   2  '屏幕中心
   Begin MapObjects2.Map Map1 
      Height          =   3495
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5655
      _Version        =   131072
      _ExtentX        =   9975
      _ExtentY        =   6165
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "form05.frx":0000
   End
End
Attribute VB_Name = "Form05"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xuewei,2003/5/7
'在图上点击可以画多根线,用数组形式存放;
'画图时点击形成点集,双击画线。

Option Explicit
Dim Pline(30) As MapObjects2.Line
Dim PtsP(30) As MapObjects2.Points
Dim Pts As MapObjects2.Points
Dim P1 As MapObjects2.Point
Dim Pi As Integer
Dim g_Line As MapObjects2.Line

Private Sub Form_Load()
  Pi = 0
End Sub

Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)
  Dim sym As New Symbol, sym1 As New Symbol
  Dim i As Integer

  sym1.Size = 3
  sym1.Color = moRed
  If Not Pts Is Nothing Then
    Map1.DrawShape Pts, sym1
  End If
    
  sym.Color = moBlue
  sym.SymbolType = moLineSymbol
  sym.Size = 3
  For i = 0 To 30
    If Not Pline(i) Is Nothing Then
      Map1.DrawShape PtsP(i), sym1
      Map1.DrawShape Pline(i), sym
    End If
  Next i
End Sub

Private Sub Map1_DblClick()
  
  If Not g_Line Is Nothing Then
    Set Pline(Pi) = g_Line
    Set PtsP(Pi) = Pts
    Pi = Pi + 1
    Set g_Line = Nothing
    Set Pts = Nothing
    Map1.TrackingLayer.Refresh True
    Map1.Refresh
  End If
End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  
    If g_Line Is Nothing Then
      Set g_Line = New MapObjects2.Line
    End If
    
    If Pts Is Nothing Then
      Set Pts = New MapObjects2.Points
    End If
    
    Set P1 = New MapObjects2.Point
    Set P1 = Map1.ToMapPoint(X, Y)
    Pts.Add P1
    If Pts.Count = 1 Then
      g_Line.Parts.Add Pts
      Set Pts = g_Line.Parts(0)
    End If
    Map1.TrackingLayer.Refresh True
 
End Sub


⌨️ 快捷键说明

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