Winform 启动画面 - VB.NET - 计时器 [英] Winform Splash Screen - VB.NET - Timer

查看:21
本文介绍了Winform 启动画面 - VB.NET - 计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序和表单上有一个闪屏.我有一个计时器.

I have a splash screen on the application and on that form. I have a timer.

Private Sub Splash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

   SplashTimer.Start()

   ' Set application title
   ' Set Version
 Me.Show()
        'Me.Refresh()
        'System.Threading.Thread.Sleep(2000)
        'Login.ShowDialog()
        'Login.AllowTransparency = True
  End Sub

定时器的间隔设置为 5000.

Interval on the timer is set to 5000.

  Private Sub SplashTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplashTimer.Tick
        SplashTimer.Stop()
        Login.Show()
        Login.AllowTransparency = True
        Me.Hide()
    End Sub

我在这里设置了断点,但它似乎没有达到这个断点.我取消注释 Me.Refresh()

I set breakpoint here but it doesn't seem to hit this breakpoint. I uncommented Me.Refresh()

启动画面正在关闭.然后登录显示一个继续按钮.当你点击继续按钮

Splash screen is closing. Then Login is shown with a continue button. When you click continue button

MainMenu.Show() 'this form should be shown as this is the main window of the application but it's not showing.
            Me.Close() 'closes login window

没有显示窗口,应用程序挂起.任何输入将不胜感激.

No window shows up and the application is hanging. Any inputs will be greatly appreciated.

推荐答案

我建议使用 Visual Studio 提供的内置启动画面:

I would suggest using the built in Splash Screen that is provided by Visual Studio:

转到项目"菜单并选择添加 Windows 窗体"并选择启动画面模板:

Go to the "Projects" menu and select "Add Windows Form" and select the Splash Screen template:

然后在项目的应用程序设置中,选择该表单作为启动画面:

Then in the Project's Application settings, select that form to be the Splash screen:

您的启动表单应该是您的登录表单,而不是初始屏幕表单.

Your start up form should be your login form, not the splash screen form.

更新:

单击我的项目的应用程序"屏幕中最后一个图像上的查看应用程序事件"按钮,并添加此代码以设置 MinimumSplashScreenDisplayTime 值:

Click on the "View Application Events" button on the last image from your My Project's Application screen and add this code to set the MinimumSplashScreenDisplayTime value:

Imports System.Collections.ObjectModel

Namespace My
  Partial Friend Class MyApplication
    Protected Overrides Function OnInitialize(commandLineArgs As ReadOnlyCollection(Of String)) As Boolean
      Me.MinimumSplashScreenDisplayTime = 5000
      Return MyBase.OnInitialize(commandLineArgs)
    End Function
  End Class
End Namespace

您的启动画面将在屏幕上停留 5000 毫秒或 5 秒.

Your splash screen will remain on the screen for 5000 milliseconds, or 5 seconds.

这篇关于Winform 启动画面 - VB.NET - 计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆