Anybody else think
Zarco Gajic is an idget sometimes?
No seriously, I AM KIDDING. However, after looking at his
how to create a splash screen in Delphi code, I realized to really make a cool splash screen in Delphi... something else would be needed.
This article will accomplish three things.
1. It will provide you code on how to
prevent your application from running more than one instance.
2. It will create a
splash screen that will show during your applications start up.
3. It will
animate into view (fade) the splash screen. This effect although simple really adds "Splash" to your
Delphi splash screen.
To Begin »First those of you who are unfamiliar with how to view the source of your .EXE or Delphi project file simply right click in the Delphi project manager on the .exe and select view source.
That will open up the project source id the IDE editor window. Take a look at how your current source is laid out. It will appear similar to that below. Below is the full source code you will need to create the three effects outlined above.
You'll obviously need to create a new form and name it FrmSplash. Remove it from the available forms section via Projects » Options » Forms.
You'' also need to add "Windows", "Dialogs" & "Forms" if not present in the source's USES clause. Follow the code and it will dress up your Delphi application in a nice way.
-------------------------------------------------------------------------------------
program xyz;
uses
Windows,
Forms,
Dialogs,
MdiUnit in 'MdiUnit.pas' {FrmMain},
{$R *.res}
var
MyProgramNameMutex: Thandle;
I : Integer;
begin
MyProgramNameMutex:=CreateMutex(nil, False, 'MyProgramNameMutex');
if WaitForSingleObject (MyProgramNameMutex, 0) <> Wait_TimeOut then
begin
Application.Initialize;
Application.Title := 'My Program Name';
//Create Splash Screen
with TFrmSplash.Create(nil) do
try
Show;
Update;
// AnimateWindow(Handle, 1000, AW_HIDE Or AW_BLEND); Lame Code that don't work!~
for I := 0 to 255 do begin
AlphaBlendValue := I;
Sleep(10);
Application.ProcessMessages;
end;
Application.CreateForm(TFrmMain, FrmMain);
finally
Free;
end;
Application.Run;
end
else begin
MessageDlg(Application.Title+' is already running!!!', mterror, [mbok], 0);
Application.BringToFront;
Application.RestoreTopMosts;
end;
end.
-------------------------------------------------------------------------------------