| View previous topic :: View next topic |
| Author |
Message |
JD Guest
|
Posted: Fri Dec 19, 2003 2:36 pm Post subject: Re: Spash screen |
|
|
"Rodolfo Frino - Macrosoft" <Macrosoft (AT) Atlantis (DOT) com> wrote:
| Quote: | [...] If that is not suitable for your application, then
you'll have to use threads.
|
Umm. While I like you're solution (because the image is loaded
from the resource file), There is another alternative. Just
design the form in the IDE the way that you want it to look
and modify the project's cpp file:
//-------------------------------------------------------------
#include <vcl.h>
#include "SplashMod.h" // add this line
#pragma hdrstop
//-------------------------------------------------------------
USEFORM("MainMod.cpp", Main);
USEFORM("SplashMod.cpp", Splash);
//-------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
// add next 3 lines
Splash = new TSplash(Application);
Splash->Show();
Splash->Update();
Application->Initialize();
Application->CreateForm(__classid(TMain), &Main);
// remove the following line
Application->CreateForm(__classid(TSplash), &Splash);
// add next 2 lines
Splash->Hide();
Splash->Close();
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//-------------------------------------------------------------
~ JD
|
|
| Back to top |
|
 |
chris Guest
|
Posted: Fri Dec 19, 2003 2:59 pm Post subject: Spash screen |
|
|
My question is quite simple but I do not manage to do a correct thing
(dispaly after the loading, flicking behavior, ...).
I do not find help on the internet so here I am:
How to display a spash screen while the application is loading?
--
chris
|
|
| Back to top |
|
 |
Rodolfo Frino - Macrosoft Guest
|
Posted: Fri Dec 19, 2003 3:03 pm Post subject: Re: Spash screen |
|
|
Have a look at this article
http://www.geocities.com/rodolfofrino/SplashScreen.html
If that is not suitable for your application, then you'll have to use
threads.
"Should you have bright ideas in your dreams, then make your dreams come
true". Rodolfo, 2003
"chris" <blin_c (AT) epita (DOT) fr> wrote
| Quote: | My question is quite simple but I do not manage to do a correct thing
(dispaly after the loading, flicking behavior, ...).
I do not find help on the internet so here I am:
How to display a spash screen while the application is loading?
--
chris
|
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Sat Dec 20, 2003 12:24 pm Post subject: Re: Spash screen |
|
|
"Rodolfo Frino - Macrosoft" <Macrosoft (AT) Atlantis (DOT) com> wrote:
| Quote: | You could also use this method:
|
Which just became my preferred method. It's a tad more work but
but I'm all for reducing my application's footprint in every
way possible and this is one way to do it. Every little bit
helps!!
~ JD
|
|
| Back to top |
|
 |
Rodolfo Frino - Macrosoft Guest
|
Posted: Sat Dec 20, 2003 12:45 pm Post subject: Re: Spash screen |
|
|
Absolutely, that's a good solution too.
Rodolfo
"JD" <nospam (AT) nospam (DOT) com> wrote
| Quote: |
"Rodolfo Frino - Macrosoft" <Macrosoft (AT) Atlantis (DOT) com> wrote:
[...] If that is not suitable for your application, then
you'll have to use threads.
Umm. While I like you're solution (because the image is loaded
from the resource file), There is another alternative. Just
design the form in the IDE the way that you want it to look
and modify the project's cpp file:
//-------------------------------------------------------------
#include <vcl.h
#include "SplashMod.h" // add this line
#pragma hdrstop
//-------------------------------------------------------------
USEFORM("MainMod.cpp", Main);
USEFORM("SplashMod.cpp", Splash);
//-------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
// add next 3 lines
Splash = new TSplash(Application);
Splash->Show();
Splash->Update();
Application->Initialize();
Application->CreateForm(__classid(TMain), &Main);
// remove the following line
Application->CreateForm(__classid(TSplash), &Splash);
// add next 2 lines
Splash->Hide();
Splash->Close();
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//-------------------------------------------------------------
~ JD
|
|
|
| Back to top |
|
 |
Rodolfo Frino - Macrosoft Guest
|
Posted: Sat Dec 20, 2003 1:03 pm Post subject: Re: Spash screen |
|
|
You could also use this method:
#include <vcl.h>
USEUNIT("Splash.cpp");
USEFORM("Unit1.cpp", Form1);
//--------------------------------------------------------------------------
-
#pragma hdrstop
USERES("ProjSplashScreen.res");
USEFORM("Unit1.cpp", Form1);
#include "Splash.h"
//--------------------------------------------------------------------------
-
void Init()
{
// DWORD t1 = GetTickCount(); //TEST
// First call the Initialize method of the application
Application->Initialize();
// Create a Splash Screen Form
TSplash_Form* pSplash = new TSplash_Form(Application->Owner, bsNone,
SPLASH_SCREEN_WIDTH,
SPLASH_SCREEN_HEIGHT,
poScreenCenter,
true, true);
TImage* Image1 = new TImage(pSplash);
Image1->Parent = pSplash;
Image1->Width = SPLASH_SCREEN_WIDTH;
Image1->Height = SPLASH_SCREEN_HEIGHT;
// With The Stretch property it takes more time to display the
// image on the splash form.
Image1->Stretch = true;
try
{
// Load the Splash Screen Bitmap from file
Image1->Picture->LoadFromFile("C:\Graphics\BMP\Kylie.bmp");
pSplash->Update();
}
catch (...)
{
MessageBeep(0);
}
// DWORD t2 = GetTickCount(); // TEST
// ShowMessage(String(t2 - t1)); // TEST
// Show the Splash Screen for 3 seconds and then destroy the
// Splash object
Sleep(3000);
delete pSplash;
pSplash = NULL;
}
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Init();
Application->CreateForm(__classid(TForm1), &Form1);
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
Rodolfo
|
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Sat Dec 20, 2003 4:26 pm Post subject: Re: Spash screen |
|
|
I'v spent a lot of time with spalsh screens. I prefer the effect
like TextPad:
1) Splash screen appears.
2) Main form appears
3) Splash screen stays active for a while
4) Splash screen closes.
Just a timer is included to secure closing of splash screen after some time.
Vladimir.
|
|
| Back to top |
|
 |
Tomasz Piasecki Guest
|
Posted: Sat Dec 20, 2003 4:28 pm Post subject: Re: Spash screen |
|
|
Vladimir Stefanovic wrote:
| Quote: | 1) Splash screen appears.
2) Main form appears
3) Splash screen stays active for a while
4) Splash screen closes.
If I was the user of your application I'd hate this. I hate |
splash-screens staying visible when main application appears.
TP.
--
| Quote: | _ _ _ |
_____ _| |_| | __ (o) | | __ __ @poczta.onet.pl |
| | | |o | | |/o |/ _| |
|_|_|_| _| |__/|_| |_|__|__||_| Tomasz Piasecki |
|
|
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Sat Dec 20, 2003 7:13 pm Post subject: Re: Spash screen |
|
|
| Quote: | If I was the user of your application I'd hate this. I hate
splash-screens staying visible when main application appears.
So I included in Options |
[x] Show splash screen at program startup
:)
|
|
| Back to top |
|
 |
chris Guest
|
Posted: Mon Dec 22, 2003 10:18 am Post subject: Re: Spash screen |
|
|
"Rodolfo Frino - Macrosoft" <Macrosoft (AT) Atlantis (DOT) com> a écrit dans le message
de news: [email]3fe31333 (AT) newsgroups (DOT) borland.com[/email]...
This article is just what I need for beginning, thanks.
| Quote: | If that is not suitable for your application, then you'll have to use
threads.
|
that is my case because I want the spash screen must be displayed only while
the application is loading the dynamic libraires I use, included the VCL.
I want for example a splash screen like the BCB one (with no gray bitmap
when passing a window over it).
Many thanks again.
--
chris
|
|
| Back to top |
|
 |
Lynn Morrison Guest
|
Posted: Tue Dec 23, 2003 12:41 pm Post subject: Re: Spash screen |
|
|
Ouch, you are using the Application object before you have even initialized
it.... that will certainly be undefined behaviour... ;)
Lynn
"JD" <nospam (AT) nospam (DOT) com> wrote
| Quote: |
"Rodolfo Frino - Macrosoft" <Macrosoft (AT) Atlantis (DOT) com> wrote:
[...] If that is not suitable for your application, then
you'll have to use threads.
Umm. While I like you're solution (because the image is loaded
from the resource file), There is another alternative. Just
design the form in the IDE the way that you want it to look
and modify the project's cpp file:
//-------------------------------------------------------------
#include <vcl.h
#include "SplashMod.h" // add this line
#pragma hdrstop
//-------------------------------------------------------------
USEFORM("MainMod.cpp", Main);
USEFORM("SplashMod.cpp", Splash);
//-------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
// add next 3 lines
Splash = new TSplash(Application);
Splash->Show();
Splash->Update();
Application->Initialize();
Application->CreateForm(__classid(TMain), &Main);
// remove the following line
Application->CreateForm(__classid(TSplash), &Splash);
// add next 2 lines
Splash->Hide();
Splash->Close();
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//-------------------------------------------------------------
~ JD
|
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Tue Dec 23, 2003 4:02 pm Post subject: Re: Spash screen |
|
|
"Lynn Morrison" <Cranky (AT) __whisp (DOT) com> wrote:
| Quote: | Ouch, you are using the Application object before you have even initialized
it.... that will certainly be undefined behaviour...
|
I hadn't considered that but it's cut directly from one of the
sample applications ...ExamplesDBTasksMastApp.
Gambit? Any comments?
~ JD
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Tue Dec 23, 2003 6:34 pm Post subject: Gambit? |
|
|
"JD" <nospam (AT) nospam (DOT) com> wrote:
| Quote: |
"Lynn Morrison" <Cranky (AT) __whisp (DOT) com> wrote:
Ouch, you are using the Application object before you have even initialized
it.... that will certainly be undefined behaviour... ;)
I hadn't considered that but it's cut directly from one of the
sample applications ...ExamplesDBTasksMastApp.
Gambit? Any comments?
~ JD
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Dec 23, 2003 7:38 pm Post subject: Re: Spash screen |
|
|
"Lynn Morrison" <Cranky (AT) __whisp (DOT) com> wrote
| Quote: | Ouch, you are using the Application object before
you have even initialized it....
|
The global TApplication object has already been created and intialized
before WinMain() is even called. Do not be confused with the call to the
Initialize() method, it does not do what you think it does, and in fact in
normal GUI apps it does not do anyhing at all.
Gambit
|
|
| Back to top |
|
 |
|