Board index » cppbuilder » Form Oddities in Show and Hide

Form Oddities in Show and Hide


2007-03-01 02:53:14 AM
cppbuilder81
Hi,
Hopefully someone has encountered this before...
I have two forms (Login Form, Main Menu Form)
The Main Menu Form's Visible Property is Set to False
When the Application Starts to Run, you get the login form.
You press the okay button, and it calls methods for verification
and other stuff. The Login Process takes about 5 seconds to complete.
After the 5 seconds, the Login Form is Hidden, and the Main Menu Form is set to become visible.
The problem:
During the login process, if I switch screens (go to explorer),
or any other window to multitask, when I come back to the application;
The Main Form is Visible and so is the Login Form.
I don't understand why the Login Form isn't Hidden?
If the application doesn't lose focus, everything runs as normal.
But when I change focus during the login menu, and return back to the app.
The login menu remains visible?
I've added additional checks in the Main Menu Form's on Show Event, but it doesn't seem to work:
If (LoginMenuForm->Visible)
LoginMenuForm->Hide();
Does anyone else have this problem?
Do I need to write a search routine to find the form to close it?
Thanks,
Heinz
 
 

Re:Form Oddities in Show and Hide

First, check the code in OnShow and in OnActivate because
it can be called *multiple* times, especially if changing focus.
--
Best Regards,
Vladimir Stefanovic
 

Re:Form Oddities in Show and Hide

"Heinz Ketchup" < XXXX@XXXXX.COM >
wrote in message news:45e5cf9a$ XXXX@XXXXX.COM ...
Quote
The Main Menu Form's Visible Property is Set to False

When the Application Starts to Run, you get the login form.
You press the okay button, and it calls methods for verification
and other stuff. The Login Process takes about 5 seconds to
complete.

After the 5 seconds, the Login Form is Hidden, and the Main Menu
Form is set to become visible.
You should display the Login form inside of WinMain() directly (use
'new' so it does not become the MainForm), and then create the
MainForm only if the validation succeeded. If the validation fails,
you can simply exit WinMain() immediately, and the MainForm is never
created. Either way, you can destroy the Login form after you are
done using it so it does not stick around wasting unnecessary
resources.
Gambit
 

{smallsort}