我正在开发一款游戏,其中某些系统比较重,因此当游戏打开时,我想执行以下操作(伪代码):
Show Splashscreen
Load GameForm
When GameForm Is Completely Loaded
Splashscreen Close
Show GameForm
实际的VB代码应该怎样写呢?
我正在开发一款游戏,其中某些系统比较重,因此当游戏打开时,我想执行以下操作(伪代码):
Show Splashscreen
Load GameForm
When GameForm Is Completely Loaded
Splashscreen Close
Show GameForm
打开Visual Studio,选择新的VB.Net Winform项目。
右键单击解决方案,选择“添加新项”,然后选择“启动屏幕”。
双击Form1,在Form1_Load事件中进行编辑。
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Visible = False
Dim s = New SplashScreen1()
s.Show()
'Do processing here or thread.sleep to illustrate the concept
System.Threading.Thread.Sleep(5000)
s.Close()
Me.Visible = True
End Sub
VB.NET 2010(其他版本?)具有内置的启动画面指定机制。
将启动画面添加到您的Winform项目中。 项目菜单 -> 添加新项 -> 选择“启动画面”
在启动画面代码窗口中,它会给出一些提示来进行操作。
'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).
基本上,在项目属性中,应用程序选项卡下面有一个选择启动画面的选项。
这个更改添加的代码会在Application.Designer.vb文件中生成:
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateSplashScreen()
Me.SplashScreen = Global.WindowsApplication1.SplashScreen1
End Sub
默认情况下,使用这种方法分配启动画面会显示2000毫秒。
您可以阅读其他用法的文档@MSDN