如何将DLL中的表单嵌入到Inno Setup向导页面中? [英] How to embed a form from a DLL into an Inno Setup wizard page?

查看:163
本文介绍了如何将DLL中的表单嵌入到Inno Setup向导页面中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Delphi DLL中构建了一些VCL表单,它在Inno Setup安装过程中显示。但是,如果我可以将这些表单嵌入到Inno Setup向导中,那将会更为简洁。

I've built some VCL forms in Delphi DLL's which show during the Inno Setup installation. However, it would be much more concise if I could embed these forms into the Inno Setup wizard.

我该怎么做?

推荐答案

最简单的方法是创建一个导出的函数,它将完成库中的所有内容。这种功能的必要最小值是用于嵌入表单的Inno Setup控件的句柄的参数。下一个必要的事情你需要知道嵌入是有限的,但是你可以通过Windows API函数调用库边。

The simplest way for you will be to create an exported function which will do all the stuff in your library. The necessary minimum for such function is a 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 embedding are bounds, but those you can get with the Windows API function call on the library side.

这是Delphi部分显示单元与您的DLL项目的形式:

Here is the Delphi part showing the unit 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.

这里是Inno安装脚本:

And here is the Inno Setup 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;






只需要注意,Inno Setup也支持 COM Automation ,所以上述方法不是唯一的选项如何嵌入一个对象进入向导形式。但是,这是最简单的一个。


Just to note, Inno Setup supports also COM Automation, so the above way is not the only option how to embed an object into the wizard form. However, it's the simplest one.

哦,还有一个注释,这可能对你有所帮助。如果您需要从库中执行某个Inno Setup脚本代码,您可以通过在Inno安装方面进行回调函数,并在DLL端传递和执行它。

Oh, and yet one note, which might be good for you to know. If you'd ever need to execute a certain Inno Setup script code from your library, you could do it by making a callback function on the Inno Setup side and passing and executing it on the DLL side.

这篇关于如何将DLL中的表单嵌入到Inno Setup向导页面中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆