StartForm minimize = form navigation trouble

  • Thread starter Thread starter PeterB
  • Start date Start date
P

PeterB

Hi!

I have a small problem I am sure someone has come across. I have a rather
large application with lots of nested child forms. For instance, the second
level child form (counting from the startup form) is a control rich form
which I want to keep in memory when it has been initialized. So, after the
application has been started and the user has gone through a couple of forms
say about 5 of them still reside in memory. If we for simplicity say the
user is in the last form and closes it, I use the Hide() method of the form
(or the user might minimize it by clicking the (X)). This means the child
forms parent will be shown without any fuss... the user keeps on doing this
until he reaches the startup form.

In the startup form the user clicks the top-right (X) or (OK). I could
either close the form or hide it, there already is an option for terminating
the application, and the recommended thing is to minimize the form since we
don't need to re-initialize all the forms later on. The user goes on playing
solitair for a while and realized he needs to do some more work. He now
clicks the application icon and .. million dollar quiz, what does he see? He
sees, not to surprisingly, the last of the child forms. As this was the
first one to be minimized it is first in line to be shown :-) But this is
ofcourse not what I want...

How can you force the startup form to be shown when you click the
application icon and "re-start" an already open application?? Or can you
make sure the startup form is put first in line to be shown when closing it?

Thanks,

Peter
 
A quick work around for my similar problem was to create a "stub"
executable that simply looks for my start form (using FindWindow API),
and if found, shoves it to the front(Using ShowWindow or
SetForegroundWindow... I don't recall right off-hand). If the start
form is not found, then I simply start the my program (using
ShellExecuteEx).

Have your program's shortcut point to the stub program instead of your
actual application and you're set. This might not be the best
solution, but it works for me :)

Good Luck!
 
Back
Top