Hi :)
I have a software, which contain
several forms that are open at the same time.
And i have caple of problems with it:
1) How can i do that all the forms will minimize
when i minimize the main form ?
2) I have some forms that supose to be at the top of the screen
all the time (form.topmost) but the problem is
when i go to another program (while my software is open)
those forms are still at the top of the screen, i dont want them
to be at the top when my software lost focus, how can i do it ?
(i tryed to make all the forms.topmost=false, when my main forum
lost his focus, but its not working :/)
Thanks.
ManuelPosted Aug 1, 2007, 5:00 PM
List
< Form > forms = new List< Form >( ); List< Form > topForms = new List< Form >( ); bool oneIsActive = true; for ( int a = 0; a < 3; a++ ){
forms.Add(
new Form( ) );}
topForms.Add( forms [ 0 ] );
topForms.Add( forms [ 2 ] );
for ( int a = 0; a < forms.Count; a++ ){
Form form = forms [ a ];form.Text =
string.Concat( "Form #", a, " - TopMost = ", topForms.Contains( form ) );form.Activated +=
delegate{
if ( ! oneIsActive ){
oneIsActive =
true; for ( int i = 0; i < topForms.Count; i++ ){
topForms [ i ].TopMost =
true;}
}
};
Timer timer = new Timer( );timer.Interval = 300;
timer.Tick +=
delegate{
timer.Enabled =
false; if ( ! oneIsActive ){
for ( int i = 0; i < topForms.Count; i++ ){
topForms [ i ].TopMost =
false;}
}
};
form.Deactivate +=
delegate{
timer.Enabled =
true;};
form.Show(
this ); // giving Form as parameter effects that shown Form will be minimized when parameter-Form is minimizedform.Left = 100 + a * 350;
}