BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

splahs screen
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
Bono
Guest





PostPosted: Thu Mar 09, 2006 6:03 pm    Post subject: splahs screen Reply with quote



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





PostPosted: Thu Mar 09, 2006 7:03 pm    Post subject: Re: splahs screen Reply with quote



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





PostPosted: Thu Mar 09, 2006 7:03 pm    Post subject: Re: splahs screen Reply with quote



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





PostPosted: Thu Mar 09, 2006 9:03 pm    Post subject: Re: splahs screen Reply with quote

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





PostPosted: Thu Mar 09, 2006 9:03 pm    Post subject: Re: splahs screen Reply with quote

Bono wrote:
Quote:
I 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





PostPosted: Thu Mar 09, 2006 9:03 pm    Post subject: Re: splahs screen Reply with quote

"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





PostPosted: Sat Mar 11, 2006 3:03 pm    Post subject: Re: splahs screen Reply with quote

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





PostPosted: Mon Mar 13, 2006 9:03 am    Post subject: Re: splahs screen Reply with quote

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





PostPosted: Sat Mar 25, 2006 5:03 pm    Post subject: Re: splahs screen Reply with quote

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





PostPosted: Sat Mar 25, 2006 7:03 pm    Post subject: Re: splahs screen Reply with quote

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





PostPosted: Sat Mar 25, 2006 8:03 pm    Post subject: Re: splahs screen Reply with quote

Don't forget to set Visible of the splashform to false during designtime.

Hans.
Back to top
Hans Galema
Guest





PostPosted: Sat Mar 25, 2006 8:03 pm    Post subject: Re: splahs screen Reply with quote

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





PostPosted: Sun Mar 26, 2006 10:03 pm    Post subject: Re: splahs screen Reply with quote

"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





PostPosted: Thu Mar 30, 2006 5:03 pm    Post subject: Re: splahs screen Reply with quote

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





PostPosted: Thu Mar 30, 2006 6:03 pm    Post subject: Re: splahs screen Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.