Hemant Jaiswal
Hemant Jaiswal

Reputation: 81

C#: form.TopMost = true not working on Windows 7

I am developing a Windows Setup project using an installer class. I am opening a Windows form before installation and it opens successfully. I want to open this form as a Topmost form, but it opens behind the Setup Wizard on Windows 7.

This form opens as a topmost form successfully on Windows XP during setup. The problem arises only on Windows 7.

I am using the following code for opening that form in my installer class:

namespace MyApp
{
    [RunInstaller(true)]
    public partial class DbInstallerClass : Installer
    {
        public DbInstallerClass()
        {
            InitializeComponent();
            Form frm = new DBInstallerForm();                                  
            frm.TopMost = true;  
            frm.ShowDialog();
        }
    }
}

Is this problem platform specific or OS specific?

Upvotes: 3

Views: 3864

Answers (1)

fab
fab

Reputation: 2509

It works if you put it under load:

private void MainForm_Load(object sender, EventArgs e)
{
    this.TopMost = true;
}

Upvotes: 5

Related Questions