[vb]代码库
'移动窗体声明
Dim TF As Boolean
Dim MX As Integer
Dim MY As Integer
Private Sub form_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
'移动窗体MouseDown事件
TF = True
MX = x
MY = Y
End Sub
Private Sub form_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
'移动窗体MouseUp事件
TF = False
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
'移动窗体MouseMove事件
If TF = True And Button = 1 Then
Me.Move Me.Left - MX + x, Me.Top - MY + Y
End If
End Sub
-------------------------------------------------------
说明:
不用API就是好用啊!
大家可以变通着用~很好很强大!
Form可以使用其它控件代替,比如label,也就是点住标签可以移动窗口;再比如移动Frame,可以实现框架在本窗口内移动:
'点住label1移动frame1
声明
label1_MouseUp
label1_MouseDown
都一样
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
'移动框架MouseMove事件
If TF = True And Button = 1 Then
Frame1.Move Frame1.Left - MX + x, Frame1.Top - MY + Y
End If
End Sub
------------------------------------------------------
by: 发表于:2017-11-06 14:45:53 顶(0) | 踩(0) 回复
??
回复评论