首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过DLL在Inno设置中显示用Delphi创建的FMX或VCL窗体?

问通过DLL在Inno设置中显示用Delphi创建的FMX或VCL窗体?
EN

Stack Overflow用户
提问于 2018-01-19 19:39:38
回答 1查看 306关注 0票数 0

我正在尝试使用dll在Inno设置中显示FMX表单。我创建了一个动态链接库并将表单添加到DLL.dll中。下面是dll中的代码:

代码语言:javascript
复制
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.

下面是inno的代码:

代码语言:javascript
复制
[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;

安装程序编译但未显示窗体,退出时未显示任何错误。

它在cmd,vcl应用程序上运行得很好,但在inno上就不行了。我使用下面的代码在cmd,vcl应用程序中显示来自dll的表单:

代码语言:javascript
复制
procedure ShowForm; stdcall; external 'DLL.dll';
...
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Free;
ShowForm;
end;
EN

回答 1

Stack Overflow用户

发布于 2018-01-20 02:35:51

除非绝对必要,否则您不应该尝试从Inno Setup中调用外部表单。Inno是一个非常强大的设置工具,它允许您使用自己的脚本创建自定义页面(表单)。我真的鼓励你仔细阅读Inno关于自定义页面的帮助,这个过程有很好的文档记录。话虽如此,这里有一段代码可能会让你入门:

代码语言:javascript
复制
[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;

声明一个TWizardPage类型的全局变量,实现一个自己的过程来呈现表单(如: CreateCustomUserInfoPage),在该过程中将内置函数CreateCustomPage返回的值赋给TWizardPage全局变量,向表单添加一些组件,然后从InitializeWizard内置过程中调用该过程。

这只是一个小的实际例子,它会变得更复杂,这取决于你的需求。但该软件的帮助应该涵盖几乎所有内容。至于DLL,我只把它们留给那些在Inno Setup Pascal脚本功能中没有涉及的非常复杂的工作。希望这能帮上忙。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48340276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档