BUG?! Visual Studio .NET 2003: Why is a Modal Dialog destroyed?

G

Guest

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.
 
G

Guest

Modal dialogs stop the process that spawns them. They are chained to that
process. If you spring a modal dialog from a form, and destroy the form,
there is no process, so the modal dialog drops out, as well. It is expected
behavior.

If you want to stop process, but leave the box open, you will have to create
your own classes, as the "boxed" solution will not work.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 

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