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?
Parent
as handle (pointer
) but onlyForm
orControl
. So the easiest way is to useSetParent
winapi function. I think this will be then same where You will callSetParent
from InnoSetup or from DLL – Alexey KulikovNativeWindow
to wrap handle, see stackoverflow.com/a/213751/850848 – Martin PrikrylNativeWindow
) by youself? Sorry but It not works in my issue – Alexey Kulikov