Rocks, here the way that I've done it in all my pass project.
Code:'Put this code under a Basic Module and 'Assume the frmMain is your application main form Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As String) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Const SW_SHOWNORMAL = 1 Private xhwnd As Long Public Sub Main() Dim xAppName As String If App.PrevInstance Then xAppName = "Your Application Windows Title" xhwnd = FindWindow(0&, xAppName) If xhwnd <> 0 Then AppActivate xAppName xhwnd = ShowWindow(xhwnd, SW_SHOWNORMAL) End End If End If Load frmMain frmMain.Show End Sub




Reply With Quote