Vb编程的窗口改成无边框后怎么随意点一处可以拖动窗口?? 谢谢啦啦啦啦啦
4个回答
展开全部
用mousedown和mousemove事件结合就可以了。以下程序可以实现点击窗体空白部分对窗体进行拖曳移动。
Dim X0!, Y0!
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
X0 = X
Y0 = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Me.Left = Me.Left + X - X0
Me.Top = Me.Top + Y - Y0
End If
End Sub
展开全部
Dim ismousedown As Boolean
Private Sub Form_Load()
ismousedown = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ismousedown = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ismousedown = True Then
Me.Left = Me.Left + X
Me.Top = Me.Top + Y
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
ismousedown = False
End Sub
一个简单的
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
窗体放一个timer 设置为false
Option Explicit
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Dim p As POINTAPI, X1 As Long, Y1 As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Interval = 10
Timer1.Enabled = True
GetCursorPos p
X1 = p.X
Y1 = p.Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
GetCursorPos p
Form1.Left = Form1.Left + (p.X - X1) * 15
Form1.Top = Form1.Top + (p.Y - Y1) * 15
X1 = p.X
Y1 = p.Y
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你的无边框是将borderstyle改为0吗?
追问
是的,改为零就不能够移动了。
追答
使用窗体Form的mousedown和mousemove事件,当鼠标点下时获得当前窗体坐标,然后在鼠标移动事件中重新加载窗体位置
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询