How to insert a form from a DLL into the Inno Setup Wizard page?

I created some VCL forms in the Delphi DLL that appear during the installation of Inno Setup. However, it would be much more concise if I could embed these forms in the Inno Setup Wizard.

How can i do this?

+3
source share
1 answer

The easiest way for you is to create an exported function that will do whatever your library has. The necessary minimum for such a function is the parameter for the handle of the Inno Setup control into which your form should be embedded. The next necessary thing you need to know for implementation is the boundaries, but the ones you can get with a call to the Windows API function on the library side.

Here is the Delphi part showing the device with the form from your DLL project:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids;

type
  TEmbeddedForm = class(TForm)
    StringGrid1: TStringGrid;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  end;

procedure CreateEmbeddedForm(ParentWnd: HWND); stdcall;

implementation

{$R *.dfm}

{ TEmbeddedForm }

procedure TEmbeddedForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

{ CreateEmbeddedForm }

procedure CreateEmbeddedForm(ParentWnd: HWND); stdcall;
var
  R: TRect;
  Form: TEmbeddedForm;
begin
  Form := TEmbeddedForm.Create(nil);
  Form.ParentWindow := ParentWnd;
  Form.BorderStyle := bsNone;
  GetWindowRect(ParentWnd, R);
  Form.BoundsRect := R;
  Form.Show;
end;

exports
  CreateEmbeddedForm;

end.

And here is the installation of the Inno script:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

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

[Code]
procedure CreateEmbeddedForm(ParentWnd: HWND);
  external 'CreateEmbeddedForm@files:MyDLL.dll stdcall';

procedure InitializeWizard;
var
  CustomPage: TWizardPage;
begin
  CustomPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
  CreateEmbeddedForm(CustomPage.Surface.Handle);
end;

Just note that Inno Setup also supports it COM Automation, so the above method is not the only way to embed an object in a wizard form. However, this is the easiest.

, , . - Inno Setup script , , Inno DLL.

+5

Source: https://habr.com/ru/post/1622649/


All Articles