CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    1

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

    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.

  2. #2
    Join Date
    Feb 2005
    Posts
    106

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

    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.

  3. #3
    Andy Tacker is offline More than "Just Another Member"
    Join Date
    Jun 2001
    Location
    55°50' N 37°39' E
    Posts
    1,503

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

    moved to C# forum...

    I dont see any problem in here... I can suggest you removing (this) from the showdialog... just try ShowDialog...
    If you think you CAN, you can, If you think you CAN'T, you are probably right.

    Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.

  4. #4
    Join Date
    Mar 2005
    Posts
    1

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

    I have the same promlem.
    Do you find some solutions ???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured