Objective is simple. Show Form1 first and maximize it (can make observation
easier), then after click button1, show form2 as modal dialog.
When hide form2 by click button2, the expected behavior is that form2 hides
and form1 becomes the topmost form.
The funny thing is that, sometimes after hide form2, some kind of blinking
will be seen.
You will find something like form1 become transparent-like for 0.2-2 second
or just go to the back,
and the window (e.g., Visual Studio) which was right behind form1 will show
up.
Form1 will comeback to top most again very soon after this z-order switch.
But it also may just never come back, becoming the 2nd topmost form. The
Visual Studio IDE will be the top most window. Need to use alt-tab to get
form1 back.
Can anyone explain this? Thanks.
Slower pc can make it more easy to observe. But this also happen on fast pc.
Part of the C# Code (excluding designer code and some other non-crutial
code):
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
public partial class Form1 : Form
{
private Form2 f;
public Form1()
{
InitializeComponent();
f = new Form2();
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult d = f.ShowDialog(this);
}
}
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
}
}
Manish Bafna - 24 Mar 2007 10:50 GMT
Try setting the modal form's(form2) TopMost to False and setting its Owner
property to the parent(form1) Form.
Form2 f = new Form2();
f.TopMost = false;
f.Owner = this;
f.Show();

Signature
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
> Objective is simple. Show Form1 first and maximize it (can make observation
> easier), then after click button1, show form2 as modal dialog.
[quoted text clipped - 55 lines]
> }
> }
Fluxray - 28 Mar 2007 03:05 GMT
Thanks Manish but seems it is not working. And I do need showdialog to make
sure the parent form is disabled.
> Try setting the modal form's(form2) TopMost to False and setting its Owner
> property to the parent(form1) Form.
[quoted text clipped - 66 lines]
> > }
> > }
VJ - 28 Mar 2007 17:32 GMT
Hi.. This has been a problem for us. We choose to give quick navigate
buttons so the user can swtich back. I have looked around, was never able to
get a answer.
If you do find some, would like to learn!
VJ
> Thanks Manish but seems it is not working. And I do need showdialog to
> make
[quoted text clipped - 80 lines]
>> > }
>> > }