📄 frmdrawmain.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form DrawMain
AutoRedraw = -1 'True
Caption = "VB_CAD"
ClientHeight = 3195
ClientLeft = 165
ClientTop = 810
ClientWidth = 4680
DrawStyle = 2 'Dot
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
WindowState = 2 'Maximized
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 270
Left = 0
TabIndex = 2
Top = 2925
Width = 4680
_ExtentX = 8255
_ExtentY = 476
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 4
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Object.Width = 7056
MinWidth = 7056
Key = "Pos"
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Object.Width = 4304
MinWidth = 4304
EndProperty
BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Object.Width = 4304
MinWidth = 4304
EndProperty
EndProperty
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 1020
Left = 0
TabIndex = 1
Top = 0
Width = 4680
_ExtentX = 8255
_ExtentY = 1799
ButtonWidth = 609
ButtonHeight = 582
Appearance = 1
Style = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 25
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Key = "New"
Object.ToolTipText = "新文件"
ImageIndex = 1
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Key = "Open"
Object.ToolTipText = "打开文件"
ImageIndex = 2
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Key = "Save"
Object.ToolTipText = "保存文件"
ImageIndex = 3
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Key = "Preview"
Object.ToolTipText = "打印预览"
ImageIndex = 4
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Key = "Print"
Object.ToolTipText = "打印"
ImageIndex = 5
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Select"
Object.ToolTipText = "选择"
ImageIndex = 6
EndProperty
BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Line"
Object.ToolTipText = "直线段"
ImageIndex = 7
EndProperty
BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Polyline"
Object.ToolTipText = "多义线"
ImageIndex = 8
EndProperty
BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Circle"
Object.ToolTipText = "圆"
ImageIndex = 9
EndProperty
BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Arc"
Object.ToolTipText = "圆弧"
ImageIndex = 10
EndProperty
BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Text"
Object.ToolTipText = "文本"
ImageIndex = 11
EndProperty
BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button16 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Move"
Object.ToolTipText = "平移"
ImageIndex = 12
EndProperty
BeginProperty Button17 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Rotate"
Object.ToolTipText = "旋转"
ImageIndex = 13
EndProperty
BeginProperty Button18 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Mirror"
Object.ToolTipText = "镜像"
ImageIndex = 14
EndProperty
BeginProperty Button19 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Scale"
Object.ToolTipText = "比例"
ImageIndex = 15
Style = 5
BeginProperty ButtonMenus {66833FEC-8583-11D1-B16A-00C0F0283628}
NumButtonMenus = 2
BeginProperty ButtonMenu1 {66833FEE-8583-11D1-B16A-00C0F0283628}
Key = "ZoomO"
Text = "放大"
EndProperty
BeginProperty ButtonMenu2 {66833FEE-8583-11D1-B16A-00C0F0283628}
Key = "ZoomI"
Text = "缩小"
EndProperty
EndProperty
EndProperty
BeginProperty Button20 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button21 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "ZoomOut"
Object.ToolTipText = "放大"
ImageIndex = 16
EndProperty
BeginProperty Button22 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "ZoomIn"
Object.ToolTipText = "缩小"
ImageIndex = 17
EndProperty
BeginProperty Button23 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "ZoomLocal"
Object.ToolTipText = "局部放大"
ImageIndex = 18
EndProperty
BeginProperty Button24 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Extent"
Object.ToolTipText = "显示全局"
ImageIndex = 19
EndProperty
BeginProperty Button25 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "GMove"
Object.ToolTipText = "移动画面"
ImageIndex = 20
EndProperty
EndProperty
End
Begin VB.PictureBox picDraw
BackColor = &H00FFFFFF&
Height = 5895
Left = 0
ScaleHeight = 5835
ScaleWidth = 9435
TabIndex = 0
Top = 360
Width = 9495
Begin MSComctlLib.ImageList ImageList1
Left = 720
Top = 840
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 20
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":0000
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":0544
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":0A88
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":0FCC
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":1510
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":1A54
Key = ""
EndProperty
BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":1EA8
Key = ""
EndProperty
BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":2784
Key = ""
EndProperty
BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":3060
Key = ""
EndProperty
BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":393C
Key = ""
EndProperty
BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":4218
Key = ""
EndProperty
BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":4AF4
Key = ""
EndProperty
BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":53D0
Key = ""
EndProperty
BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":5CAC
Key = ""
EndProperty
BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":6588
Key = ""
EndProperty
BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":6E64
Key = ""
EndProperty
BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":7740
Key = ""
EndProperty
BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":801C
Key = ""
EndProperty
BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":88F8
Key = ""
EndProperty
BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmDrawMain.frx":91D4
Key = ""
EndProperty
EndProperty
End
End
Begin VB.Menu Draw
Caption = "绘图"
Begin VB.Menu line
Caption = "直线"
End
Begin VB.Menu PolyLine
Caption = "多义线"
End
Begin VB.Menu Circle
Caption = "圆"
End
Begin VB.Menu arc
Caption = "圆弧"
End
Begin VB.Menu Text
Caption = "标注文本"
End
End
Begin VB.Menu Edit
Caption = "编辑"
Begin VB.Menu SelOnebyOne
Caption = "逐个选择"
End
Begin VB.Menu SelbyClass
Caption = "分类选择"
Begin VB.Menu SelLine
Caption = "选择直线段"
End
Begin VB.Menu SelPolyline
Caption = "选择多义线"
End
Begin VB.Menu SelCircle
Caption = "选择圆"
End
Begin VB.Menu SelArc
Caption = "选择圆弧"
End
Begin VB.Menu SelText
Caption = "选择标注文本"
End
End
Begin VB.Menu SelAll
Caption = "全选"
End
Begin VB.Menu SelNone
Caption = "放弃选中"
End
Begin VB.Menu Move
Caption = "平移变换"
End
Begin VB.Menu Rotate
Caption = "旋转变换"
End
Begin VB.Menu Mirror
Caption = "镜像变换"
End
Begin VB.Menu TransScale
Caption = "比例变换"
Begin VB.Menu ScaleZoomIn
Caption = "缩小"
End
Begin VB.Menu ScaleZoomOut
Caption = "放大"
End
Begin VB.Menu ZoomScale
Caption = "缩放比例设置..."
End
End
Begin VB.Menu Delete
Caption = "删除"
End
End
Begin VB.Menu View
Caption = "缩放"
Begin VB.Menu ZoomOut
Caption = "放大"
End
Begin VB.Menu ZoomIn
Caption = "缩小"
End
Begin VB.Menu localZoomOut
Caption = "局部放大"
End
Begin VB.Menu ViewPan
Caption = "画面移动"
End
Begin VB.Menu Extent
Caption = "全屏显示"
End
End
Begin VB.Menu Help
Caption = "帮助"
Begin VB.Menu About
Caption = "关于VB_CAD"
End
End
End
Attribute VB_Name = "DrawMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal z As Long, ByVal x As Long, ByVal cz As Long, ByVal cx As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Dim Z01 As Double, X01 As Double, Z02 As Double, X02 As Double, BZ As Double, BX As Double
Private bolHandleShow As Boolean
Private bolEntitySizing As Boolean
Private Sub About_Click()
frmAbout.Show
End Sub
Private Sub Arc_Click()
Command = ecCreateArc
End Sub
Private Sub Circle_Click()
Command = ecCreateCircle
End Sub
Private Sub Delete_Click()
'删除被选中的所有图元
AllSelRemove
'更新图片框中的内容
DrawMain.picDraw.Refresh
End Sub
Private Sub Extent_Click()
Dim minZ As Double
Dim minX As Double
Dim maxZ As Double
Dim maxX As Double
Dim rc As rect
Dim rcLB As New Position
Dim rcRT As New Position
Dim scalez As Double, scalex As Double
Call GetClientRect(DrawMain.picDraw.hwnd, rc)
With rcLB
.z = rc.Left * Screen.TwipsPerPixelX
.x = rc.Bottom * Screen.TwipsPerPixelY
End With
With rcRT
.z = rc.Right * Screen.TwipsPerPixelX
.x = rc.Top * Screen.TwipsPerPixelY
End With
Call GetExtentBox(minZ, minX, maxZ, maxX)
'计算新坐标系与逻辑坐标的比例因子
scalez = Abs((rcRT.z - rcLB.z) / (maxZ - minZ))
scalex = Abs((rcRT.x - rcLB.x) / (maxX - minX))
scale1 = min(scalez, scalex)
'重新设置视口大小
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -