Injecting dialog is shown incorrectly

Oct 25, 2016 at 8:04 AM
Hello, Oleg!
I do msi installer with standart UI.
project.InjectClrDialog injects custom dialog into standart dialog sequence.
project.InstallScope = InstallScope.perMachine;

Then I embedded the msi into bootstrapper.
During installing injecting custom dialog shows in the top left corner of the screen with minimum size. Previous dialog isn't hiden.

if project.InstallScope = InstallScope.perUser, dialog sequence is shown correctly.
Oct 26, 2016 at 2:34 AM
Edited Oct 26, 2016 at 11:46 AM
Thank you I wasn't aware about this one.

Injected CLR dialog needs to position and resize itself properly on the screen just where the native MSI UI dialog was before proceeding to the CLR dialog by clicking Next button. The vital part of this positioning is to find the handle of the main Window of the msi process. The default algorithm works well but I guess it fails when the msi process is elevated because of the InstallScope.perMachine.

Making the default algorithm more sophisticated can be a difficult time consuming exercise. However making it work for a specific scenario like yours is relatively simple. You will need to implement your own algorithm of finding the window. For that you need to overwrite the GetMsiForegroundWindow method of WixCLRDialog:
protected override IntPtr GetMsiForegroundWindow()
    var handle = base.GetMsiForegroundWindow();

    if (handle == IntPtr.Zero)
        handle = Win32.FindWindow(null, "natka setup");

    return handle;
In this case I assumed that your main msi (setup) window has title "natka setup";