I need to embed a WinForms form (with BorderStyle = None
) into the Inno Setup Wizard and have an issue.
Here is an Inno Setup script:
procedure EmbedConfiguratorForm(parentWnd: HWND);
external 'EmbedConfiguratorForm@files:configurator.dll stdcall';
procedure InitializeWizard();
var
cfgPageHandle: HWND;
begin
cfgPageHandle := CreateCustomPage(wpSelectDir,
'Configuration',
ExpandConstant(description)).Surface.Handle;
EmbedConfiguratorForm(cfgPageHandle);
end;
Here is a C# code:
class WizardWindow : IWin32Window
{
public WizardWindow(IntPtr handle)
{
Handle = handle;
}
public WizardWindow(int handle) : this(new IntPtr(handle))
{
}
public IntPtr Handle { get; private set; }
}
public static class MainClass
{
[DllExport("EmbedConfiguratorForm", CallingConvention.StdCall)]
public static void EmbedConfiguratorForm(int parentWnd)
{
// System.Diagnostics.Debugger.Launch();
ConfiguratorForm form = new ConfiguratorForm();
form.Show(new WizardWindow(parentWnd));
}
}
It works but not as expected. After setup loads, it automatically call EmbedConfiguratorForm
from configurator.dll
and the form shows but not into setup wizard page. It shows behind (see screenshot).
So what am I doing wrong?