: : : : : : : : : : I have made a program containing many big pictures and when I start the program on a slower computer then mine it takes some time for the program start.
: : : : : : : : : :
: : : : : : : : : : And I know that I could just put the pictures in a folder and have the program load them when they are to be shown but I want to hav all the pictures in the program so what I need is some kind of loading time when the program start
: : : : : : : : : :
: : : : : : : : : : Can anyone help me...
: : : : : : : : : :
: : : : : : : : : I'm not sure what you mean by "loading time", but why don't make a nice splash form and put that up while your program is loading and initializing?
: : : : : : : : :
: : : : : : : :
: : : : : : : : I have tryed that I don't work, you see the program still must load up all the images before anything can happen (like showing a nice splashy form) any more ideas?
: : : : : : : :
: : : : : : : You can show a splash screen before the pictures load. Here is an example code of the project source to show you how to do it:
: : : : : : :
: : : : : : : program Project1;
: : : : : : :
: : : : : : : uses
: : : : : : : Forms,
: : : : : : : Unit1 in 'Unit1.pas' {Form1},
: : : : : : : SplashUnit in 'SplashUnit.pas' {SplashForm};
: : : : : : :
: : : : : : : {$R *.RES}
: : : : : : :
: : : : : : : begin
: : : : : : : SplashForm := TSplashForm.Create(nil); // Create the splash form as first thing
: : : : : : : try
: : : : : : : SplashForm.Show; // and immediately show it
: : : : : : : Application.Initialize; // start to initialize the application
: : : : : : : Application.CreateForm(TForm1, Form1); // and create the other forms
: : : : : : : finally
: : : : : : : SplashForm.Free; // free the splash form
: : : : : : : Application.Run; // run the program itself
: : : : : : : end;
: : : : : : : end.
: : : : : : :
: : : : : : : This code assumes that you load the images in the OnCreate() of any other form than the SplashForm. It also assumes that you don't do any lengthy initialization in the "initialization"-part of any of the units.
: : : : : : :
: : : : : : Hey thanks alot I'll try it out right now
: : : : : :
: : : : : Hello again, I have just tryed out the code and it didn't work but I change it alitle and I got the SplashForm to show before everything eles but the problem is that if I put any text or pictures in the SplashForm they won't show... help.
: : : : :
: : : : The first thing you need to do in the OnCreate() of the first form you make (form1 in the code above) is call SplashForm.Repaint. This is necessary, because the program will not yet see any repaint commands from windows. If you have a control, which is updated periodically, you need to call its Repaint() method also after each update.
: : : :
: : : Well I did put the code above in the OnCreate() of the first form but when I compiled the program, the program just stops att the the SplashForm and nothing happends
: : :
: : Strange, in my test project it worked perfectly. Could you post the first part of the OnCreate() here? Also have you got any lengthy processes in the SplashForm?
: :
: Okej this is exacly how I have done, try to see if you can find any misstake:
:
: procedure TForm1.FormCreate(Sender: TObject);
: begin
: SplashForm := TSplashForm.Create(nil);
: try
: SplashForm.Show;
: Application.Initialize;
: Application.CreateForm(TForm1, Form1);
: finally
: SplashForm.Free;
: Application.Run;
: end;
: end;
:
: And when I compile this the SplashForm will show but after that nothing happends the program just freezes up and I can't do anything but use the "Program reset" button
:
: But one part of your code I didd't understand was:
:
: uses
: Forms,
: Unit1 in 'Unit1.pas' {Form1},
: SplashUnit in 'SplashUnit.pas' {SplashForm};
:
: Because when I add this part under the "uses" I can't compile the program. But as I said I changed the code to:
:
: procedure TForm1.FormCreate(Sender: TObject);
: begin
: SplashForm := TSplashForm.Create(nil);
: SplashForm.Show;
: end;
:
: And now the SplashForm shows before everything and when all the pictures have been loaded the first from will appeare BUT on images of text will be shown on the SplashForm
:
What Zibadian showed you was the *Project Source*. I think you've conflated that and the unit source. Try removing everything from that OnCreate handler and just put the repaint within the try..finally block. The idea here is create the splash screen and show it, to let the program itself create forms and all, and then to destroy splash screen.