| View previous topic :: View next topic |
| Author |
Message |
Olives Guest
|
Posted: Wed Mar 28, 2007 2:19 pm Post subject: What Event should I add my code for loading? |
|
|
I have a program that load a bunch of settings when it loads so I wanted to
created a basic loading... message with a TPanel that I just change the
visible property as needed.
The problem is I'm not sure the event I should add my code for. When I place
the code in the OnShow I don't see my loading message.
Thanks |
|
| Back to top |
|
 |
Thorsten Kettner Guest
|
Posted: Wed Mar 28, 2007 7:01 pm Post subject: Re: What Event should I add my code for loading? |
|
|
"Olives" <junkmail78 (AT) charter (DOT) net> wrote:
| Quote: | When I place the code in the OnShow I don't see my loading
message.
|
OnShow happens immediately _before_ the form gets shown. There
are two ways to solve that: Either post a user defined msg in OnShow and write code to react on that msg or display your
loading message in OnActivate. The second approach is easier:
void __fastcall TFormMain::FormActivate(TObject *Sender)
{
static bool FirstTime = true;
if(FirstTime)
{
FirstTime = false;
...
}
} |
|
| Back to top |
|
 |
Olives Guest
|
Posted: Thu Mar 29, 2007 8:10 am Post subject: Re: What Event should I add my code for loading? |
|
|
I used the FormActivate but it doesn't seem to be working.
I placed a ShowMessage() and it gets executed before the form shows up.
void __fastcall TMain::FormActivate(TObject *Sender)
{
ShowMessage("Do you see the form?"); // No Form at this point
// Show load message
LoadListPnl->Visible = true;
LoadListPnl->Refresh();
// Change Cursor to hourglass
OldCursor = Screen->Cursor;
Screen->Cursor = crHourGlass;
// Call load programs
static bool Load_Started = false;
if(! Load_Started) {
Load_Started = true;
GetProgramList(ListView);
}
// Change Cursor to normal
Screen->Cursor = OldCursor;
// Hide load message
LoadListPnl->Visible = false;
}
"Thorsten Kettner" <ANSWERBYthorsten.kettner (AT) otto (DOT) de> wrote in message
news:460a6739$1 (AT) newsgroups (DOT) borland.com...
| Quote: | OnShow happens immediately _before_ the form gets shown. There
are two ways to solve that: Either post a user defined msg in OnShow and
write code to react on that msg or display your
loading message in OnActivate. The second approach is easier:
void __fastcall TFormMain::FormActivate(TObject *Sender)
{
static bool FirstTime = true;
if(FirstTime)
{
FirstTime = false;
...
}
} |
|
|
| Back to top |
|
 |
Thorsten Kettner Guest
|
Posted: Thu Mar 29, 2007 8:10 am Post subject: Re: What Event should I add my code for loading? |
|
|
"Olives" <junkmail78 (AT) charter (DOT) net> wrote:
| Quote: | I used the FormActivate but it doesn't seem to be working.
I placed a ShowMessage() and it gets executed before the form shows up.
void __fastcall TMain::FormActivate(TObject *Sender)
{
ShowMessage("Do you see the form?"); // No Form at this point
|
Sorry, I have no idea why this isn't working for you. It works
for me for the main form and any secondary form and has always
worked that way. OnActivate should be fired when the form is
visible and gets activated. |
|
| Back to top |
|
 |
Olives Guest
|
Posted: Thu Mar 29, 2007 1:37 pm Post subject: Re: What Event should I add my code for loading? |
|
|
If I place the code into a TTimer and set the Interval to 1 and disable the
TTimer when it's executed the first time my load message
works, but it feels kind of cheesy.
"Thorsten Kettner" <ANSWERBYthorsten.kettner (AT) otto (DOT) de> wrote in message
news:460b6446$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Sorry, I have no idea why this isn't working for you. It works
for me for the main form and any secondary form and has always
worked that way. OnActivate should be fired when the form is
visible and gets activated. |
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Thu Mar 29, 2007 8:09 pm Post subject: Re: What Event should I add my code for loading? |
|
|
Olives wrote:
| Quote: | If I place the code into a TTimer and set the Interval to 1 and disable
the TTimer when it's executed the first time my load message
works, but it feels kind of cheesy.
|
It is an elegant solution.
If OnActivate is not usable for you then try the OnPaint event.
The OnPaint of the form will be there only if your form is not covered up
with controls.
Hans. |
|
| Back to top |
|
 |
JD Guest
|
Posted: Fri Mar 30, 2007 2:24 am Post subject: Re: What Event should I add my code for loading? |
|
|
"Olives" <junkmail78 (AT) charter (DOT) net> wrote:
| Quote: |
[...] works, but it feels kind of cheesy.
|
Thorsten suggested that you use the Win32 API PostMessage in
the form's constructor. Since the TTimer is message based,
you've accomplished the same without defining a custom message
and it's handler.
~ JD |
|
| Back to top |
|
 |
Olives Guest
|
Posted: Fri Mar 30, 2007 3:39 pm Post subject: Re: What Event should I add my code for loading? |
|
|
Well I guess the solution wasn't as bad as I thought I was just expecting a
form event I could use instead.
I tried using the form's OnPaint event and that seems to work too.
Thanks for all your input guys :)
"Hans Galema" <notused (AT) notused (DOT) nl> wrote in message
news:460bd78c$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Olives wrote:
If I place the code into a TTimer and set the Interval to 1 and disable
the TTimer when it's executed the first time my load message
works, but it feels kind of cheesy.
It is an elegant solution.
If OnActivate is not usable for you then try the OnPaint event.
The OnPaint of the form will be there only if your form is not covered up
with controls.
Hans. |
|
|
| Back to top |
|
 |
DreamChaser Guest
|
Posted: Wed Apr 04, 2007 5:34 am Post subject: Re: What Event should I add my code for loading? |
|
|
Olives wrote:
| Quote: | I have a program that load a bunch of settings when it loads so I wanted
to created a basic loading... message with a TPanel that I just change
the visible property as needed.
The problem is I'm not sure the event I should add my code for. When I
place the code in the OnShow I don't see my loading message.
Thanks
Another way: |
Create a form (A flash screen) that displays the messages about the
status of the loading of your program. display it from the project
source file. I would take it out of the auto create section of the
project options, and manually create, show, and delete it.
I believe that their was a really good example that I have used in the
past in Howard Howe's (sp) great book, "BCB - How To:"
DC |
|
| Back to top |
|
 |
Bruce Salzman Guest
|
Posted: Wed Apr 04, 2007 7:12 am Post subject: Re: What Event should I add my code for loading? |
|
|
"DreamChaser" <NO-Spam@No-Span.net> wrote in message
news:4612f27b$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Another way:
Create a form (A flash screen) that displays the messages about the
status of the loading of your program. display it from the project
source file. I would take it out of the auto create section of the
project options, and manually create, show, and delete it.
I believe that their was a really good example that I have used in
the past in Howard Howe's (sp) great book, "BCB - How To:"
|
Ah, yes. Who could forget Howard.
--
Bruce |
|
| Back to top |
|
 |
|