11.02.2010

Splash-Screen-Problem in VB.Net

Problem: Ein Formular das nach einem Splash-Screen gezeigt werden soll und nicht das Hauptformular ist (z.B. Login) erhält nicht den Fokus.

Lösung:
private m_FormLoaded as boolean



Private Sub frmLogin_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
    m_FormLoaded = True

    txtUserID.Text = String.Empty
End Sub

Private Sub txtUserID_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtUserID.GotFocus
'This hack ensures that the user id field receives focus.
'For some reason it appeared to have focus however was not responding until
'user clicked on the Form!

    If m_FormLoaded = False Then
        System.Windows.Forms.SendKeys.Send(ControlChars.Back)

        txtUserID.Text = String.Empty

    End If
End Sub
Quelle:
http://bytes.com/topic/visual-basic-net/answers/638041-application-startup-event-splash-login-screens