Ativate Form

  • Thread starter Thread starter schneider
  • Start date Start date
S

schneider

Hello,

When a window is closed, what is the next window to get activated, and how
is that determined?

Thanks,

Schneider
 
Hi Schneider,

When a window is opened, Windows tracks its position in the Z order.
Generally, the currently activated window is positioned at the top of the Z
order. If this window is close, Windows seeks the next window positioned in
the Z order and activate it.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thats not what I'm seeing.

The problem I'm having is, When a specific form is closed, a different form
steals to focus.

Example:

Visual zorder:

Form A
Form B
Form C


Form c gets closed and Form A gets activated, when I want Form B to be on
top.

Form B, C are not modal.

Is there a way to stop Form C from causing the activation of Form A?

Thanks,

Schneider
 
Hi Schneider,

Thank you for your reply!

In your example, I consider this behavior would happen only in the case
that you set the TopMost property of Form B to true and after you show Form
C, you activate Form A and then activate Form C again.
Is there a way to stop Form C from causing the activation of Form A?

It's Windows that tracks and determines which form would be activated next.
In the above case, to prevent the activation of Form A after Form C is
closed, a workaround is to set Form A as the owner of Form B and set Form B
as the owner of Form C. Handle the Activated event of Form A and Form B and
activate its owned form in the event handler.

The following is the code in Form A.
public partial class FormA : Form
{
public FormA()
{
InitializeComponent();
this.Activated += new EventHandler(FormA_Activated);
}

void FormA_Activated(object sender, EventArgs e)
{
if (this.OwnedForms.Length > 0)
{
this.OwnedForms[0].Activate();
}
}
private void button1_Click(object sender, EventArgs e)
{
FormB frm = new FormB();
frm.Owner = this;
frm.Show();
}
}

Hope this is what you want.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top