3 windows, bring all to front

T

Thomas Fisher

Hi All,

This should be pretty easy, and I'm sure there's a simple way to do it, but
it's eluding me.

The application has three windows open at all times. Needed functionality: a
click on any of the three windows should bring the other two to the front as
well so that they would all be above any other program windows.

I've been messing with BringToFront and the Activated event but everything I
do seems to lead into infinite loops.

Hopefully one of you knows the 'right' way to handle this common problem.

Thanks for any help!

- Tom
 
T

Tim Wilson

If you set the "Owner" property of the Forms then the associated Forms will
be brought to the front when one is selected. So let's say that Form1 is the
main form and Form2 and Form3 are displayed by Form1, then by setting the
"Owner" property of the Form2 and Form3 instance, from within the scope of
Form1 (this), you have associated the instances of Form2 and Form3 with
Form1. So when Form1 is shown, Form2 and Form3 will be shown.

Form2 form2Instance = new Form2();
form2Instance.Owner = this;
form2Instance.Show();

Form3 form3Instance = new Form3();
form3Instance.Owner = this;
form3Instance.Show();
 
W

webmasta

Good one!

I take it that none of the three windows will ever be covered by each other, otherwise youll be
messing with programatically shifting them around so each is visible... if its an MDI interface you
could use tileing, which I suspect it isnt or you would have figured that.

To stop the looping, just set a variable depending on the Activated status of the window and test
the variable to see if the specific window needs to be activated or not.

~webmasta
~~~~~~~~~


"Thomas Fisher" <thesequoyan [[[at]]] hotmail> wrote in message
| Hi All,
|
| This should be pretty easy, and I'm sure there's a simple way to do it, but
| it's eluding me.
|
| The application has three windows open at all times. Needed functionality: a
| click on any of the three windows should bring the other two to the front as
| well so that they would all be above any other program windows.
|
| I've been messing with BringToFront and the Activated event but everything I
| do seems to lead into infinite loops.
|
| Hopefully one of you knows the 'right' way to handle this common problem.
|
| Thanks for any help!
|
| - Tom
|
|
|
 
T

Thomas Fisher

Thanks!

This method seems to work well with one of the 'sub' forms but the clicking
on the other doesn't cause the others to appear on top. Any idea why that
might be? (I've triple checked to confirm that the code is the same for
each).

- T
 
T

Tim Wilson

How are your Forms layed out? In other words, do you have a main Form that
displays 3 sub Forms - is that the layout? In addition, can you post the
code that you're using with an indication as to where the code is being
called from?
 
T

Thomas Fisher

How are your Forms layed out?

There is the 'main' form and two 'sub' forms.
can you post the code?

This code is in the 'main' form:

CN = New frmConsole(Me)
CN.Show()
CN.Width = Me.Width
CN.Location = New System.Drawing.Point(Me.Left, Me.Top + Me.Height)
CN.Height = 180

RM = New frmRemote(Me)
RM.Show()
RM.Location = New System.Drawing.Point(Me.Left + Me.Width, Me.Top)

'Setup Ownership
Me.AddOwnedForm(CN)
Me.AddOwnedForm(RM)

Thanks for the help with this...

- Tom


Tim Wilson said:
How are your Forms layed out? In other words, do you have a main Form that
displays 3 sub Forms - is that the layout? In addition, can you post the
code that you're using with an indication as to where the code is being
called from?

--
Tim Wilson
.Net Compact Framework MVP

Thomas Fisher said:
Thanks!

This method seems to work well with one of the 'sub' forms but the clicking
on the other doesn't cause the others to appear on top. Any idea why that
might be? (I've triple checked to confirm that the code is the same for
each).

- T

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
is
the
scope
of
Form1 (this), you have associated the instances of Form2 and Form3 with
Form1. So when Form1 is shown, Form2 and Form3 will be shown.

Form2 form2Instance = new Form2();
form2Instance.Owner = this;
form2Instance.Show();

Form3 form3Instance = new Form3();
form3Instance.Owner = this;
form3Instance.Show();

--
Tim Wilson
.Net Compact Framework MVP

"Thomas Fisher" <thesequoyan [[[at]]] hotmail> wrote in message
Hi All,

This should be pretty easy, and I'm sure there's a simple way to do it,
but
it's eluding me.

The application has three windows open at all times. Needed functionality:
a
click on any of the three windows should bring the other two to the front
as
well so that they would all be above any other program windows.

I've been messing with BringToFront and the Activated event but everything
I
do seems to lead into infinite loops.

Hopefully one of you knows the 'right' way to handle this common problem.

Thanks for any help!

- Tom
 
T

Tim Wilson

Using the code that you posted, if I click on any Form, even if its on the
taskbar, it brings all three to the front. Unless, of course, one of the sub
Forms has been explicitly minimized and then this sub Forms will not be
displayed. What is the exact scenario that you would like to see and in what
way is this not working for you?

--
Tim Wilson
..Net Compact Framework MVP

Thomas Fisher said:
How are your Forms layed out?

There is the 'main' form and two 'sub' forms.
can you post the code?

This code is in the 'main' form:

CN = New frmConsole(Me)
CN.Show()
CN.Width = Me.Width
CN.Location = New System.Drawing.Point(Me.Left, Me.Top + Me.Height)
CN.Height = 180

RM = New frmRemote(Me)
RM.Show()
RM.Location = New System.Drawing.Point(Me.Left + Me.Width, Me.Top)

'Setup Ownership
Me.AddOwnedForm(CN)
Me.AddOwnedForm(RM)

Thanks for the help with this...

- Tom


Tim Wilson said:
How are your Forms layed out? In other words, do you have a main Form that
displays 3 sub Forms - is that the layout? In addition, can you post the
code that you're using with an indication as to where the code is being
called from?
Form1
is
the
main form and Form2 and Form3 are displayed by Form1, then by
setting
the
"Owner" property of the Form2 and Form3 instance, from within the
scope
of
Form1 (this), you have associated the instances of Form2 and Form3 with
Form1. So when Form1 is shown, Form2 and Form3 will be shown.

Form2 form2Instance = new Form2();
form2Instance.Owner = this;
form2Instance.Show();

Form3 form3Instance = new Form3();
form3Instance.Owner = this;
form3Instance.Show();

--
Tim Wilson
.Net Compact Framework MVP

"Thomas Fisher" <thesequoyan [[[at]]] hotmail> wrote in message
Hi All,

This should be pretty easy, and I'm sure there's a simple way to
do
it,
but
it's eluding me.

The application has three windows open at all times. Needed
functionality:
a
click on any of the three windows should bring the other two to the
front
as
well so that they would all be above any other program windows.

I've been messing with BringToFront and the Activated event but
everything
I
do seems to lead into infinite loops.

Hopefully one of you knows the 'right' way to handle this common
problem.

Thanks for any help!

- Tom
 
T

Thomas Fisher

Each of the forms in question have around 10k lines of code so it's possible
there's something else in there mucking it up. I'll investigate.

Thanks for the help. I had never encountered 'Owner'...

- T

Tim Wilson said:
Using the code that you posted, if I click on any Form, even if its on the
taskbar, it brings all three to the front. Unless, of course, one of the sub
Forms has been explicitly minimized and then this sub Forms will not be
displayed. What is the exact scenario that you would like to see and in what
way is this not working for you?

--
Tim Wilson
.Net Compact Framework MVP

Thomas Fisher said:
How are your Forms layed out?

There is the 'main' form and two 'sub' forms.
can you post the code?

This code is in the 'main' form:

CN = New frmConsole(Me)
CN.Show()
CN.Width = Me.Width
CN.Location = New System.Drawing.Point(Me.Left, Me.Top + Me.Height)
CN.Height = 180

RM = New frmRemote(Me)
RM.Show()
RM.Location = New System.Drawing.Point(Me.Left + Me.Width, Me.Top)

'Setup Ownership
Me.AddOwnedForm(CN)
Me.AddOwnedForm(RM)

Thanks for the help with this...

- Tom


"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
How are your Forms layed out? In other words, do you have a main Form that
displays 3 sub Forms - is that the layout? In addition, can you post the
code that you're using with an indication as to where the code is being
called from?

--
Tim Wilson
.Net Compact Framework MVP

"Thomas Fisher" <thesequoyan [[[at]]] hotmail> wrote in message
Thanks!

This method seems to work well with one of the 'sub' forms but the
clicking
on the other doesn't cause the others to appear on top. Any idea why that
might be? (I've triple checked to confirm that the code is the same for
each).

- T

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
If you set the "Owner" property of the Forms then the associated Forms
will
be brought to the front when one is selected. So let's say that
Form1
is
the
main form and Form2 and Form3 are displayed by Form1, then by setting
the
"Owner" property of the Form2 and Form3 instance, from within the scope
of
Form1 (this), you have associated the instances of Form2 and Form3 with
Form1. So when Form1 is shown, Form2 and Form3 will be shown.

Form2 form2Instance = new Form2();
form2Instance.Owner = this;
form2Instance.Show();

Form3 form3Instance = new Form3();
form3Instance.Owner = this;
form3Instance.Show();

--
Tim Wilson
.Net Compact Framework MVP

"Thomas Fisher" <thesequoyan [[[at]]] hotmail> wrote in message
Hi All,

This should be pretty easy, and I'm sure there's a simple way to do
it,
but
it's eluding me.

The application has three windows open at all times. Needed
functionality:
a
click on any of the three windows should bring the other two to the
front
as
well so that they would all be above any other program windows.

I've been messing with BringToFront and the Activated event but
everything
I
do seems to lead into infinite loops.

Hopefully one of you knows the 'right' way to handle this common
problem.

Thanks for any help!

- Tom
 
T

Tim Wilson

Ok. Let me know how it goes.

--
Tim Wilson
..Net Compact Framework MVP

Thomas Fisher said:
Each of the forms in question have around 10k lines of code so it's possible
there's something else in there mucking it up. I'll investigate.

Thanks for the help. I had never encountered 'Owner'...

- T

Tim Wilson said:
Using the code that you posted, if I click on any Form, even if its on the
taskbar, it brings all three to the front. Unless, of course, one of the sub
Forms has been explicitly minimized and then this sub Forms will not be
displayed. What is the exact scenario that you would like to see and in what
way is this not working for you?

--
Tim Wilson
.Net Compact Framework MVP

Thomas Fisher said:
How are your Forms layed out?

There is the 'main' form and two 'sub' forms.

can you post the code?

This code is in the 'main' form:

CN = New frmConsole(Me)
CN.Show()
CN.Width = Me.Width
CN.Location = New System.Drawing.Point(Me.Left, Me.Top + Me.Height)
CN.Height = 180

RM = New frmRemote(Me)
RM.Show()
RM.Location = New System.Drawing.Point(Me.Left + Me.Width, Me.Top)

'Setup Ownership
Me.AddOwnedForm(CN)
Me.AddOwnedForm(RM)

Thanks for the help with this...

- Tom


"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
How are your Forms layed out? In other words, do you have a main
Form
that
displays 3 sub Forms - is that the layout? In addition, can you post the
code that you're using with an indication as to where the code is being
called from?

--
Tim Wilson
.Net Compact Framework MVP

"Thomas Fisher" <thesequoyan [[[at]]] hotmail> wrote in message
Thanks!

This method seems to work well with one of the 'sub' forms but the
clicking
on the other doesn't cause the others to appear on top. Any idea why
that
might be? (I've triple checked to confirm that the code is the
same
for
each).

- T

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in
message
If you set the "Owner" property of the Forms then the associated Forms
will
be brought to the front when one is selected. So let's say that Form1
is
the
main form and Form2 and Form3 are displayed by Form1, then by setting
the
"Owner" property of the Form2 and Form3 instance, from within the
scope
of
Form1 (this), you have associated the instances of Form2 and Form3
with
Form1. So when Form1 is shown, Form2 and Form3 will be shown.

Form2 form2Instance = new Form2();
form2Instance.Owner = this;
form2Instance.Show();

Form3 form3Instance = new Form3();
form3Instance.Owner = this;
form3Instance.Show();

--
Tim Wilson
.Net Compact Framework MVP

"Thomas Fisher" <thesequoyan [[[at]]] hotmail> wrote in message
Hi All,

This should be pretty easy, and I'm sure there's a simple way
to
do
it,
but
it's eluding me.

The application has three windows open at all times. Needed
functionality:
a
click on any of the three windows should bring the other two
to
the
front
as
well so that they would all be above any other program windows.

I've been messing with BringToFront and the Activated event but
everything
I
do seems to lead into infinite loops.

Hopefully one of you knows the 'right' way to handle this common
problem.

Thanks for any help!

- Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top