以下是我目前用的代码 myform,zbx,zby是全局变量
自定义函数ydchuank1
Dim x As Integer = System.Windows.Forms.Cursor.Current.Position.X
Dim y As Integer = System.Windows.Forms.Cursor.Current.Position.Y
zbx = myform.left - x
zby = myform.Top - y
自定义函数ydchuank2
Dim x As Integer = zbx + System.Windows.Forms.Cursor.Current.Position.X
Dim y As Integer = zby + System.Windows.Forms.Cursor.Current.Position.Y
myform.Left = x
myform.Top = y
myform.Width = myform.Width
myform.Height = myform.Height
mousemove事件
If e.Button = Windows.Forms.MouseButtons.Left And basemainform.WindowState <> Windows.Forms.FormWindowState.Maximized Then
Functions.Execute("ydchuank2")
End If
mousedown事件
If e.Button = Windows.Forms.MouseButtons.Left And basemainform.WindowState <> Windows.Forms.FormWindowState.Maximized Then
myform = basemainform
Functions.Execute("ydchuank1")
End If