'------------------------------------- 'Author: Eric D. Burdo, Sean Solo 'URL: http://www.redleif.com 'Added: 31-June-2000 '------------------------------------- 'Program: APPACTIVATER.ZIP '------------------------------------- 'Description: This sample will activate 'and maximize a previous instance of the 'app. ' 'This only works with a compiled EXE, and 'will not work if run from the IDE so you 'must compile to see it work correctly. '------------------------------------- Option Explicit Private Declare Function ShowWindow Lib "User32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As Any, _ ByVal lpWindowName As Any) As Long Private Const SW_SHOWMAXIMIZED = 3 Private Sub Form_Load() Dim hWnd As Long Dim sTitle As String If App.PrevInstance Then 'Is there a previous instance? sTitle = Caption 'Store the current caption of this form Caption = "Test ABC" 'Change the caption to something else hWnd = FindWindow(0&, "Test 123") 'Find the window If hWnd = 0 Then 'If the window is not found Exit Sub '>>>>>>>>>>>> Something is wrong, so leave Else 'Otherwise AppActivate sTitle 'Activate the program ShowWindow hWnd, SW_SHOWMAXIMIZED 'And maximize the window End If Unload frmMain 'Unload this form (ends the program) End If End Sub