Click to See Complete Forum and Search --> : BUG?! Visual Studio .NET 2003: Why is a Modal Dialog destroyed?


Quaker_AL
January 28th, 2005, 02:11 AM
I have problem, which is to minimize a WinForm Application with an Open Modal Dialog.
When the WinForm Application is minimized, then the Modal Dialog is destroyed. Why?! Bug ?!

Sample:

using System;
using System.Windows.Forms;
class MainForm: Form
{
Timer timer = new Timer();
Form modalForm = new Form();

public MainForm()
{
Button btShowModal = new Button();
btShowModal.Click += new EventHandler(btShowModal_Click);
btShowModal.Parent = this;
timer.Interval = 5000;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();

}
static void Main()
{
Application.Run(new MainForm());
}
private void btShowModal_Click(object sender, EventArgs e)
{
modalForm.ShowDialog(this);


...when MainForm is minimized, then modalForm is destroyed... ?! BUG ?!;
}
private void timer_Tick(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Normal)
WindowState = FormWindowState.Minimized;
else
WindowState = FormWindowState.Normal;
}
}

I have Visual Studio .NET 2003 and Framework v1.1 SP1.

Kindly solve my problem.

SouthernCodeMonkey
February 17th, 2005, 03:38 PM
You're smearing your modal dialog when your timer fires and makes a call on your GUI thread which is being blocked by your dialog.

Andy Tacker
February 18th, 2005, 01:29 AM
moved to C# forum...

I dont see any problem in here... I can suggest you removing (this) from the showdialog... just try ShowDialog...

aaasssddd
March 15th, 2005, 04:41 AM
I have the same promlem.
Do you find some solutions ???