Visual Basic SplashScreen无法与版本选择表单一起使用

时间:2014-02-13 03:21:57

标签: vb.net visual-studio-2012

我会尽量保持这个简短而不遗漏细节。我在使用.NET 4.5的Visual Stuido 2012工作

我有一个启动画面,一个“版本选择”形式作为我的主要启动形式,然后从那里根据用户的选择以两种方式分支。

版本选择可以保存用户将来的选择,并检查他们是否有保存的设置,如果他们这样做,它会跳过选择表格并直接进入他们的版本。我遇到的问题是,当用户有一个保存的版本时,启动画面会保持启动状态并且永远不会关闭,除非我强制它。

我尝试在应用程序事件中使用MinimumSplashScreen时间,但这没有帮助。仅当用户保存了版本时才会发生这种情况。

对此有何想法?我可以根据需要发布更多细节。提前致谢


来自评论

Private Sub Version_Selection_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load 
    If My.Settings.VersionSelected = "OSRS" Then 
        'Code to close initial form and load old school 
        Dim OSmain As New OldSchoolMain 
        OSmain.Show() 
        Me.Close() 
    ElseIf My.Settings.VersionSelected = "RS3" Then 
        'Code to close intital form and load RS3 
    End If 
End Sub

Private Sub btnConfirmSelection_Click(sender As Object, e As EventArgs) Handles btnConfirmSelection.Click 
    If radOSRS.Checked = True Then 
        If cboxSaveVersion.Checked = True Then 
            My.Settings.VersionSelected = "OSRS" 
        End If 
        Dim OSmain As New OldSchoolMain 
        OSmain.Show() 
        Me.Close() 
    ElseIf radRS3.Checked = True Then 
        If cboxSaveVersion.Checked = True Then 
            My.Settings.VersionSelected = "RS3" 
        End If 
        Dim RS3main As New RS3Main 
        RS3main.Show() 
        Me.Close() 
    End If 
End Sub 

1 个答案:

答案 0 :(得分:0)

查看您的代码,我认为您的Splash Screen的问题在于您在完成之前关闭了启动表单。我会尝试使用Form Shown事件,因为在SplashScreen完成之前不会被触发,我也是最小化表单,试图阻止它在屏幕上短暂闪烁。看看这样的东西是否适合你。

Private Sub Splash_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
    If My.Settings.StartupForm = "Form1" Then
        Dim frm As New Form1
        frm.Show()
        Me.WindowState = FormWindowState.Minimized
        Me.ShowInTaskbar = False
        Me.Close()
   ElseIf My.Settings.StartupForm = "Form2" Then
        Dim frm As New Form2
        frm.Show()
        Me.WindowState = FormWindowState.Minimized
        Me.ShowInTaskbar = False
        Me.Close()
    End If
End Sub