我知道這將工作如果我沒有使用網絡瀏覽器填寫我的表單。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