Hey,
OK, if there is already a copy of my application open, i wanna bring that copy to the front,

and then unload the new copy.

Now, it is making the screen flicker, but nothing other then that happens...

should this work?

My app's form caption is "[" & webbrowser PageTitle & "] - The Walks Chat"

so is there something im doing wrong with this, since it dont work proper?


VB Code:
  1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  2. Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
  3.  
  4. Private Sub Form_Load()
  5.  
  6.     If App.PrevInstance = True Then GoTo PrevInst:
  7.  
  8. ' Some code here
  9.  
  10. Exit Sub
  11. PrevInst:
  12.     ' Theres a previous open copy of the application,
  13.     ' so lets bring that copy to the front, and unload this copy
  14.     Dim WinHan As Long
  15.     WinHan = FindWindow(vbNullString, " - The Walks Chat")
  16.     WinHan = SetForegroundWindow(WinHan)
  17.     Unload Me
  18. Exit Sub
  19. ' More Sub's ETC
  20. End Sub