Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Messagebox appearing behind uninstaller

Messagebox appearing behind uninstaller

Scheduled Pinned Locked Moved C#
helpquestioncsharpvisual-studiowindows-admin
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jacob D Dixon
    wrote on last edited by
    #1

    So I am trying to give the user an option of removing registry keys when uninstalling my application (the installer is the windows installer with visual studio). The problem is it appears the message box appears behind the uninstaller (sometimes). Here is what I am doing:

        public CustomInstaller() : base()
        {
            InitializeComponent();
    
            base.AfterUninstall += new InstallEventHandler(CustomInstaller\_AfterUninstall);
        }
    
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);
        }
    
        void CustomInstaller\_AfterUninstall(object sender, InstallEventArgs e)
        {
            // Ask to remove settings
            DialogResult result = MessageBox.Show("Do you want to remove all settings? (This is not reversible)", "Remove Settings",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == DialogResult.Yes)
            {
                try
                {
                    Registry.LocalMachine.DeleteSubKeyTree(@"Software\\JD Development");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to remove registry settings: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
    
            // Delete the service
            Process.Start("sc", "delete JDAgent");
        }
    
    J 1 Reply Last reply
    0
    • J Jacob D Dixon

      So I am trying to give the user an option of removing registry keys when uninstalling my application (the installer is the windows installer with visual studio). The problem is it appears the message box appears behind the uninstaller (sometimes). Here is what I am doing:

          public CustomInstaller() : base()
          {
              InitializeComponent();
      
              base.AfterUninstall += new InstallEventHandler(CustomInstaller\_AfterUninstall);
          }
      
          public override void Uninstall(IDictionary savedState)
          {
              base.Uninstall(savedState);
          }
      
          void CustomInstaller\_AfterUninstall(object sender, InstallEventArgs e)
          {
              // Ask to remove settings
              DialogResult result = MessageBox.Show("Do you want to remove all settings? (This is not reversible)", "Remove Settings",
                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
              if (result == DialogResult.Yes)
              {
                  try
                  {
                      Registry.LocalMachine.DeleteSubKeyTree(@"Software\\JD Development");
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show("Unable to remove registry settings: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                  }
              }
      
              // Delete the service
              Process.Start("sc", "delete JDAgent");
          }
      
      J Offline
      J Offline
      JF2015
      wrote on last edited by
      #2

      I googled (you can do this too) and found some solutions: 1.:

      MessageBox.Show(new Form(){TopMost = true},"I'm still on top, YEAH");

      2.: TopMost MessageBox[^] 3.:

      [DllImport("user32.dll")]
      public static extern int MessageBox(int hWnd, String text, String caption, uint type);

      Then just call MessageBox with MB_TOPMOST

      J 1 Reply Last reply
      0
      • J JF2015

        I googled (you can do this too) and found some solutions: 1.:

        MessageBox.Show(new Form(){TopMost = true},"I'm still on top, YEAH");

        2.: TopMost MessageBox[^] 3.:

        [DllImport("user32.dll")]
        public static extern int MessageBox(int hWnd, String text, String caption, uint type);

        Then just call MessageBox with MB_TOPMOST

        J Offline
        J Offline
        Jacob D Dixon
        wrote on last edited by
        #3

        Yeah I was working on this late night and didn't find anything. Just had my wording screwed up in my search parameters instead of just top most messagebox. I dunno. Thanks for the reply.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups