InnoSetup: is it possible to open a regular Delphi form (from the DLL) instead of the usual configuration wizard

I need to create a complex form with my own components (for example, the OneClick installer) and use it as a replacement for the standard InnoSetup wizard. Is it possible?

My form is placed in a DLL and this DLL will be available to the InnoSetup process.

Here is how I tried to do this:

Delphi dll

library OneClickWizard;

uses
  SysUtils,
  Classes,
  Wizard in 'Wizard.pas' {FormWizard};

{$R *.res}

exports
  CreateWizardForm,
  DestroyWizardForm;

begin
end.

Delphi Form

unit Wizard;

interface

type
  TFormWizard = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormWizard: TFormWizard;

procedure CreateWizardForm(AppHandle: THandle); stdcall;
procedure DestroyWizardForm; stdcall;

implementation

{$R *.dfm}

procedure CreateWizardForm(AppHandle: THandle);
begin
  Application.Handle := AppHandle;
  FormWizard := TFormWizard.Create(Application);
  FormWizard.Show;
  FormWizard.Refresh;
end;

procedure DestroyWizardForm;
begin
  FormWizard.Free;
end;

InnoSetup script (iss)

[Setup]
;Disable all of the default wizard pages
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyMemo=true
DisableReadyPage=true
DisableStartupPrompt=true
DisableWelcomePage=true
DisableFinishedPage=true

[Files]
Source:"OneClickWizard.dll"; Flags: dontcopy

[Code]
procedure CreateWizardForm(AppHandle: Cardinal); 
  external 'CreateWizardForm@files:OneClickWizard.dll stdcall';
procedure DestroyWizardForm;
  external 'DestroyWizardForm@files:OneClickWizard.dll stdcall';


procedure InitializeWizard();
begin
  CreateWizardForm(MainForm.Handle);
end;

The form appears on the screen, but it does not respond to my input. This does not seem to be from the main message loop. How to do it right?

+5
source share
3 answers

InnoSetup, , , ShowModal, Show . , , , Inno. , , ? ShowModal , .

DLL, DestroyWizardForm, , ShowModal, .

+5

- . InnoSetup StrToInt(ExpandConstant('{wizardhwnd}')) ( , MainForm.Handle )

DLL:

OldAppHandle := Application.Handle;
try
  Application.Handle := hAppHandle; // hAppHandle the handle from InnoSetup
  F := TfmZForm.Create(Application);
  try
    F.Caption := lpTitle;
    F.ShowModal;
    Result := F.ErrorCode;
  finally
    F.Free;
  end;
finally
  Application.Handle := OldAppHandle;
end;
+6

If you want to completely replace the user interface, it will probably be easier to create a stub application that represents the form, then start the normal setup in silent mode, passing various command-line options.

Either this, or at least using Inno's built-in form and wizard functions / logic functions.

+1
source

All Articles