[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?
Call Minimize and Restore/show methods of the form, this fix your problem.
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.
I tried the same and I can see the form. The only different I can see is you are missing base.OnAfterInstall(savedState); in your code.
And if it still doesn't show up the try putting just MessageBox to see if your installer is hooked or not with setup project
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()?Top most won't work. Simply make the form to be displayed in the custom action larger than the MSI installer form.
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.