English 中文(简体)
1. 创造温和的眼镜
原标题:Create animated splashscreen delphi 7

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...

我的守则如下:

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;

在我的间谍活动中,我制作了5个同样的影像复制件,在创建主要表格时,我希望图像能够显露,不会出现在变化之中。

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

等等。

任何想法?

最佳回答

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.

This leaves you with two options :

  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.

  2. 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 thread :

问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签