Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
Public Const GW_HWNDPREV = 3
Declare Function OpenIcon Lib "user32" (ByVal hwnd As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) _
As Long
Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long) As Long
Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Private Sub Form_Load()
If App.PrevInstance Then
ActivatePrevInstance
End If
End Sub
Sub ActivatePrevInstance()
Dim strOldTitle As String
Dim lngPrevHndl As Long
Dim lngResult As Long
'Save the title of the application.
strOldTitle = App.Title
'Rename the title of this application so FindWindow
'will not find this application instance.
App.Title = "unwanted instance"
'Attempt to get window handle using VB4 class name.
lngPrevHndl = FindWindow("ThunderRTMain", strOldTitle)
'Check for no success.
If lngPrevHndl = 0 Then
'Attempt to get window handle using VB5 class name.
lngPrevHndl = FindWindow("ThunderRT5Main", strOldTitle)
End If
'Check if found
If lngPrevHndl = 0 Then
'Attempt to get window handle using VB6 class name
lngPrevHndl = FindWindow("ThunderRT6Main", strOldTitle)
End If
'Check if found
If lngPrevHndl = 0 Then
'No previous instance found.
Exit Sub
End If
'Get handle to previous window.
lngPrevHndl = GetWindow(lngPrevHndl, GW_HWNDPREV)
'Restore the program.
lngResult = OpenIcon(lngPrevHndl)
'Activate the application.
lngResult = SetForegroundWindow(lngPrevHndl)
'End the application.
Unload Me
End Sub