| View previous topic :: View next topic |
| Author |
Message |
Bono Guest
|
Posted: Thu Mar 09, 2006 6:03 pm Post subject: splahs screen |
|
|
Hi everybody!!
I'm attempting to create a SplashScreen for my app.
I created a corma nd placed an image. That's enough for me. Now I want to
display it as the first form... then wait a couple of seconds (Sleep(2000)
works fine!).. and then unload this form and show the main MDI form.
I hope someone can give me some idea.
Thanks!!
Andrea |
|
| Back to top |
|
 |
Bono Guest
|
Posted: Thu Mar 09, 2006 7:03 pm Post subject: Re: splahs screen |
|
|
I wrote:
frmSplash = new TfrmSplash(Application);
frmSplash->Show();
Sleep (2000);
delete frmSplash;
But I get an error: cannot convert 'TApplication *' to 'TfrmSplash'.
Th constructor of TfrmSplash is:
__fastcall TfrmSplash::TfrmSplash(TComponent* Owner): TForm(Owner)
{
....
}
"Hans Galema" <notused (AT) notused (DOT) nl> ha scritto nel messaggio
news:44106b3b$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Bono wrote:
I'm attempting to create a SplashScreen for my app.
I created a corma nd placed an image. That's enough for me. Now I want
to
display it as the first form... then wait a couple of seconds
(Sleep(2000)
works fine!).. and then unload this form and show the main MDI form.
I hope someone can give me some idea.
Add some code to the WinMain function of your project.
If Tform2 is your splashform then something like this:
#include "Unit2.h"
//-------------------------------------------------------------------------- |
-
| Quote: | WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
// start of added code
Form2 = new TForm2(Application );
Form2->Show();
Sleep (2000);
delete Form2;
// end of added code
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
Hans. |
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Thu Mar 09, 2006 7:03 pm Post subject: Re: splahs screen |
|
|
Bono wrote:
| Quote: | I'm attempting to create a SplashScreen for my app.
I created a corma nd placed an image. That's enough for me. Now I want to
display it as the first form... then wait a couple of seconds (Sleep(2000)
works fine!).. and then unload this form and show the main MDI form.
I hope someone can give me some idea.
|
Add some code to the WinMain function of your project.
If Tform2 is your splashform then something like this:
#include "Unit2.h"
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
// start of added code
Form2 = new TForm2(Application );
Form2->Show();
Sleep (2000);
delete Form2;
// end of added code
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
Hans. |
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Thu Mar 09, 2006 9:03 pm Post subject: Re: splahs screen |
|
|
| Quote: | But I get an error: cannot convert 'TApplication *' to 'TfrmSplash'.
|
Then try /untested/:
Instead of:
| Quote: | frmSplash = new TfrmSplash(Application);
|
Use:
frmSplash = new TfrmSplash( static_cast<void *>(NULL) );
or just this (if the compiler can swallow that, I'm not sure):
frmSplash = new TfrmSplash( NULL );
--
Best Regards,
Vladimir Stefanovic |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Thu Mar 09, 2006 9:03 pm Post subject: Re: splahs screen |
|
|
Bono wrote:
Please trim your quotes.
| Quote: | frmSplash = new TfrmSplash(Application);
But I get an error: cannot convert 'TApplication *' to 'TfrmSplash'.
Th constructor of TfrmSplash is:
__fastcall TfrmSplash::TfrmSplash(TComponent* Owner): TForm(Owner)
|
There is no reason for such an error message. What is going on more ?
Hans. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Mar 09, 2006 9:03 pm Post subject: Re: splahs screen |
|
|
"Bono" <bono (AT) ingv (DOT) it> wrote in message
news:44106e6c$1 (AT) newsgroups (DOT) borland.com...
| Quote: | But I get an error: cannot convert 'TApplication *' to 'TfrmSplash'.
|
Did you #include TfrmSplash's header file so that WinMain() knows what the
constructor actually looks like?
Did you declare 'frmSplash' as a pointer? The error message suggests that
you did not.
Gambit |
|
| Back to top |
|
 |
Pete Guest
|
Posted: Sat Mar 11, 2006 3:03 pm Post subject: Re: splahs screen |
|
|
| Quote: | But I get an error: cannot convert 'TApplication *' to 'TfrmSplash'.
|
It looks like your 'TfrmSplash' is not declared as a pointer. Note the
compiler complains it cannot convert the TApplication pointer to
'TfrmSplash' instead of to 'TfrmSplash *'
-- P |
|
| Back to top |
|
 |
Bono Guest
|
Posted: Mon Mar 13, 2006 9:03 am Post subject: Re: splahs screen |
|
|
| Quote: |
Did you #include TfrmSplash's header file so that WinMain() knows what the
constructor actually looks like?
|
Oooooooooops... Thanks a lot!! Now it's working fine!! |
|
| Back to top |
|
 |
Peter Guest
|
Posted: Sat Mar 25, 2006 5:03 pm Post subject: Re: splahs screen |
|
|
Thanks for the Q and A, I'm using this information as well.
I created a small form (borderstyle bsNone) with a TImage on it (AlClient
aligned) and loaded a small jpg file during design time.
What I'm seeing is that first a blank form is shown and next the real image
inside.
So there is a small delay in painting the image (I suppose ?).
Any idea how I can avoid this delay ?
E.g. can I do something before I call ->Show() for instance ?
Q2. the image is loaded at design time, so I can be sure it's in the exe's
resources ... right ?
I removed the image as a test and all appeared to work normally, but just
making sure. |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Sat Mar 25, 2006 7:03 pm Post subject: Re: splahs screen |
|
|
Peter wrote:
| Quote: | What I'm seeing is that first a blank form is shown and next the real image
inside.
|
Hmm. I do never see the image.
But. Put a TTimer on your splashform. Enabled true. Interval 2000;
In the TTimer eventhandler:
void __fastcall TForm2::Timer1Timer(TObject *Sender)
{
ModalResult = mrOk;
}
Instead of
Form->show();
Sleep(2000);
use only;
Form->ShowModal();
Hans. |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Sat Mar 25, 2006 8:03 pm Post subject: Re: splahs screen |
|
|
Don't forget to set Visible of the splashform to false during designtime.
Hans. |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Sat Mar 25, 2006 8:03 pm Post subject: Re: splahs screen |
|
|
Hans Galema wrote:
Alternative if you want the splaschform visible together with the mailform:
Make WindowStyle of the splashform fsStayOnTop.
| Quote: | Put a TTimer on your splashform. Enabled true. Interval 2000;
In the TTimer eventhandler:
|
void __fastcall TForm2::Timer1Timer(TObject *Sender)
{
Close();
}
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
Action = caFree;
}
| Quote: | Instead of
Form->show();
Sleep(2000);
delete Form;
|
use only:
Form->Show();
Hans. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sun Mar 26, 2006 10:03 pm Post subject: Re: splahs screen |
|
|
"Peter" <Will_Bounce_So_Use_My_First_Name@Smart-Projects.net> wrote in
message news:44257195 (AT) newsgroups (DOT) borland.com...
| Quote: | What I'm seeing is that first a blank form is shown and next
the real image inside. So there is a small delay in painting the
image (I suppose ?). Any idea how I can avoid this delay ?
E.g. can I do something before I call ->Show() for instance ?
|
Make sure that you are calling Update() immediately after Show(), ie:
SplashForm = new TSplashForm(Application);
SplashForm->Show();
SplashForm->Update(); // <-- here
// do something ...
delete SplashForm;
| Quote: | the image is loaded at design time, so I can be sure it's in the
exe's resources ... right ?
|
It is stored as a binary stream embedded inside of the TForm's DFM resource.
The image is not its own resource.
Gambit |
|
| Back to top |
|
 |
Peter Guest
|
Posted: Thu Mar 30, 2006 5:03 pm Post subject: Re: splahs screen |
|
|
I solved it by calling
Application->ProcessMessages();
right after SplashForm->Show();
Maybe it's better to call ->Update() ? (not tested) |
|
| Back to top |
|
 |
Peter Guest
|
Posted: Thu Mar 30, 2006 6:03 pm Post subject: Re: splahs screen |
|
|
| Quote: | Don't forget to set Visible of the splashform to false during designtime.
|
Ah ...
I don't think I do that (have to check)
maybe that had an impact as well. |
|
| Back to top |
|
 |
|