📄 6-1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BackColor = &H00808000&
Caption = "Form1"
ClientHeight = 3480
ClientLeft = 60
ClientTop = 345
ClientWidth = 5355
LinkTopic = "Form1"
ScaleHeight = 3480
ScaleWidth = 5355
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox Picture1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 540
Left = 2160
Picture = "6-1.frx":0000
ScaleHeight = 540
ScaleWidth = 540
TabIndex = 1
Top = 1080
Width = 540
End
Begin VB.Label Label1
BackColor = &H00808000&
Caption = "拖动对象"
Height = 255
Left = 3600
TabIndex = 0
Top = 960
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim dX, dY As Single
Private Sub Form_Load()
Picture1.AutoSize = True
Picture1.BorderStyle = 0
End Sub
Private Sub label1_DragDrop(Source As Control, X As Single, Y As Single)
'当鼠标未移出label1边框时,
'窗体Form1不获得任何事件,
'为了移动控件,必须处理label1的DragDrop事件
Source.Move Source.Left + X - dX, Source.Top + Y - dY
End Sub
Private Sub label1_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
'保存鼠标位置
dX = X
dY = Y
'开始拖动控件
Label1.Drag vbBeginDrag
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
'由于控件不能自动改变位置,
'必须调用Move方法移动该控件
Source.Move X - dX, Y - dY
End Sub
Private Sub Picture1_DblClick()
If Not Label1.Visible Then
'恢复 Label1 显示
Label1.Top = ScaleTop
Label1.Left = ScaleLeft
Label1.Visible = True
End If
End Sub
Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
'结束拖动并触发DragDrop事件
Source.Drag vbEndDrag
Source.Visible = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -