Mdi bug ?

  • Thread starter Thread starter Fab
  • Start date Start date
F

Fab

Hi,

I have a mdi container form named Form1, and two child forms named Form2 and
Form3.
I open Form1, then Form2 and Form3.
I minimize Form2.
I close Form 3.
Then i can't close Form1 anymore !

In fact, if i have a child Form minimised while i close another one, i can't
close anymore the container form.

I have tried with dotnet 1.1 and 2.0, Visual 2003 and 2005.

Is this a bug ? Is there a way to fix it ?

Many thanks,

FB.

using System;
using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

namespace WindowsApplication1

{

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.MainMenu mainMenu1;

private System.Windows.Forms.MenuItem menuItem1;

private System.Windows.Forms.MenuItem menuItem2;

private System.ComponentModel.IContainer components;

public Form1()

{

InitializeComponent();

}

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.mainMenu1 = new System.Windows.Forms.MainMenu();

this.menuItem1 = new System.Windows.Forms.MenuItem();

this.menuItem2 = new System.Windows.Forms.MenuItem();

//

// mainMenu1

//

this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.menuItem1,

this.menuItem2});

//

// menuItem1

//

this.menuItem1.Index = 0;

this.menuItem1.Text = "Ouvrir 2";

this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);

//

// menuItem2

//

this.menuItem2.Index = 1;

this.menuItem2.Text = "Ouvrir 3";

this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(424, 429);

this.IsMdiContainer = true;

this.Menu = this.mainMenu1;

this.Name = "Form1";

this.Text = "Form1";

}

#endregion

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void menuItem1_Click(object sender, System.EventArgs e)

{

Form2 aForm2 = new Form2();

aForm2.MdiParent = this;

aForm2.Show();

}

private void menuItem2_Click(object sender, System.EventArgs e)

{

Form3 aForm3 = new Form3();

aForm3.MdiParent = this;

aForm3.Show();

}

}

}
 
There's a bug in your code; I have a Mdi application, and minimizing
child windows doesn't prevent the main form from closing.

Andy
 
I have a mdi container form named Form1, and two child forms named Form2 and
Form3.
I open Form1, then Form2 and Form3.
I minimize Form2.
I close Form 3.
Then i can't close Form1 anymore !

In fact, if i have a child Form minimised while i close another one, i can't
close anymore the container form.

I have tried with dotnet 1.1 and 2.0, Visual 2003 and 2005.

Is this a bug ? Is there a way to fix it ?

It looks like a bug to me. I've been able to reproduce it here (.NET 1.1,
VS 2003) and I can't see anything wrong or unusual about your code. There
is something even more weird: this bug only seems to appear when the parent
form has a main menu but no other control. In your case, your Form1 has a
main menu and no other control. Run it, do what you've described above and
the bug will creep up. Now close the application, open Form1 in the
designer and add another control to the form (a Button for instance).
Launch the application again, perform the steps, try to close Form1... it
closes just fine. The bug has gone. Freaky.
 
Doubt its a bug in .Net; I have a mdi application as well, and I can
open two different forms, minimize the second, then close the third,
and I can close my application window.

There's something wrong with the code posted, not .Net. I'm sure a bug
like this in 1.1 and 2.0 would have been discovered by now.

Andy
 
Doubt its a bug in .Net; I have a mdi application as well, and I can
open two different forms, minimize the second, then close the third,
and I can close my application window.

There's something wrong with the code posted, not .Net. I'm sure a bug
like this in 1.1 and 2.0 would have been discovered by now.

Try it then and tell us whether you can or cannot reproduce the bug
(following the exect steps described by the OP). Because I did reproduce
the bug and frankly, i can't see what could be possibly wrong with the
code. It's just about the most basic piece of code you could do. One main
menu with 2 menu items, each creating and showing a child form. Nothing
fancy, it's all designer generated code.
 
Thanks Mehdi.
Effictively, it's all designed code, there's nothing special in this.

And effectively, the bug has gone with a button on the main form.... But not
with a label !!!

Very strange...
FB
 
Something more stange: that works with a button that is visible, but the bug
is still there if you make the button not visible...
 
Perhaps if there's no control on the main form that can accept the Focus,
this causes the problem?

(Just a shot in the dark....)

Anne
 
Fab said:
Hi,

I have a mdi container form named Form1, and two child forms named Form2 and
Form3.
I open Form1, then Form2 and Form3.
I minimize Form2.
I close Form 3.
Then i can't close Form1 anymore !

In fact, if i have a child Form minimised while i close another one, i can't
close anymore the container form.

I have tried with dotnet 1.1 and 2.0, Visual 2003 and 2005.
<...>

Verified with 2005 here too.

JB
 
Yes, that's the way to avoid the problem : i have just created a 0 sized
button on the container form.
The most strange thing is noboby encountered the problem until today...
 
Back
Top