在不使用全局变量的情况下从自定义Inno Setup向导页面读取值 [英] Reading values from custom Inno Setup wizard pages without using global variables

查看:178
本文介绍了在不使用全局变量的情况下从自定义Inno Setup向导页面读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此支持页面上,用于创建自定义 CreateInputOptionPage ,他们建议通过将页面值分配给变量来存储页面值.尚不清楚何时应执行此分配.'

On this support page for creating a custom CreateInputOptionPage, they suggest storing the values of the page by just assigning them to a variable. It's not clear however WHEN this assignment should happen.'

据我所知,如果在创建页面时分配此权限,则将获得默认值.这很有意义,因为在创建页面时,用户尚未输入任何输入查询".

From what I can tell, if you assign this right when you create the page, you will get the default value. This makes sense as when the page is created, user hasn't input any "Input Query"'s yet.

因此,我有理由使用function NextButtonClick(CurPageID: Integer): Boolean;

为此,我需要在NextButtonClick函数中访问页面的变量(Page.Values[0]).由于Page是在其他函数中定义的,因此访问这些值以使Page成为全局变量的唯一方法是吗?这就是我决心要做的,但是我想知道是否有人可以替代全局变量.

In order to do that, I needed to access the page's variable (Page.Values[0]) in the NextButtonClick function. Since Page was defined in a different function, is the only way to access those values to have Page be a global variable? That's what I've resolved to do but I was wondering if anyone out there had an alternative to global variables.

到目前为止我的代码存根.

Stub of my code so far.

[Code]

var
  Page: TInputOptionWizardPage;
  InstallationTypeIsClient: boolean;

procedure InitializeWizard();
begin
  Page := CreateInputOptionPage(wpWelcome,'Installation Type', 'Select Installation Type', 'No really, do some selecting', True, False)
  Page.Add('Server Install');
  Page.Add('Client Install');
  Page.Values[1] := True;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID=100 then
  begin
    InstallationTypeIsClient := Page.Values[1];
    MsgBox('InstallationTypeIsClient value is ' + Format('%d', [InstallationTypeIsClient]), mbInformation, MB_OK);
  end;
  Result := True;
end;

推荐答案

使用全局变量存储对自定义页面的引用是正确且最简单的方法.

Using a global variable to store the reference to the custom page is the correct and the easiest way.

相关问题: Inno设置:从另一个控件的OnClick事件访问自定义控件

尽管您是否确实需要将用户值存储到另一个变量中值得怀疑.只需在需要时从自定义页面中读取值即可.

使用全局变量确实很普遍.但这就是在开发独立代码时.在这种情况下,您只是为现有应用程序实现事件挂钩,因此您别无选择.

唯一的其他方法是在WizardForm的子控件中递归查找自定义页面.它的代码很多,效率也很低.

The only other way is to recursively lookup the custom page in child controls of the WizardForm. It's lot of code and quite inefficient.

有关递归组件迭代的示例,请参见我对 Inno Setup:OnHover事件的回答.

See my answer to Inno Setup: OnHover event for an example of recursive component iteration.

这篇关于在不使用全局变量的情况下从自定义Inno Setup向导页面读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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