我知道这将工作如果我没有使用网络浏览器填写我的表单。VB.NET合并Alt +窗口+拖入表格
Dim drag As Boolean
Dim mousex As Integer
Dim mousey As Integer
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
'--- Alter the return value of WM_NCHITTEST when the ALT key is down
If m.Msg = &H84 AndAlso (Control.ModifierKeys And Keys.Alt) <> 0 Then
'--- Turn HTCLIENT into HTCAPTION
If m.Result = 1 Then m.Result = 2
End If
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
drag = True
mousex = Windows.Forms.Cursor.Position.X - Me.Left
mousey = Windows.Forms.Cursor.Position.Y - Me.Top
End If
Timer1.Enabled = True
Timer1.Interval = 2500
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If drag Then
Me.Top = Windows.Forms.Cursor.Position.Y - mousey
Me.Left = Windows.Forms.Cursor.Position.X - mousex
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Timer1.Enabled = False
drag = False
End Sub
但是我发现一个Windows程序,具有Linux的使用Alt +拖放窗口功能称为AltWindowDrag我知道我可以使用的Process.Start为我做了以下运行的程序......
Process.Start(Application.StartupPath & "\AltWindowDrag\AltWindowDrag.exe")
但是,这个问题是当我关闭我的应用程序时,AltWindowDrag仍在运行。无论如何,当我的窗体关闭时,我可以关闭AltWindowDrag?
任何帮助将不胜感激。
编辑!
一个在另一个论坛上的家伙帮助我解决了这个问题,所以对于那些遇到同样问题的人。这是代码。
Dim proc As Process
Private Sub btnStart_Click(sender As System.Object, e As System.EventArgs) Handles btnStart.Click
proc = Process.Start(Application.StartupPath & "\AltWindowDrag\AltWindowDrag.exe")
End Sub
Private Sub Form1_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If Not proc Is Nothing Then
If Not proc.HasExited Then
proc.Kill()
End If
End If
End Sub
如果是您使用的解决方案,则应将解决方案移至答案,并且可能接受答案。 – 2012-07-24 04:12:35
两天前我已经做到了。 – 2012-07-25 12:52:27