How to keep app in Foreground

  • Thread starter Thread starter Tim Johnson
  • Start date Start date
T

Tim Johnson

I've got an app with a main form, from which it launches a 2nd form. If the
user brings up another app from the Start menu at that point, like Contacts,
then "restarts" my app from the Start menu, it brings my app to the
foreground on the 2nd form. So far so good. But then he closes my 2nd
form, and Contacts shows up. Not my main form.

Is there a trick to keeping my app in the foreground in this sort of case,
or do I have to re-acquire the foreground after every time I launch a
subform, as in:

Form2 frm = new Form2();
frm.ShowDialog();
this.BringToFront();

--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
Yes, but the curious thing to me is that my app already was in the
foreground and active - my 2nd form was showing just fine. The problem is
that when I close that form in "normal" circumstances, my 1st form
re-appears as expected. But if I've run Contacts or some other app in
between, then go back to my app (so it's active and fg'd) and then close the
2nd form, what appears next is Contacts. In other words I'm confused why
the Contacts app is suddenly made active when my app was the active app.
Clearly my 1st form doesn't get any kind of redraw event, but why isn't my
app still the active app anyway? I hate to have to put a SetFg after every
call to every subform in my app!

I think it's because each form is regarded as a top-level window (at least
each active form in my app appears as a separate entry in the
System/Memory/Running Programs window). So evidently the Z-order applies
across all apps, not just within my app. So my Z-order at the critical time
was form2, Contacts, form1. When I close form2, Contacts comes to the top.
At least with .Net - I don't recall having this problem on PPC using C++ and
MFC.

Not cool, man!

--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
Back
Top