[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
private void Installer1_AfterInstall(object sender, InstallEventArgs e)
{
Form1 topmostForm = new Form1();
topmostForm.BringToFront();
topmostForm.TopMost = true;
topmostForm.ShowDialog();
} }
I need to display the topmostForm in front of the default Windows Installer UI. The above is sample code inside my CustomAction that I am using to create a Form. Setting the TopMost property or using ShowDialog is not helping. Is there any other solution to make my form the top most and focussed?
To add a custom action click on the custom action icon. This will open the following window and there we can add a project containing an installer class. To create this project having an installer class, we can make a class library type of project and add an installer class in it from the add new item dialog.
If not then Choose View -> Editor -> File System. Now, you need to add output of your Windows Form Application to build the setup. Right-click on the Application Folder and select Add -> Project Output. Leave the default selection of Primary Output in the "Add Project Output Group" dialog box and click the OK button.
Go to Extensions > Manage Extensions > Online > Search, find, download and install Microsoft Visual Studio Installer Projects extension. 2). Add a new Setup Project in your solution > right-click Application Folder > Add > Project Output… > choose the corresponding Project > select Primary output > OK.
If you want to show your own UI in the installer, you won't be able to use a setup and deployment project, because it lacks the features necessary to implement that. Consider using an installer toolkit like WiX or Inno Setup instead.
Concerning the first part of your question, are you passing the custom dialog box in the owner
argument to MessageBox.Show()?
although i'm not wuite sure what exactly you're asking for, using WiX for building windows installers is the prefered way to go. There you can build your forms and custom actions and pretty much anything else.
If you want to have complete control over installer user interface for branding or custom dialogs and don't want to use installer builder software like InstallShield then you can create a C++ application to serve as shell for Windows Installer - there is no need to implement installer actions such as copying files by yourself.
Windows Installer has API for such purpose. With function MsiSetExternalUIRecord you can provide a callback to capture installer notifications such as messages and progress updates.
Dialogs created by custom actions are always displayed behind the installation dialogs on newer Windows versions (Vista and Windows 7). This is because Windows prevents applications to move a window on top of all other windows. Think how virus popups would fill up the screen on older Windows versions.
Instead, a newly created dialog is displayed in the background and it's title bar button (if it has one) flashes.
The correct solution for what you want is creating a dialog in your MSI package and using it instead of the custom action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With