可以在Forms应用程序中实现WPF风格的启动画面吗?
在使用 Visual Studio 10 项目中的资源时,我遇到了一个名为“Splash Screen”的构建操作,这让我在 WPF 简洁的启动屏幕功能。
四处搜寻,我发现了这篇关于在 Windows 窗体中制作启动屏幕,但这是一种不同类型的方法:WinForms 版本不是在应用程序加载之前使用本机代码加载启动屏幕,而是在主窗体初始化时简单地显示它。
有什么方法可以在 WinForms 应用程序中实现这种高级类型的启动屏幕吗?
Whilst playing around with resources in my visual studio 10 project, I came across a build action called "Splash Screen", which led me to find this article on the neat splash screen capabilities of WPF.
Hunting around, I found this MSDN article on making a splash screen in Windows Forms, but it's a different type of approach: rather than loading the splash screen using native code before the app loads, the WinForms version simply displays it whilst the main form is initialising.
Is there any way to achieve this superior type of splash screen in a WinForms app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的。在将 WPF 应用程序与 .NET 3.5 SP1 一起打包之前,我对其进行了实现。
基本上,您创建一个本机 Win32 窗口并在加载程序集和初始化应用程序时显示 BMP 图像。您可以使用其他图像格式,但首选 BMP,因为它需要加载的库数量最少。
快速谷歌“创建本机启动窗口”出现了几篇文章。我发现(通过快速扫描)最全面的是 Bradley Grainger 的: 显示使用 C++ 的启动屏幕。本文是针对 WPF 编写的,但概念相同:创建本机窗口、启动您的应用程序、关闭窗口。
我将在明天的工作中查看我的实施源,并用示例更新我的答案。
在那之前,请谷歌并研究已有的许多示例以开始使用。
更新
正如所承诺的,下面是实现启动屏幕的完整示例(有一些内容)。
Yes. I did an implementation for our WPF application before it came packaged with .NET 3.5 SP1.
Basically, you create a Native Win32 window and display a BMP image whilst you are loading the assemblies and initialising your application. You can use other image formats, but BMP is preferred as it requires the least number of libraries loaded.
A quick google for "creating native splash window" came up with several articles. The most comprehensive that I found (from a quick scan) was by Bradley Grainger: Displaying a Splash Screen with C++. The article was written for WPF in mind, however the concept the same: create a native window, launch your application, close window.
I will have a look at the source for my implementation tomorrow at work and update my answer with an examples.
Until then, google and research the many examples already out there to get started.
UPDATE
As promised, below is a full example of implementing a splash screen (there is a bit to it).
为此可以使用非 WPF 表单,而且效果非常好。顺便说一句,这也是 VS2008 中的一个功能。
It is possible to use a non-WPF form for this, and it works quite happily. As an aside, it was a feature in VS2008 as well.