Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to close a splash screen at the time I choose

Status
Not open for further replies.

TimSNL

Programmer
Sep 11, 2001
119
0
0
AU
I have setup a splash scren for my appliaction as per
My appliaction takes some time to draw its main form the first time, and the splash screen vanishes before this process is complete. Is it possible to free the splash from from the main form of the application instead of just before the Application.Run in the main pas file?

Any suggestions about this would be helpful, thankyou.

---------------------------------------
The maggotts always win.
 
Without following your link, there are lots of way that you can implement a splash screen.
The simplist method is launching a modal borderless form from your main form 'formcreate'.
This can have a timer to close after a set period, and a button for the user to close it immediately.
It does depend on whether or not you "must" hide the main form or allow it to be visible behind the splash.




Steve: Delphi a feersum engin indeed.
 
As indicated in the link you posted - if possible, be sure to include some sort of progress indicator (not just some changing text that describes what's going on - use a TProgressBar or somesuch) to let your users know how long they have to wait.
 
Thankyou for your suggestions. This is how i have solved the problem at the moment ...

I have an initial splash form that is displayed in the standard way as the link in my first post explains. This splash screen covers the first few seconds of initialization. Then I instantiate another splash screen and Show it inside the OnShow event of my main form. Creating it and Releasing it inside the scope of the OnShow procedure.

This seems to work ok. There is just a small flicker when the splash window changes to the second one.

Griffyn you are right, I should put a progress indicator on it at some stage.

---------------------------------------
The maggotts always win.
 
I can think of several very well known applications that dont give any indication of the splash screen 'time to run'
Delphi 7 for example!! and that can take ages to initalise on a slow machine.
Unless we are talking several minutes, I would not bother with a progress indicator. Just my opinion.


Steve: Delphi a feersum engin indeed.
 
the way i do it is.

set the splash form to stayontop.

dont close the splash form in the project source.

put a timer on the main form and set it to close and free the splash form and the timmer after a couple of seconds.

enable the timer on main form show.



Aaron Taylor
John Mutch Electronics
 
aaronjme, have you actually tried this?
I tried to do it this way as well, it worked but there was a side effect. The main form would not close. I dont know how to get around this without using Application.Terminate to close the main form. Did you find this problem as well?

---------------------------------------
The maggotts always win.
 
Form1 is MainForm, Form3 is your "SplashScreenForm" with FormStyle=fsNormal and with Timer1 component (set Enabled=false Property of Timer1 and Interval=1000 (for example, or set other value - this is number of miliseconds you want SplashScreen be visible )). Use this code:

Code:
procedure TForm1.FormCreate(Sender: TObject);
var
  SplashAbout: TForm3;
begin
  // creates SplashForm:
  SplashAbout := TForm3.Create (Application);
  SplashAbout.MakeSplash;
  SplashAbout.Timer1.Enabled := True;
end;

-------------------------------------
Code:
procedure TForm3.MakeSplash;
begin
  BorderStyle := bsNone;
  FormStyle := fsStayOnTop;
  Show;
  Update;
end;


Code:
procedure TForm3.Timer1Timer(Sender: TObject);
begin

  Close;
  Release;

end;


Best wishes!
 

Here is an extract from the .dpr of one of my projects:
Code:
begin
  Application.Initialize;
  // Put "splash" screen.
  frmSplash := TfrmSplash.Create(Application);
  frmSplash.Show;
  frmSplash.Repaint;
  Application.Title := 'Find Closest Office';
  frmSplash.MessageLine := 'Login to the database...';
  Application.CreateForm(TINVSCHED, INVSCHED);
  // Don't show main form if user didn't log in.
  if INVSCHED.Connected then
    begin
      frmSplash.MessageLine := 'Loading office data...';
      frmSplash.Repaint;
      Application.CreateForm(TOfficeData, OfficeData);
      Application.CreateForm(TfrmMain, frmMain);
    end;
  // Kill "splash" screen.  
  frmSplash.Hide;
  frmSplash.Free;
  Application.Run;
end.
There is no progress bar, but the splash screen has a description of the application and some instructions on how to use it. It gives the user something to read while the app is loading.

The TINVSCHED form creates a login dialog that prompts the user for an ID and password.

 
Have you tried putting the close code in the FormActivate event? You could just enclose it with an if statement to see wether or not the form is there or not.

[bobafett] BobbaFet [bobafett]

Code:
if not Programming = 'Severe Migraine' then
                       ShowMessage('Eureka!');
faq102-5352
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top