2006. július 24., hétfő

Creating a splash screen


Problem/Question/Abstract:

How do I make a splash screen for my application?

Answer:

First make a new form, this will be your SpashSreen.

Set Name to "Splash".
Set BorderStyle to "bsNone".
Put an image or whatever on it.
Make sure it is not auto-created. (Shift-Ctrl-F11)
Now edit your main program body:

program MyApp;
{... }
begin
  Application.Initialize;

  { ---------- PUT THIS IN: ------------- }
  Splash := TSplash.Create(Application);
  Splash.Show;
  Splash.Refresh;
  { ------------------------------------- }

  ..
    Application.CreateForm(...);
    Application.Run;
end;

Now edit the OnShow event of your main form:

procedure TMainForm.FormShow(Sender: TObject);
begin
  {...}
  { Free Splash screen }
  Splash.Free;
end;

You now have a splash screen!
Tip: If you place the Spash.Free in a OnTimer event, you can control how long the user sees your splash screen.

Nincsenek megjegyzések:

Megjegyzés küldése