0
votes

I am trying to show a FMX form in Inno Setup using an dll. i created a DLL and added the form to the DLL.dll. here is the code from the dll:

library DLL;

uses
  System.SysUtils,
  System.Classes,
  Winapi.Windows, Winapi.Messages, System.Variants,
  DLLForm in 'DLLForm.pas' {Form2};

{$R *.res}
procedure ShowForm; stdcall;
begin
  Form2:=TForm2.Create(nil);
  Form2.ShowModal;
  Form2.Free; //Added this line.
  end;

Exports ShowForm;
end.

and here it is the code for inno:

[Setup]
AppName=Windows
AppPublisher=Stack
AppVersion=1.0.0.0
DefaultDirName={pf}\FMXForm

[Files]
Source: Include\DLL.dll; DestDir: {tmp} Flags: dontcopy;

[code]
procedure Show;
external 'ShowForm@Files:DLL.dll stdcall delayload';

procedure InitializeWizard();
begin
  Show;
end;

Setup Compiles but did not showing the form and exits without showing any errors.

It is working fine with cmd,vcl apps but with inno it is not. I used following code to show the form from dll in cmd,vcl apps :

procedure ShowForm; stdcall; external 'DLL.dll';
...
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Free;
ShowForm;
end;
1
This is utter masochism. Make a VCL form for pity's sake!David Heffernan
it is working fine with cmd app and with vcl app created in Delphi but with inno it's not working. I Tried to create an vcl form with same method above but it is not working.bear
So you get the same problem with VCL as with FMX?Martin Prikryl
Yes, but i think it is problem with inno procedure calling code because it is working fine with cmd ,VCL apps.bear
Then you should modify your question to ask about VCL, as you will get much wider audience. + "it is working fine with cmd ,VCL apps" - in those apps, do you call the DLL? Show us how.Martin Prikryl

1 Answers

2
votes

You shouldn't really try to call an external Form from within Inno Setup unless absolutely necessary. Inno is a very powerful setup tool that allows you to create custom Pages (Forms) using it's own script. I really encourage you to read very thoroughly Inno's help about custom pages, the process is very well documented. Having said that, here's a piece of code that might get you started:

[Code]

var
  UserInfoPage: TWizardPage;

procedure CreateCustomUserInfoPage;
begin
  UserInfoPage := CreateCustomPage(wpWelcome, 'User information', 'Please insert user information.');

  { First Name Field }

  FNLabel := TLabel.Create(UserInfoPage);
  with FNLabel do
  begin
    Caption := 'First Name:';
    Parent := UserInfoPage.Surface;
  end;

  FNEdit := TEdit.Create(UserInfoPage);
  with FNEdit do
  begin
    Top := FNLabel.Top + FNLabel.Height + 4;
    Width := (UserInfoPage.SurfaceWidth div 2) - 8;
    Parent := UserInfoPage.Surface;
    OnKeyPress := @FNEditOnKeyPress; // Just an event handler. If assigned, it should be implemented in the [code] section.
  end;

  { ...The rest of the fileds here... }

end;

procedure InitializeWizard;
begin
  CreateCustomUserInfoPage;
end;

You declare a global variable of type TWizardPage, implement a procedure of your own to render the form (like: CreateCustomUserInfoPage), inside this procedure you assign the value returned by the built-in function CreateCustomPage to the TWizardPage global variable, add some components to the form, and later on you call this procedure from within the InitializeWizard built-in proc.

This is just a small practical example, it gets more complex depending on what your needs are. But the software's help should cover pretty much anything. As for the DLLs, I only leave those for really intricate work that is not covered by the Inno Setup Pascal Scripting functionality. Hope it helped.