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 7771661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:42:27+00:00 2026-06-01T16:42:27+00:00

I have an application that is being deployed via a Visual Studio Setup Project,

  • 0

I have an application that is being deployed via a Visual Studio Setup Project, however, I had to create some custom Windows Forms to collect some specific data from the user. These forms are shown in the Install() method of the application’s Installer class, right after application files have been deployed by the Setup Project (I.E. the MSI). The problem is that when my forms appear, they appear under the Setup Project’s window rather than being the topmost form on the screen. The form then has to be focused on manually by clicking on its icon in the taskbar to bring it up, if the user even notices it.

  • 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-06-01T16:42:28+00:00Added an answer on June 1, 2026 at 4:42 pm

    All I had to do was pick the Setup project’s window from the list of processes and set it as the owner of the custom forms as I was displaying them. Here’s a breakdown of the steps I used:

    1. Go through the list of processes named “msiexec”, and get the handle of the one displaying the Setup .msi’s window, identifiable by the MainWindowTitle – the title of the window.
    2. You now have the handle of this process (MainWindowHandle), but how do you use it? You can specify the owner of a Form when you’re calling ShowDialog through the parameter that takes an IWin32Window; the problem is that IWin32Window doesn’t let you set the handle of the window. This is worked around by using a wrapper class which extends IWin32Window.
    3. So finally, all you have to do is set the owner of the form as you’re calling ShowDialog(), with something like CustomForm.ShowDialog(new WindowWrapper(process.MainWindowHandle), message, etc.).

    Myself, I made a method which returns the Setup Project’s window as a WindowWrapper, and then used that in each of the Installer class’s methods (Install, Commit, Uninstall and Rollback) to set the owner of every form and messagebox I am creating.

    Also, don’t change the owners of any child forms or messageboxes of your custom forms (except maybe to “this”), as they’ll be owned by the custom forms that show them; otherwise they’ll show up over the Setup project’s window but under the custom forms, not that we desired.

        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
            try
            {
                ExecuteSqlScript();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    
        private void ExecuteSqlScript()
        {
            IntPtr hwnd = IntPtr.Zero;
            WindowWrapper wrapper = null;
            Process[] procs = Process.GetProcessesByName("msiexec");
            if (null != procs && procs.Length > 0)
                hwnd = procs[0].MainWindowHandle;
            wrapper = new WindowWrapper(hwnd);
            //Set the windows forms owner to setup project so it can be focused and
            //set infront
            frmInstance objInstance = new frmInstance();
            if (null != wrapper)
                objInstance.ShowDialog(wrapper);
            else
                objInstance.ShowDialog();
        }
    
        public class WindowWrapper : System.Windows.Forms.IWin32Window
        {
            public WindowWrapper(IntPtr handle)
            {
                _hwnd = handle;
            }
    
            public IntPtr Handle
            {
                get { return _hwnd; }
            }
    
            private IntPtr _hwnd;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application project (wap) that is successfully being deployed to a
I have an MSI-packaged application that is being deployed via Group Policy Objects (GPO)
I have a web application that I wrote in Visual Studio 2008 that targets
We have an application that is being moved to .NET. One part of the
I have a Java Swing application that is being used as a cluster application.
I have a combo box in a C# Windows form application that is being
I have an ASP.NET application that is hosted in timezone A and is being
I have written an application for Android. the main part being that it communicates
I have a function that is being called from different threads in the application.
I have a static instance variable that is being used throughout my application. It

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.