我正在学习vstudio 2012,我正试图用“borderstyle = none”制作一个可移动的表单,但我不能。
我在谷歌发现的所有信息都谈到了vb4 5& 6关于这个问题,版本对我来说太早了,我不能使用它们(我不知道如何)。
我的声明非常简单,我只需要通过点击应用程序(表单上的任何位置)使窗口可移动:
Public Class Form1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label2.Text = "X: " & MousePosition.X
Label3.Text = "Y: " & MousePosition.Y
End Sub
Sub Form1_KeyPress(ByVal sender As Object, _
ByVal e As KeyPressEventArgs) Handles Me.KeyPress
If e.KeyChar >= ChrW(3) Then
Clipboard.SetDataObject(Label2.Text & " " & Label3.Text)
End If
End Sub
End Class
请帮忙吗?谢谢你的阅读
答案 0 :(得分:0)
我已经解决了这个问题,谢谢。
Private ArrastrarForm As Boolean
Private PosicionMouseHeader As Point
Private tmpPoint As Point
Private Sub Form1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
ArrastrarForm = True
PosicionMouseHeader = e.Location
End If
End Sub
Private Sub Form1_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If ArrastrarForm Then
tmpPoint = Me.Location + e.Location - PosicionMouseHeader
Me.Location = tmpPoint
End If
End Sub
Private Sub Form1_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
If e.Button = Windows.Forms.MouseButtons.Left Then
ArrastrarForm = False
End If
End Sub
再见!