[英]SplashScreen staying open even after Application Exits
Windows Forms VB应用程序。我向应用程序添加了一个splashScreen。 而且它只闪烁一秒钟然后消失了,所以我在Form Load事件中添加了一个睡眠计时器...问题是,即使在应用程序退出后,splashScreen仍保持打开状态,而不是在sleeptimer结束时简单地关闭。导致此的表单加载事件的部分如下:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
Threading.Thread.Sleep(5000)
Me.WindowState = FormWindowState.Maximized
Dim _year As String = System.DateTime.Now.Year.ToString
我正在使用通过转到myproject创建的股票启动画面。 它的代码如下:Public NotInheritable Class SplashScreen1
'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
' of the Project Designer ("Properties" under the "Project" menu).
Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set up the dialog text at runtime according to the application's assembly information.
'TODO: Customize the application's assembly information in the "Application" pane of the project
' properties dialog (under the "Project" menu).
'Application title
If My.Application.Info.Title <> "" Then
Else
'If the application title is missing, use the application name, without the extension
'ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
End If
'Format the version information using the text set into the Version control at design time as the
' formatting string. This allows for effective localization if desired.
' Build and revision information could be included by using the following code and changing the
' Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar. See
' String.Format() in Help for more information.
'
' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)
Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)
'Copyright info
Copyright.Text = My.Application.Info.Copyright
End Sub
末级
与此相关的功能一无所有。.其余的用于填充表单标签和文本框...如果我删除Threading.Thread.Sleep(5000)行,则初始屏幕仅闪烁一秒钟,但完成后退出。任何想法吗?
答案不是使用Thread.Sleep
而是设置MinimumSplashScreenDisplayTime ( 显示初始屏幕的最短时间长度(以毫秒为单位 ) 。 )
要设置此:
Project>[Your project name] Properties
Application
标签 View Application Events
按钮 MyApplication
对象(左上方菜单) OnCreateSplashScreen
方法声明(右上方菜单) OnCreateSplashScreen
方法MinimumSplashScreenDisplayTime = 10000
添加以下行 (如果尚未这样做,则需要将初始屏幕表单设置为应用程序的初始屏幕,请参阅如何指定初始屏幕)
FormName.MinimumSplashScreenDisplayTime = 10000
它将显示初始屏幕10秒钟。
非常感谢您提供的帮助...它现在正在工作..但是我不得不注释掉
Me.WindowState = FormWindowState.Maximized
由于某种原因,它打破了最小飞溅时间。
这发生在我身上,是由OnLoad事件形式的错误引起的。 我清除了错误,启动屏幕开始正常运行。
顺便说一句,我已将此表单设置为“最大化”,该设置对初始屏幕没有影响
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.