我有一个没有边框的表单,我希望用户能够移动.我找不到任何可以让我这样做的东西. 是否可以移动边框设置为None的窗口? 引入一个布尔变量,如果当前拖动了表单,则保存状态,以及保存
是否可以移动边框设置为None的窗口?
引入一个布尔变量,如果当前拖动了表单,则保存状态,以及保存拖动起始点的变量.然后OnMove相应地移动表单.由于这已在其他地方得到解答,我只需将其复制并粘贴到此处即可.Class Form1
Private IsFormBeingDragged As Boolean = False
Private MouseDownX As Integer
Private MouseDownY As Integer
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Left Then
IsFormBeingDragged = True
MouseDownX = e.X
MouseDownY = e.Y
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
If e.Button = MouseButtons.Left Then
IsFormBeingDragged = False
End If
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
If IsFormBeingDragged Then
Dim temp As Point = New Point()
temp.X = Me.Location.X + (e.X - MouseDownX)
temp.Y = Me.Location.Y + (e.Y - MouseDownY)
Me.Location = temp
temp = Nothing
End If
End Sub
End Class
从http://www.dreamincode.net/forums/topic/59643-moving-form-with-formborderstyle-none/被盗
