Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

problems with creating a splash-screen

Posted on 2002-04-27
9
Medium Priority
?
266 Views
Last Modified: 2010-04-04
Hi experts,

with the code quoted below I try to create a splash-screen. Unfortunately it does not work as
desired.

The code is syntactically correct, however when I run my program, the splash-screen is not displayed.

Can you please tell me, what I am doing wrong here?



program WinPosh;

uses
  Forms,
  Dialogs,
  SysUtils,
  filectrl,
  WP_MAINMENUE in 'WP_MAINMENUE.PAS' {frmMainMenu},
  WP_Setup in 'WP_SETUP.PAS' {frmWP_Setup},
  WP_global_module in 'WP_global_module.pas',
  WP_SplashScreen in 'WP_SplashScreen.pas' {frmWP_SplashScreen};

{$R *.RES}

begin
  Application.Initialize;
  Application.HelpFile := 'WINPOSH.HLP';
  Application.CreateForm(TfrmMainMenu, frmMainMenu);
  Application.CreateForm(TfrmWP_Setup, frmWP_Setup);
  Application.CreateForm(TfrmWP_SplashScreen, frmWP_SplashScreen);
  if (FileExists(ExtractFilePath(Application.ExeName) +
     'winposh.ini')=false) then  CreateIniFile;
  Application.Run
end.  

0
Comment
Question by:mathes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 9

Expert Comment

by:ginsonic
ID: 6974569
I think that you must add to splash form something alike:



procedure TfrmWP_SplashScreen.FormShow(Sender: TObject);
begin
  SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6974572
OR:

Application.Initialize;
{my suggestion}
Application.CreateForm(TfrmWP_SplashScreen, frmWP_SplashScreen);
frmWP_SplashScreen.Show;
frmWP_SplashScreen.Update;
{my suggestion}
Application.HelpFile := 'WINPOSH.HLP';
Application.CreateForm(TfrmMainMenu, frmMainMenu);
Application.CreateForm(TfrmWP_Setup, frmWP_Setup);
if (FileExists(ExtractFilePath(Application.ExeName) +
    'winposh.ini')=false) then  CreateIniFile;
{my suggestion}
frmWP_SplashScreen.Hide;
frmWP_SplashScreen.Free;
{my suggestion}
Application.Run


0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6974575
And don't forget to add to main form :

procedure TfrmMainMenu.FormCreate(Sender: TObject);
var
  CurrentTime: LongInt;
begin
  CurrentTime := GetTickCount div 1500;
  while ( (GetTickCount div 1500) < (CurrentTime + 4) ) do
    { nothing };
end;
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mathes
ID: 6974602
Dear gnsonic,

I used the following freeware code when I created my own splashscreen:

program Project1;

uses
  Forms,
  Windows,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {SplashScreen};

{$R *.RES}

begin
  SplashScreen := TSplashScreen.Create(Application);
  SplashScreen.Show;
  Application.Initialize;
  SplashScreen.Update;
  Sleep(1000); // Or a delay command.
  Application.CreateForm(TForm1, Form1);
  SplashScreen.Hide;
  SplashScreen.Free;
  Application.Run;
end.

(Source: www.SwissDelphiCenter.ch)

Do you think that this sample code can work?


0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6974612
i use this in one of my projects

program BP;

uses
  Forms,
  BP_u1 in 'BP_u1.pas' {Form1},
  BP_u3 in 'BP_u3.pas' {F_AG: TFrame},
  BP_u2 in 'BP_u2.pas' {F_PResource: TFrame},
  fr_prg_u in 'fr_prg_u.pas' {fr_prg: TFrame},
  fr_pr_u in 'fr_pr_u.pas' {fr_pr: TFrame},
  fr_prc_u in 'fr_prc_u.pas' {fr_prcal: TFrame},
  fr_agg_u in 'fr_agg_u.pas' {fr_agg: TFrame},
  fr_ag_u in 'fr_ag_u.pas' {fr_ag: TFrame},
  fr_fp_u in 'fr_fp_u.pas' {fr_agl: TFrame},
  fr_fpg_u in 'fr_fpg_u.pas' {fr_aglg: TFrame},
  BP_u4 in 'BP_u4.pas' {F_FP: TFrame},
  bp_progress_u in 'bp_progress_u.pas' {frmProgress},
  bp_Splash_u in 'bp_Splash_u.pas' {f_Splash},
  fr_ppl_u in 'fr_ppl_u.pas' {fr_ppl: TFrame},
  f_ppo_u in 'f_ppo_u.pas' {fr_ppo: TFrame},
  repBeleg1 in 'repBeleg1.pas' {qr_Beleg1: TQuickRep},
  repBeleg2 in 'repBeleg2.pas' {qrBeleg2: TQuickRep},
  uRepBBPO in 'uRepBBPO.pas' {RepBBPO: TQuickRep};

{$R *.RES}

begin
  Application.Initialize;
  f_Splash := tf_Splash.Create(Application);
  f_Splash.Show;
  f_Splash.BringToFront;
  Application.ProcessMessages;
  try
    Application.HelpFile := 'DruckAuftragHilfe.hlp';
    Application.Title := 'Vistaworks PPS';
    Application.CreateForm(TForm1, Form1);
    Application.CreateForm(TRepBBPO, RepBBPO);
  except
    Raise;
    Application.Terminate;
  end;
  f_Splash.Release;
  Application.Run;
end.

meikl ;-)
0
 
LVL 9

Accepted Solution

by:
ginsonic earned 400 total points
ID: 6974617
I think that Application.Initialize most be first .
Tested my code and work for me .
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6974706
That is my version:
  Application.Initialize;
  SplashScreen := TSplashScreen.Create(Application);
  SplashScreen.Show;
  SplashScreen.Refresh;
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;

and the splash screen form:
unit Splash;

interface

uses
  Windows, Forms, Graphics, Controls, Classes, ExtCtrls, jpeg, StdCtrls;

type
  TSplashScreen = class(TForm)
    Timer1: TTimer;
    Image1: TImage;
    procedure Timer1Timer(Sender: TObject);
    procedure Image1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
  public
  end;

var
  SplashScreen: TSplashScreen;
  SplashExists: Boolean = False;

implementation

{$R *.DFM}

uses
  JCLGraphics;

procedure TSplashScreen.Timer1Timer(Sender: TObject);
begin
  Close;
end;

procedure TSplashScreen.Image1Click(Sender: TObject);
begin
  Timer1.Free;
  Close;
end;

procedure TSplashScreen.FormCreate(Sender: TObject);
var
 HRegion: HRGN;
begin
  SplashExists := True;
  // from Jedi Code Library
  HRegion := CreateRegionFromBitmap(Image1.Picture.Bitmap, $FFFFFF, rmExclude);
  SetWindowRgn(Handle, HRegion, False);
end;

procedure TSplashScreen.FormDestroy(Sender: TObject);
begin
  SplashExists := False;
end;

end.

The refinement is that the splash screen destroys itself by a timer without slowin down app start.
It also closes on click which is something i want for all splash screens.

0
 

Author Comment

by:mathes
ID: 6974736

Hi experts,

thank you all for your feedback. I found out that all your suggestions work well in my demo sources.

Meikl: I would like to reward you with points, too.

Please post a dummy comment to my other question, and I will give you points, too.
0
 

Author Comment

by:mathes
ID: 6974740
Dear Robert,

your solution works very well too. I will ask a question especially to you. Pl4ease post a dummy comment and I will reward you with points, too.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question