首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

窗体没有边框如何移动

2012-02-14 
窗体没有边框怎么移动?把一个窗体的formborderstyle属性设为None时,就不可以拖动了,怎么能让它没有边框还

窗体没有边框怎么移动?
把一个窗体的formborderstyle属性设为None时,就不可以拖动了,怎么能让它没有边框还可以拖动

[解决办法]
Dim down As Boolean
Dim newPoint As Point

Private Sub UserControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
down = True
newPoint = New Point(e.X, e.Y)
End Sub

Private Sub UserControl1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If (down) Then
' 根据鼠标的移动,实际移动控件
Dim diffx, diffy As Integer
diffx = newPoint.X - e.X
diffy = newPoint.Y - e.Y
Me.Location = New Point(Me.Location.X - diffx, Me.Location.Y - diffy)
End If
End Sub

Private Sub UserControl1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
down = False
End Sub

很简单的......

热点排行