>Here's my problem:  Form1 is current and in the foreground.  A certain
>action launches Form2.  Now Form2 is in the foreground and Form1 is in
>the background.  Form2 has a button to launch Form1, but rather than
>re-launching a new instance, I want to simply bring the existing
>background form back to the foreground.  I tried adding a simple Show
>call to it, but that seems to show a 2nd instance!  How do I bring the
>background form to the foreground?  I'm thinking it has something to do
>with the Hwnd property but I've never played with that before.

My base form class has a custom BringToTop() method. It cycles through the 
form's Controls collection to find the first one that has a SetFocus() 
method, then calls that method on that control. That forces the form to the 
top.

You can, of course, override the BringToTop() method to make it set focus 
to any control you want.

I also have a Form Manager class that has an OpenForm() method. You can 
call that method and pass the form name, and "bringtotop" as one of the 
parameters. Then it will open the form if it's not already open, but if it 
is, it will call the already-open form's BringToTop() method instead.

Ken Dibble
www.stic-cil.org


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to