Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 949463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:24:22+00:00 2026-05-15T23:24:22+00:00

I want to prevent activation of all other forms in my winforms application when

  • 0

I want to prevent activation of all other forms in my winforms application when any dialog is modal. This is how Outlook operates – open two new mail messages, open the address book from one message and you cannot activate the other mail message using either the taskbar or by clicking on the message window. How can I do this in a winforms application (note that setting ownership does not work)?

Sample application below.

using System.Drawing;
using System.Windows.Forms;

namespace ConsoleApplication1
{
   class Program
   {
      static void Main(string[] args)
      {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new MainForm());
      }
   }

   public class MainForm : Form
   {
      public MainForm()
      {
         Text = "Main Form";
         var button = new Button{Text = "New form"};
         button.Click += (sender, args) => new Form2().Show();
         //button.Click += (sender, args) => { var form = new Form2(); AddOwnedForm(form); form.Show(); };
         Controls.Add(button);
         button.Location = new Point(20, 20);
      }
   }

   public class Form2 : Form
   {
      public Form2()
      {
         Text = "Form 2";
         var button = new Button{Text = "New modal form"};
         button.Click += (sender, args) => new Form{Text = "Modal Dialog", ShowInTaskbar = false}.ShowDialog();
         Controls.Add(button);
         button.Location = new Point(20, 20);
      }
   }
}

To reproduce the behaviour, run the application, open two Form2 instances and then open a modal dialog from the second instance. Then use the taskbar to activate the first Form2 instance and it appears above the modal dialog.

Update: this repros with WPF Windows too.

Update: From Hans’ feedback, this does appear to be a bug and I have reported this to connect.microsoft.com here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:24:23+00:00Added an answer on May 15, 2026 at 11:24 pm

    I repro, Win7. I don’t see an obvious workaround for it beyond making these forms owned so they don’t need a taskbar button. That the Windows window manager allows disabled windows to become active is quite odd. This doesn’t get put to test often, very unusual to have one app take so many taskbar buttons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to prevent my application from being reverse engineered and decompiled by someone
I want to prevent XSS attacks in my web application. I found that HTML
I want to prevent line breaks between two forms I have. So basically: <form
We want to prevent other users from editing other users profile, still allowing a
I want to prevent users from shut down or restart the system. my application
I want to prevent accidental activation of tooltips on hover by using .delay and
I want to prevent users submitting forms multiple times in .NET MVC. I've tried
I want to prevent an assembly to be loaded from another application. So that
I want to prevent unauthorized user to access the web based application. My application
I want to prevent the database from storing any values bigger than 20 into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.