一个古老的问题—如何在WinForm中显示Splash Screen

步骤1:
在SplashScreen窗体上拖放一个Timer控件,并设置Interval属性为3000(代表停留3秒钟),在时间到后关闭窗体;

ExpandedBlockStart.gif ContractedBlock.gif      Private   Sub Timer1_Elapsed() Sub Timer1_Elapsed(ByVal sender As System.ObjectByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
InBlock.gif        
Me.Close()
ExpandedBlockEnd.gif    
End Sub

步骤2:
在主窗体的构造函数中使用下列代码:
ExpandedBlockStart.gif ContractedBlock.gif Public   Sub New() Sub New()
InBlock.gif        
MyBase.New()
InBlock.gif
InBlock.gif        
Me.Cursor = Cursors.AppStarting
InBlock.gif        
'该调用是 Windows 窗体设计器所必需的。
InBlock.gif
        InitializeComponent()
InBlock.gif
InBlock.gif        
'在 InitializeComponent() 调用之后添加任何初始化
InBlock.gif

InBlock.gif        
'加载图书类型至TreeView
InBlock.gif
        PopulateBookType()
InBlock.gif
InBlock.gif        
'显示Splash Screen
InBlock.gif
        Dim frm As New SplashForm
InBlock.gif        frm.FormBorderStyle 
= FormBorderStyle.None
InBlock.gif        frm.MaximizeBox 
= False
InBlock.gif        frm.MinimizeBox 
= False
InBlock.gif        frm.StartPosition 
= FormStartPosition.CenterScreen
InBlock.gif        frm.ControlBox 
= False
InBlock.gif        frm.ShowInTaskbar 
= False
InBlock.gif        frm.ShowDialog()
InBlock.gif
InBlock.gif        
Me.StartPosition = FormStartPosition.CenterScreen
InBlock.gif        
Me.Cursor = Cursors.Default
ExpandedBlockEnd.gif    
End Sub
注意在上述代码中需要使用frm. ShowDialog()而不能使用frm. Show,否则将不能显示SplashScreen;另外frm.ShowInTaskbar=false将使得在显示SplashScreen同时,不会在任务栏中显示内容。
参考网址:
Windows Forms FAQ - Windows Forms
Windows Forms FAQ - Windows Forms 2.0

转载于:https://www.cnblogs.com/chinapro/archive/2005/05/07/150509.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值