I am running a splash screen until all of the main form controls are bound to data. Once that is complete the splash is closed but the main form is not the top form.

How can I make the main form active?

When I start this application from a shortcut everything works fine. If I run this application from Windows Explorer, Windows Explorer maintains the focus and not the application.

Thanks

Mark Baird

' Application main
Shared Sub Main()
   Application.Run(
New MainForm)
End Sub 'Main

' Paint the form only if the splash screen is gone
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  If Not (splash Is Nothing) Then
    Return
  End If
  MyBase.OnPaint(e)
End Sub 'OnPaint

' Paint the form background only if the splash screen is gone
Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs)
  If Not (splash Is Nothing) Then
    Return
  End If
  MyBase.OnPaintBackground(e)
End Sub 'OnPaintBackground

' Shuts down and cleans up the splash screen
Private Sub CloseSplash()
  If splash Is Nothing Then
    Return
End If

' Shut down the splash screen
  splash.Invoke(New EventHandler(AddressOf splash.KillMe))
  splash.Dispose()
  splash =
Nothing
End Sub 'CloseSplash

Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

' Create a new thread from which to start the splash screen form
Dim splashThread As Thread = New Thread(New ThreadStart(AddressOf StartSplash))
  splashThread.Start()
  Application.DoEvents()
  Application.DoEvents()'splash.lblProgress.Text = "Loading proofs..."
  LoadAvailableServers()
  CloseSplash()
End Sub

' Ensures that if the form is somehow closed before loading is complete,
' the splash form will be closed and released as well.
Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)
' Make sure the splash screen is closed
  CloseSplash()
  MyBase.OnClosing(e)
End Sub 'OnClosing