1 (edited by AD1408 2017-11-04 19:06:41)

Topic: Splash

As far as I understand I can have a splash for displayed once FORM1 is loaded for specified time.


Is it possible to launch splash form just after application .exe double clicked withou the wait of Form1 loading?
This will be very useful when we have slow loading MVD app.


Here is a slower loading sample project with many forms etc., if needed:

Post's attachments

Attachment icon Solash and Login.zip 109.38 kb, 479 downloads since 2017-11-04 

Adam
God... please help me become the person my dog thinks I am.

Re: Splash

Hello AD1408

In my applications made with MVD, I frequently use a Splash on launching the exe
It works fine.

Use a Timer
CAREFUL : You have to place this piece of code between BEGIN and END. (at the end of the script)

     Timer2 := TTimer.Create(nil);             // Pour l'activation de l'écran d'accueil
      Timer2.OnTimer  := @OnTimer2;             // event procedure
      Timer2.Interval := 1000;                             // 1 sec
      Timer2.Enabled  := True;                //  Le Timer est déclenché
      Splash.ShowModal;                      //  On affiche l'écran d'accueil

Here there is Timer 2 because in the same application, I use another timer (Timer1)

Then, you have to initialize the timer

procedure OnTimer2 (Sender: TObject);       //  On initialise le splash
begin
     iTimer := iTimer + 1;
     if iTimer > 5 then                     //    The 5 seconds are gone
     begin
          Timer2.Enabled := False;          //  We unload the Timer2
          Splash.Close;                     // We close Splash form
          Timer2.Free;                      //  Essentiel : on libère le Timer2
          Waiting.Show;
          Application.ProcessMessages;      //  To avoid Windows to freeze the application
     end;
end;

And first of all, you have to declare Timer1 as a variable

Var Timer, Timer2 : TTimer; (from the beginning of the script, so you have a global variable)

Hope this helps you

JB

Re: Splash

Hi JB,


Thank you very much.......


I used your code as follows (added missing var for iTimer)

Var Timer, Timer2 : TTimer;
    iTimer : integer;

procedure OnTimer2 (Sender: TObject);       //  On initialise le splash
begin
iTimer := iTimer + 1;
if iTimer > 2 then                     //    The 5 seconds are gone
  begin
    Timer2.Enabled := False;          //  We unload the Timer2
    frmSplash.Close;                     // We close Splash form
    Timer2.Free;                      //  Essentiel : on libère le Timer2
    //Waiting.Show;
    Application.ProcessMessages;      //  To avoid Windows to freeze the application
  end;
end;


begin
  Timer2 := TTimer.Create(nil);             // Pour l'activation de l'écran d'accueil
  Timer2.OnTimer  := @OnTimer2;             // event procedure
  Timer2.Interval := 1000;                             // 1 sec
  Timer2.Enabled  := True;                //  Le Timer est déclenché
  frmSplash.ShowModal;                      //  On affiche l'écran d'accueil
end.

I couldn't understand what Waiting.Show; does refers to?


However, I still see windows progress circle showing for noticeable time though.
What I like to do is splash form shows after as soon as double clicking on MVD app and closes once the Form1 is loaded. In order to achieve this, splash form needs to run straight away, as it's own form without MVD app initialized I'm thinking?

Adam
God... please help me become the person my dog thinks I am.

Re: Splash

Adam,
I took a slightly different approach, but still using a timer. Instead of having the splash screen in your main project. I created a splash screen only app which will immediately open the splash screen and immediately run your main project and then close the splash screen (and app) after seven seconds. I chose seven seconds because that is about the length of time it takes to load your main project outside of the MVD development environment. Obviously you can adjust the time as you see fit. For ease in uploading to the forum I placed your main project within the splash screen app folder.

Post's attachments

Attachment icon Splash.zip 1.25 mb, 601 downloads since 2017-11-06 

5 (edited by AD1408 2017-11-06 05:22:22)

Re: Splash

Hi EHW,


Thank you very much............................


Now start of the splash as wanted.
I guess it's not possible doing it without timer; splash closes when main app form1 loaded as different users will have different loading time depending on their system.

Adam
God... please help me become the person my dog thinks I am.

Re: Splash

Adam,
I'm not aware of an MVD command to close an external app. If there is one, maybe Dimitry can enlighten us with it.  In the meantime I revised the Splash project to use another approach. It seems a little awkward, but it works. The result is the splash form will disappear when the first form of the main app is displayed. I utilized the Sqlite.db in the splash app to store a message. I pass the splash app path to the main app in order to attach the database in the main app. When the main app opens the first form it will update the Sqlite.db in the splash app with the message of "Done". The splash app, using a one second timer, checks the message in the Sqlite.db. As soon as it sees "Done", then it closes the splash form.

Post's attachments

Attachment icon Splash Revised.zip 1.25 mb, 800 downloads since 2017-11-06 

Re: Splash

Great stuff EHW !!!


Thank you very much.......................
Truly appreciated..................................


Perhaps Dmitry can add a ready made splash form component that we can use in not so distant future hopefully. Splash form that's in line of your solution.
♦ Splash form that starts immediately without the wait of app load
♦ And it closes once MVD app loaded (form1)

Adam
God... please help me become the person my dog thinks I am.

8 (edited by derek 2017-11-06 19:15:26)

Re: Splash

Hi Adam, EHW, Jean,
I believe the original issue was that you'd put your splash form within the form1_onshow procedure rather than on launch (ie between the final 'begin' and 'end' of any script.
If you use the TTimer approach, you still need to have an idea of how many seconds your slow-loading app is going to take, in which case you might just as well stick with the 'sleep' instruction in your script as you were already doing (in your example sleep(7000) using EHW's timings).
With any of my slow loading apps, I use a splash screen with the sleep command and use the time to pop up different messages while waiting for the application to load (ie name of the app for a couple of seconds, then the author for a couple of seconds etc etc).  It doesn't reduce the overall load time of the application but at least the user doesn't think it's stopped running!
Please see the attached for the sort of thing I'm meaning (I've used a simple timer in this example rather than different timed messages but the principle is exactly the same).
Hope this helps,
Regards,
Derek.

Post's attachments

Attachment icon Splash and Login.zip 457.72 kb, 586 downloads since 2017-11-06 

Re: Splash

Hi Derek,


Thank you very much for the sample project contains your solution.........


Unless, I'm getting something wrong there is still some time laps between double click to launch MVD app .exe and splash screen to appear. Perhaps it's waiting for MVD app to initialize?


Also I couldn't make counter and message labels on frmSplash visible for editing etc purposes?

Adam
God... please help me become the person my dog thinks I am.

Re: Splash

Hi Adam,
There is always going to be some lag unless you go down the route suggested by EHW;  the point was that the lag to load frmsplash is noticeably REDUCED  by moving the splash screen call from the form1_onshow procedure and placing it between the 'begin' and 'end' when the application loads.
It's standard MVD that when you leave the label captions blank, they do not show by default when editing the frmsplash form.  Just click on the relevant label in the 'controls' tab (see screen shot) and its outline will be displayed thereby allowing you to edit it (it's just like when you have objects that are in the background behind other objects (ie a label behind a panel) when designing your forms and you need to 'edit' them without moving the foreground object).
Derek.

Post's attachments

Attachment icon edit label.jpg 139.89 kb, 251 downloads since 2017-11-07 

Re: Splash

Hi Derek,


the point was that the lag to load frmsplash is noticeably REDUCED  by moving the splash screen call from the form1_onshow procedure and placing it between the 'begin' and 'end' when the application loads.

Agreed.
Thank you very much for the alternative........................
Truly appreciated...................................................


It's standard MVD that when you leave the label captions blank, they do not show by default when editing the frmsplash form.  Just click on the relevant label in the....

Thank you very much for the info.......

Adam
God... please help me become the person my dog thinks I am.