Board index » cppbuilder » Methods of showing a form

Methods of showing a form


2003-11-06 11:28:09 AM
cppbuilder103
What other methods are there when it comes to showing a
form to the user that is in front of your main form. Simply
because you don't want the user to interact with the main form.
When i do a Form2->Show(), i can still click on the main form
and do other things. I can't do a ShowModal(), that simply will
not work. I need to display a form with progress and update
info until the processing is complete. Is there any other way of
displaying a form like that? I want absolutely no interaction on the
main form while the program is processing.
Thanks.
 
 

Re:Methods of showing a form

"Greg Stantin" < XXXX@XXXXX.COM >wrote:
Quote
What other methods are there when it comes to showing a
form to the user that is in front of your main form. Simply
because you don't want the user to interact with the main form.
When i do a Form2->Show(), i can still click on the main form
and do other things. I can't do a ShowModal(), that simply
will not work. I need to display a form with progress and
update info until the processing is complete. Is there any
other way of displaying a form like that? I want absolutely
no interaction on the main form while the program is
processing.
You can use Form2->Show() and set Form1->Enabled = false in
TForm2::OnShow and Form1->Enabled = true in TForm2::OnHide. You
might also want to consider to use a TThread to do parallel
processing in the two windows.
 

Re:Methods of showing a form

"Greg Stantin" < XXXX@XXXXX.COM >wrote:
Quote
[...] I can't do a ShowModal(), that simply will not work.
Why not?
Quote
I want absolutely no interaction on the main form while the
program is processing.
ShowModal is well suited for this purpose.
~ JD
 

{smallsort}

Re:Methods of showing a form

So you are saying that i can use the ShowModal() and do my updating
on the window and show the progressbars etc. I dont think that will
work, simply because when you do a ShowModal(), your program
freezes on that line of code (ShowModal()) until you close the form.
Quote
ShowModal is well suited for this purpose.

~ JD

 

Re:Methods of showing a form

Thanks Thorsten, i will have to try a Thread. Just need to know
exactly
how to implement it at the moment.
Quote
You can use Form2->Show() and set Form1->Enabled = false in
TForm2::OnShow and Form1->Enabled = true in TForm2::OnHide. You
might also want to consider to use a TThread to do parallel
processing in the two windows.
 

Re:Methods of showing a form

"Greg Stantin" < XXXX@XXXXX.COM >wrote:
Quote
[...] I dont think that will work, simply because when you
do a ShowModal(), your program freezes on that line of code
(ShowModal()) until you close the form.
The program doesn't freeze. You could put all of the code (or call the code) from the OnActivate event:
void __fastcall TForm2::OnActivate(TObject* Sender)
{
//prevent duplicate processing incase user switches applications
static bool FirstPass = true;
if( FirstPass )
{
FirstPass = false;
PerformProcessing();
}
}
In the alternative, you could do something like this (Enter is
a public function):
void __fastcall TForm2::Enter()
{
InitVars();
try
{
GetFormula();
LoadCompanyLogo();
Screen->Cursor = crDefault;
ShowModal();
DisplayFormulaData();
}
catch( Exception &E )
{
CloseDataSets();
DeleteAllocatedMemory();
Screen->Cursor = crDefault;
Visible = true;
Application->ProcessMessages();
MessageDlg("Error Reading Formula : " +E.Message, mtError, TMsgDlgButtons() << mbOK, 0);
Visible = false;
}
}
~ JD
 

Re:Methods of showing a form

Hmmm, i see what you are saying, but i am running all of the code from
the
main form. I don't want to have to transfer everything to Form2. I
will keep
this snippet example for future reference. I ended up doing what
Thorsten
suggested about disabling the main form. That seems to work just the
way
i want it.
Appreciate the help.
Quote
The program doesn't freeze. You could put all of the code (or call
the code) from the OnActivate event:
 

Re:Methods of showing a form

"Greg Stantin" < XXXX@XXXXX.COM >wrote in message
Quote
So you are saying that i can use the ShowModal() and do my
updating on the window and show the progressbars etc. I dont
think that will work, simply because when you do a ShowModal(),
your program freezes on that line of code (ShowModal()) until you
close the form.
The particular code block that is calling ShowModal() will freeze at that
point, but the application as a whole will not. ShowModal() runs a separate
message queue internally to keep the application responsive since the main
message queue is blocked waiting for ShowModal() to return.
Gambit