Windows > Windows Forms Forums > ClickOnce and Setup & Deployment Projects > How to bring windows form infront of the set up installation form ?
Ask a questionAsk a question
 

AnswerHow to bring windows form infront of the set up installation form ?

  • Wednesday, November 04, 2009 4:24 AMSyam Swetha Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello Every Body,

                    I am implementing customized web set-up installation for my application. While running the installation process I am trying to open a windows form in installer class events to display information. But the problem with this Windows form is, it is displayed at back side of the set-up installation form. it is working in windows server 2007 operating system and windows XP it is not working . i  wrote the following lines of code  :

    //In windows installer class event
    Child
    child = new Child
    ();
    child.LostFocus +=
    new EventHandler
    (Child_LostFocus);
    child.ShowDialog(
    this
    );  

     

     

    protected void Child_LostFocus(object sender, EventArgs e)
    {
    Form child = (Form
    )sender;
    child.Focus();
    child.Refresh();
    }


    “Can anybody tell me how to bring the form to in front of the set-up installation form ?”.


    Thank you,

Answers

All Replies

  • Tuesday, November 03, 2009 12:47 PMSyam Swetha Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello Every Body,

                    I am implementing customized web set-up installation for my application. While running the installation process I am trying to open a windows form in installer class events to display information. But the problem with this Windows form is, it is displayed at back side of the set-up installation form. it is working in windows server 2007 operating system and windows XP it is not working . i  wrote the following lines of code  :

    //In windows installer class event
    Child
    child = new Child();
    child.LostFocus +=
    new EventHandler(Child_LostFocus);
    child.ShowDialog(
    this);  

     

    protected void Child_LostFocus(object sender, EventArgs e)
    {
    Form child = (Form)sender;
    child.Focus();
    child.Refresh();
    }


    “Can anybody tell me how to bring the form to in front of the set-up installation form ?”.


    Thank you,

  • Wednesday, November 04, 2009 8:29 AMGeert van Horrik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Set the Form.TopMost property to true. It makes your form be on top of all windows, but during an installation, I think it's fine.


    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
  • Wednesday, November 04, 2009 12:19 PMSyam Swetha Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    For the first time of the installation process,it is working fine .But for the further installations the form is getting displayed behind the installation set -up form.
  • Wednesday, November 04, 2009 1:20 PMGeert van Horrik Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Then the installer also uses the TopMost property. Use the BringToFront method as well.
    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
  • Wednesday, November 04, 2009 9:34 PMScottyDoesKnow Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    I'm noticing the same thing with a form I'm using during uninstallation. The form is set to topmost but any window I select (like this internet explorer browser) goes over it.

    BringToFront seems to fix it though. I added this code to my form:

    protected override void OnShown(EventArgs e)
            {
                base.OnShown(e);

                BringToFront();
            }

    And now it comes to front at the start, and TopMost is working too for some reason.

  • Wednesday, November 11, 2009 5:17 AMSyam Swetha Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     


    Thanks to every one.but it is not working
  • Wednesday, November 11, 2009 1:46 PMvjerryfuller Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    me too have the same problem... please help us with some options.
  • Wednesday, November 11, 2009 8:34 PMPhilWilsonModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    First I'll point out that this will always be indeterminate for a couple of reasons:

    1. You don't own the desktop, the user does, and if they select some window and it hides some other window then this is what they want. If you look at this you'll get the general idea of how pointless it is to play games with this:
    http://blogs.msdn.com/oldnewthing/archive/2009/02/20/9435239.aspx 

    2. The Windows Installer architcture is that you're expected to get user input at the start of the install in the UI sequence, and VS provides some canned dialogs. If those canned dialogs aren't sufficient then you should consider the possibility of using another tool. The Windows Installer service does not expect to get UI out of its execute sequence during the progress bar period, and all kinds of odd things might happen. The MSI team does not actually support that kind of installer class custom action:
    http://robmensching.com/blog/posts/2007/4/19/Managed-Code-CustomActions-no-support-on-the-way-and-heres 
    but DTF has some mechanisms for running installer class code out of their own process.

    Anyway, in reality there is no advantage to an installer class showing forms when compared to an actual Windows Forms app exe showing forms because they both run at the end of the install. So just run a windows forms app executable at the end of the install, and you can launch it with a simple custom action asynchronously so it stays running after the install is done. It also means that you can have a shortcut to this app to run it later to change configuration. You also have an actual program that you can debug, as opposed to an installer class called from an MSI.

    Phil Wilson
  • Wednesday, November 11, 2009 8:39 PMScottyDoesKnow Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Unless you're doing an uninstall, then you have no windows to get input at the start and no way to run a program afterwards.

    Weird that it won't work for you jerry. Maybe try posting some code? For me I just set the form as TopMost, and in the Shown event added a BringToFront() and it worked fine (on Vista at least, haven't tried XP).