Board index » cppbuilder » How to Hide the Main Form on Start of the application?

How to Hide the Main Form on Start of the application?


2004-12-14 06:52:29 AM
cppbuilder83
My program allows user to switch between a (main) form and a window using
SDL library. When then SDL-window is generated then I use Hide() to make
the main form invisible. If the user leaves the application in this state
I want the main form remains invisible on next start.
I use OnShow of the main form to initialize my program. So, the SDL-window
is generated if it was in use on previous exit. But unfortunately, I can't
use Hide() in OnShow routine :-(
1) Where can I run Hide() on next start?
2) If the form is hidden will OnShow still be triggered or I have to move
the initialization to somewhere else?
I couldn't run initialization in contructor because not all objects are
available at that time.
thanks in advance
Phuoc Can HUA
--
_/\__/\__/\__/\__/\__/\_
www.folksfun.com
 
 

Re:How to Hide the Main Form on Start of the application?

PC Hua <home-AT-huaonline.DOT.com>wrote:
Quote

[...] I couldn't run initialization in contructor because
not all objects are available at that time.
Show your code for the constructor an the OnShowEvent.
~ JD
 

Re:How to Hide the Main Form on Start of the application?

"PC Hua" <home-AT-huaonline.DOT.com>wrote in message
Quote
I use OnShow of the main form to initialize my program.
Why not the actual constructor instead? Initialization is why it exists in
the first place.
Quote
1) Where can I run Hide() on next start?
Start a program hidden
www.bcbdev.com/faqs/faq6.htm
Quote
I couldn't run initialization in contructor because not all objects are
available at that time.
Such as what? Which version of BCB are you using? In later versions, all
DFM-streamed components do exist before the constructor is called.
Gambit
 

{smallsort}

Re:How to Hide the Main Form on Start of the application?

Thank you for the link. I'm going to try it tonight.
I can't remember what was the exact reason I moved the initialization from
constructor to OnShow routine. I will try to move it back and see.
I'm using BCB5
On Mon, 13 Dec 2004 15:16:56 -0800, Remy Lebeau (TeamB)
< XXXX@XXXXX.COM >wrote:
Quote

"PC Hua" <home-AT-huaonline.DOT.com>wrote in message
news: XXXX@XXXXX.COM ...

>I use OnShow of the main form to initialize my program.

Why not the actual constructor instead? Initialization is why it exists
in
the first place.

>1) Where can I run Hide() on next start?

Start a program hidden
www.bcbdev.com/faqs/faq6.htm

>I couldn't run initialization in contructor because not all objects are
>available at that time.

Such as what? Which version of BCB are you using? In later versions,
all
DFM-streamed components do exist before the constructor is called.


Gambit


--
_/\__/\__/\__/\__/\__/\_
www.folksfun.com
 

Re:How to Hide the Main Form on Start of the application?

On Mon, 13 Dec 2004 15:16:56 -0800, Remy Lebeau (TeamB)
< XXXX@XXXXX.COM >wrote:
Quote
Start a program hidden
www.bcbdev.com/faqs/faq6.htm
The main form is invisible now, thanks.
I'm using ShowModal() in the OnShow routine of the main form to display a
splash screen. When main form is not visible the splash screen doesn't
come up. Where is the best place to call a splash screen?
Quote
Such as what? Which version of BCB are you using? In later versions,
all
DFM-streamed components do exist before the constructor is called.
Some initializations of my main form are depend on the states of other
(child) forms, e.g. buttons on the main form and also assigning some
registry information directly to variables in other forms. Of course
OnShow is set to NULL after first run. I know, it's very very messy :-)
It's time to clean up. But need some helps.
1) If I read registry information in constructor of the main form what's
the best way to pass it to an object in another form?
2) If I use a class ( MyDisplay) in the main form which will need to
access another form ( MyScreen) I will have something like this in the
initialization:
Display= new MyDisplay( MyScreen); // To allow Display to access MyScreen
This is one of the case where I have to do it when the form MyScreen is
available. Any other guggestion?
3) I also need access from a child form to the main form and I initialize
e.g. MyScreen->MyParent= this;
in the OnShow routine. It's messy :-) Can I do something via Sender
parameter in the child form constructor? or any better way?
Thank you for your time
Phuoc Can HUA
--
_/\__/\__/\__/\__/\__/\_
www.folksfun.com
 

Re:How to Hide the Main Form on Start of the application?

"PC Hua" <home-AT-huaonline.DOT.com>wrote in message
Quote
I'm using ShowModal() in the OnShow routine of the main form
to display a splash screen.
That is not a good place to handle a splash screen.
Quote
When main form is not visible the splash screen doesn't come up.
Of course not. The main form is hidden, so you will not get an OnShow event
triggered for it.
Quote
Where is the best place to call a splash screen?
In the project's WinMain() function directly. For example:
#include <splash.h>
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
TSplashForm *splash = new TSplashForm(Application);
splash->Show();
splash->Update();
Application->CreateForm(__Classid(TMainForm), &MainForm);
// other auto-created forms here as needed...
delete splash;
Application->Run();
}
catch(Exception &exception)
{
Application->HandleException(&exception);
}
return 0;
}
Quote
Some initializations of my main form are depend on the states of other
(child) forms
That sounds like a bad design to me. The child forms do not exist yet while
the main form is still initializating itself. What EXACT kind of
initializations are you doing?
Quote
buttons on the main form
The child forms should be responsible for updating the MainForm buttons when
needed. Not the other way around.
Quote
also assigning some registry information directly to variables in other
forms.
Why don't the forms handle their own values?
Quote
Of course OnShow is set to NULL after first run. I know, it's very very
messy :-)
Very.
Quote
1) If I read registry information in constructor of the main form
what's the best way to pass it to an object in another form?
The other forms don't exist yet at that time.
Why don't the forms read their own Registry values?
Quote
2) If I use a class ( MyDisplay) in the main form which will need to
access another form ( MyScreen) I will have something like this in the
initialization:
Display= new MyDisplay( MyScreen); // To allow Display to access MyScreen
If you intialize the Display in the main form's constructor, MyScreen will
not have been assigned yet.
Quote
This is one of the case where I have to do it when the form MyScreen
is available. Any other guggestion?
What EXACTLY is the main form using the Display class to do with the other
form?
Quote
3) I also need access from a child form to the main form
Just use the global Application->MainForm property for that.
Quote
I initialize
e.g. MyScreen->MyParent= this;
in the OnShow routine. It's messy :-)
Very. Is the child in question the actual MyScreen object?
Quote
Can I do something via Sender parameter in the child form constructor?
There is no Sender parameter in the constructor. I assume you mean the
Owner? Is the child form created manually or automatically? If
automatically, then the Owner is always the Application object itself.
Quote
or any better way?
It would be very helpful if you would provide more details about what
EXACTLY you are trying to accomplish will all of your forms. Your design
sounds very suspicious to me.
Gambit
 

Re:How to Hide the Main Form on Start of the application?

On Tue, 14 Dec 2004 15:48:59 -0800, Remy Lebeau (TeamB)
< XXXX@XXXXX.COM >wrote:
Quote
It would be very helpful if you would provide more details about what
EXACTLY you are trying to accomplish will all of your forms. Your design
sounds very suspicious to me.
You are absolutely right. It was problem solving on the fly :-) Now the
program is getting to big and complex. All those dirty solutions start
failing.
You have already given a lot of useful information and I'll use it to
clean up my program. It's great help, thanks a lot.
--
_/\__/\__/\__/\__/\__/\_
www.folksfun.com