總網頁瀏覽量

2011年10月3日 星期一

[VB.NET] 當程式的前景被其他程式拿走時判斷並拿回前景

Public Class Form1
   Private Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
 
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Timer1.Interval = 300
      Timer1.Enabled = True
   End Sub
 
   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      SetForegroundWindow(Me.Handle)
   End Sub
End Class

沒有留言:

張貼留言