SPLASH


Document :: Creating a Start Up Splash Screen
Author :: Jon Jenkinson
From "The Bits" Website
http://www.cbuilder.dthomas.co.uk
emails to : jon.jenkinson@mcmail.com
Legal Stuff
This document is Copyright ©Jon Jenkinson December 1997
You may redistribute this file FREE OF CHARGE providing you do not charge receprients
anything for the process of redistribution or the document itself. If you wish to use this
docuement for educational purposes you may do so free of charge. However, If you wish to use
all or part of this document for commercial training or commercial publication you must contact
the author as charges may apply. You may not receive **any** monies for this document without
the prior consent of the author.
No liability is accepted by the author(s) for anything which may occure whilst following
this tutorial
Creating A Start Up Splash Screen.
This document is designed as a tutorial treating a single issue, the creation of a splash screen.
The intention is to provide information on the creation of applications with the Profesionals touch.
I give two methods below, one based on a response from an employee at Borland called jeffc ?
The second is an enhancement of my own code to provide for those wishing to produce
shareware style start up and exit screens.
This document assumes you have access to Borland's C++ Builder running on Windows95. (The
principals should also work when applied to both Delphi and WindowsNT.)
There is no source code to accompany this document, simply follow the instructions and you'll
create your own.
(Notes:: Comments given in this colour are important things to understand about how BCB
works.)
Underlying Principals.
C++ Builder creates applications using forms. These forms, (windows), behave in manner
which at first can seem a little confusing. The first thing to realise is that your initial form, (by
default called Form1), is NOT the main application Window.
The main application window is in fact invisible, and at this level, unaccesable. We will show
this during this tutorial, when we mimize Form1 internally and it is deposited to the desktop, not
the Win95 Taskbar.
(Note: If you minimize a running application, you minimize to the Taskbar, as you actually
minimize the Invisible main application window. If you minimize a Form manually within the
application, i.e. Form2->WindowState = wsMinimized, it will display on the desktop, that is the
within the invisible main application window.)
Method One :: A True Splash Screen
Step One : Creating The Application
(a) Create a new application using File|New Application.
(b) Choose File|Save Project As... and save your project to an independant location
(e.g. C:\my projects\splash example one\)
(1) Save the unit1.cpp file as MainFormSource.cpp, (automatically renames
headers etc)
(2) Save the project.cpp file as SplashExample.cpp.
(c) Rename the form on display from Form1 to "MainForm"
(In the Object Inspector dialog, select Form1:TForm1, scroll down to the name property
and change it to "MainForm". )
(You will notice that the Object Inspector changes to display MainForm:TMainForm,
don't worry this is intentional and we shall make use of this later. You will also notice
that the form itself now has the caption MainForm within its caption area.)
(d) Choose File|Save.
Step Two :Creating the splash screen itself
(a) Create a new Form using File|New Form
(b) Rename this form to Splash in the same way as we renamed the MainForm.
(c) Again notice that the Object Inspector changes from Form2:TForm to display
Splash:TSpalsh.
(d) Save the project with File|Save.
(1) When prompted to save Unit1.cpp call it SplashSource.cpp
(e) Now we'll create the splash screen.
(1) In the Object Inspector choose +BorderIcons. Double Click in the left columns
(2) You'll see four options, turn them all to false, (BorderIcons []).
(3) Change BorderStyle = bsNone
(4) Change FormStyle = fsStayOnTop
(5) Change Position = poScreenCenter
(f) Drop a panel onto the form, (Panel1) Set the properties of the panel as follows
(1) Align = alClient
(2) BevelInner = bvLowered
(3) BevelOuter = bvLowered
(4) Bevelwidth = 2
(g) Drop a TImage inside the panel, (TImage1), setting the properties as follows
(1) Align = alClient
(2) Stretch = true
(3) Load a BMP picture (doesn't matter which one)
(Double click in the TImage on the form)
Step Three :Display the Splash Screen
(a) Minimize the forms, so you're left with the code editor.
(b) Double click the MainForm:OnShow in the events pane of the Object Inspector
(c) type in the following code,
if(Splash)
{ // check to see if the pointer is valid
delete Splash; //Delete the splash form
Splash = NULL ; //set the pointer so we don't do this again
}
(d) Bring up the projects source
View|Project Source, you should see the following (bits in Black!)
(e) Add the code coloured red.
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Splash = new TSplash(static_cast(NULL)); //no owner
Splash->Show();
Application->ProcessMessages(); // this is necessary to show the Splash now
Application->CreateForm(__classid(TMainForm), &MainForm);
//
// We don't wish to auto create
// Application->CreateForm(__classid(TSplash),&Splash);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
(f) Add the header file "SplashSource.h" to SplashExample.cpp and MainFormSource.cpp
Step Four : Run the application
(a) "Golly that was quick, the splash flashed and then disappeared again !!!"
Correct, the application does nothing, so it takes no time to create and display the MainForm
form.
(b) Add a timed delay. (This is optional, as your applications grow and take longer to initialise,
you can remove this timer.)
(1) include dos.h
(2) Within the MainForm::OnCreate function add the following
if(Splash)
{
sleep(5);
}
(c) Run and smile :)


Wyszukiwarka

Podobne podstrony:
SplashScreen
Suzuki Splash ActivePlus DE 14
SplashingGoodTime
es ES Splash
ko KR Splash
Splash
splash1shot
nl NL Splash
nl NL Splash
Plusk (Splash) 1984
splash

więcej podobnych podstron