views:

24

answers:

1

I have a CustomInstaller class (System.Configuration.Install.Installer) and basically I'm opening a dialog form at Install method. I wonder if it's possible somehow to say that 'Parent' property of that form would be the setup process window?

How can I do that?

+1  A: 

You need to get the handle of the installer window. Not so sure how to get it, but Process.GetCurrentProcess().MainWindowHandle ought to give you good odds. Then create a NativeWindow to wrap the handle so you can use it as the owner. Like this:

        IntPtr hdl = Process.GetCurrentProcess().MainWindowHandle;
        var window = new NativeWindow();
        window.AssignHandle(hdl);
        try {
            using (var dlg = new YourForm()) {
                var result = dlg.ShowDialog(window);
                //...
            }
        }
        finally {
            window.ReleaseHandle();
        }
Hans Passant
It's returning zero as MainWindowHandler. I wonder why...
Ike
I got that... it's because windows installer starts CustomActions in different process, but in the same tree...
Ike