创建动画的闪屏德尔福7 [英] Create animated splashscreen delphi 7

查看:131
本文介绍了创建动画的闪屏德尔福7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,而我的应用程序加载他的数据库做一个动画闪屏。
我已经创建了一个闪屏,但我想使图像动由左到右,而DB是越来越转换。一直在寻找了一段时间,但现在所有我能找到的是有关进度条...

I'm trying to make an animated splashscreen while my app loads his database. I already created a splashscreen but I want to make the image "move" from left to right while the db is getting converted. Been searching for a while now but all I could find is about progress bars...

下面是我的code:

SplashScreen := TSplashScreen.Create(Application) ;
SplashScreen.Show;
Application.Initialize;
SplashScreen.Update;
SplashScreen.lblStatus.Caption:='Loading...';
SplashScreen.Update;
SplashScreen.lblStatus.Caption:='Updating database...';
SplashScreen.Update;
Application.Initialize;
Application.CreateForm(TfmMain, fmMain);
Sleep(1000);

Application.CreateForm(TfmPrefs, fmPrefs);
Application.CreateForm(TfmCode, fmCode);
Application.CreateForm(TfmEmps, fmEmps);
Application.CreateForm(TfmRest, fmRest);
Application.ShowMainForm:=FALSE;

SplashScreen.Hide;
SplashScreen.Free;
Application.Run;

在我的splashscrren形式,我创建了5份相同的图像,并同时创建的主要形式,我希望图像可见,并在al​​ternance ......当然不可见:

On my splashscrren form, I created 5 duplicates of the same image and while the Main Form is created, I want the image to be Visible and not visible in alternance... ex:

while my db loads... begin
Splashscreen.Image1.Visible:=FALSE;
SplashScreen.Update;
Sleep(25);
SplashScreen.Image1.Visible:=FALSE;
SplashScreen.Update;
SplashScreen.Image2.Visible:=TRUE;....

等等!

有什么想法?

推荐答案

在启动过程中做在主线程繁重的工作(如初始化数据库和多种形式)
不闪屏很好地工作。主线程太占用做的GUI东西。把睡眠到code将无法正常工作,因为这会停止主线程做任何工作都没有。

Doing heavy work in the main thread during startup (like initializing database and many forms) does not work well with splash screens. The main thread is too occupied to do anything with the GUI. Putting Sleep into the code will not work, since this will stop the main thread to do any work at all.

这让你有两种选择:


  1. 做你的数据库初始化在另一个线程。
    有时也只初始化主要形式是一个不错的选择。
    该数据库的线程可以通过PostMessage的发送进度消息飞溅的形式要求。

  1. Do your database initializations in another thread. Sometimes also only initializing the main form is a good option. The database thread can send progress messages to the splash form via PostMessage calls.

在一个单独的线程启动闪屏。这是一种棘手的,因为你可能无法从另一个线程使用VCL。
而且还必须避免阻塞消息队列。
幸运的是,彼得下面做了一个很好的例子,如何做一个线程闪屏只使用Windows API调用

Start the splash screen in a separate thread. This is kind of tricky, because you may not use the VCL from another thread. And also you must avoid blocking the message queue. Luckily, Peter Below has made a good example how to do a threaded splash screen using only windows api calls.

有这个SO线程一些更多的信息:<一href=\"http://stackoverflow.com/questions/388506/displaying-splash-screen-in-delphi-when-main-thread-is-busy\">displaying-splash-screen-in-delphi-when-main-thread-is-busy.

There are some more information in this SO thread : displaying-splash-screen-in-delphi-when-main-thread-is-busy.

这篇关于创建动画的闪屏德尔福7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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