合并来自不同来源的事件函数(InitializeWizard)实现 [英] Merging event function (InitializeWizard) implementations from different sources

查看:73
本文介绍了合并来自不同来源的事件函数(InitializeWizard)实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在组合所需的脚本,但是有错误.

I am now combining the script that I want but it has an error.

当我放置一个句号时,它将运行但缺少其他功能.

When I put a period, it will run but missing other feature.

这是我的代码:

procedure InitializeWizard;
begin
  MessageBoxTimeout(WizardForm.Handle, 'MsgBox ' +
    Timeout 'Setup', MB_OK or MB_ICONINFORMATION, 0, 2000);
end;

var
  TuneLabel: TLabel;

begin
  ExtractTemporaryFile('tune.xm');
  if BASS_Init(-1, 44100, 0, 0, 0) then
  begin
    SoundCtrlButton := TNewButton.Create(WizardForm);
    Music := BASS_MusicLoad(False, 
      ExpandConstant('{tmp}\tune.xm'), 0, 0, 
      EncodingFlag or BASS_SAMPLE_LOOP, 0);
    BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 10000);
    BASS_ChannelPlay(Music, False);

    SoundCtrlButton := TNewButton.Create(WizardForm);
    SoundCtrlButton.Parent := WizardForm;
    SoundCtrlButton.Left := 10;
    SoundCtrlButton.TabStop := False;
    SoundCtrlButton.Top := WizardForm.ClientHeight - 
      SoundCtrlButton.Height - 9;
    SoundCtrlButton.Width := 40;
    SoundCtrlButton.Caption :=
      ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
    SoundCtrlButton.OnClick := @SoundCtrlButtonClick;
    TuneLabel := TLabel.Create(WizardForm);
    TuneLabel.Parent := WizardForm;
    TuneLabel.Caption := 'Tune';
    TuneLabel.Left := SoundCtrlButton.Left + SoundCtrlButton.Width + ScaleX(5);
    TuneLabel.Top :=
      SoundCtrlButton.Top + ((SoundCtrlButton.Height - TuneLabel.Height) div 2);
  end;
end;

错误是指最后一个end;之后的一行.

The error refers to a line after the last end;.

请帮助我.

推荐答案

当您重复使用来自不同来源的各种功能实现时,通常会实现相同的

When you are reusing various feature implementations from different sources, those commonly implement the same Inno Setup event functions (like the InitializeWizard).

您必须合并这些事件函数,因为可能只有一个函数实现.

You have to merge these event functions as there can be just one function implementation.

Inno Setup 6具有事件属性功能有助于解决这个问题.

Inno Setup 6 has event attributes features that helps solving this problem.

只需确保您的每个事件实现都有一个唯一的名称,例如附加唯一的后缀.并在event属性中添加已实现事件的名称.

Just make sure that each of your event implementation have an unique name, e.g. appending unique suffix. And add event attribute with the name of the implemented event.

[Code]
procedure InitializeWizard;
begin
  Log('InitializeWizard called');
end;

<event('InitializeWizard')>
procedure InitializeWizard2;
begin
  Log('InitializeWizard2 called');
end;

Inno设置5

您可以通过将唯一的后缀添加到不同的实现中,而不是从主实现中调用它们来实现.

Inno Setup 5

You can do that by appending unique suffix to the different implementation and than calling them from a main implementation.

主要实现必须在其他实现之下.

The main implementation have to be below the other implementations.

例如,如果一个源具有实现为以下内容的InitializeWizard事件函数:

For example, if one source has InitializeWizard event function implemented as:

var
  GlobalVariable1: Integer;

procedure SubProcedure1;
begin
  { blah }
end;

procedure InitializeWizard;
var
  Variable1: Integer;
  Variable2: Integer;
begin
  Variable1 := GlobalVariable1;
  SubProcedure1;
end;

另一个来源为:

var
  GlobalVariableA: Integer;

procedure SubProcedureA;
begin
  { blah }
end;

procedure InitializeWizard;
var
  VariableA: Integer;
begin
  VariableA := GlobalVariableA;
  SubProcedureA;
end;

然后合并的代码应为:

var
  GlobalVariable1: Integer;

procedure SubProcedure1;
begin
  { blah }
end;

procedure InitializeWizard1;
var
  Variable1: Integer;
  Variable2: Integer;
begin
  Variable1 := GlobalVariable1;
  SubProcedure1;
end;

var
  GlobalVariableA: Integer;

procedure SubProcedureA;
begin
  { blah }
end;

procedure InitializeWizard2;
var
  VariableA: Integer;
begin
  VariableA := GlobalVariableA;
  SubProcedureA;
end;

procedure InitializeWizard;
begin
  InitializeWizard1;
  InitializeWizard2;
end;

另请参见 Inno设置-合并返回布尔值的事件函数的实现(例如InitializeSetup).

因此,在您的特定情况下,代码应为:

So, in your specific case the code should be:

procedure InitializeWizard1;
begin
  MessageBoxTimeout(WizardForm.Handle, 'MsgBox ' +
    Timeout 'Setup', MB_OK or MB_ICONINFORMATION, 0, 2000);
end;

procedure InitializeWizard2;
var
  TuneLabel: TLabel;
begin
  ExtractTemporaryFile('tune.xm');
  if BASS_Init(-1, 44100, 0, 0, 0) then
  begin
    SoundCtrlButton := TNewButton.Create(WizardForm);
    Music := BASS_MusicLoad(False, 
      ExpandConstant('{tmp}\tune.xm'), 0, 0, 
      EncodingFlag or BASS_SAMPLE_LOOP, 0);
    BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 10000);
    BASS_ChannelPlay(Music, False);

    SoundCtrlButton := TNewButton.Create(WizardForm);
    SoundCtrlButton.Parent := WizardForm;
    SoundCtrlButton.Left := 10;
    SoundCtrlButton.TabStop := False;
    SoundCtrlButton.Top := WizardForm.ClientHeight - 
      SoundCtrlButton.Height - 9;
    SoundCtrlButton.Width := 40;
    SoundCtrlButton.Caption :=
      ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
    SoundCtrlButton.OnClick := @SoundCtrlButtonClick;
    TuneLabel := TLabel.Create(WizardForm);
    TuneLabel.Parent := WizardForm;
    TuneLabel.Caption := 'Tune';
    TuneLabel.Left := SoundCtrlButton.Left + SoundCtrlButton.Width + ScaleX(5);
    TuneLabel.Top :=
      SoundCtrlButton.Top + ((SoundCtrlButton.Height - TuneLabel.Height) div 2);
  end;
end;

procedure InitializeWizard;
begin
  InitializeWizard1;
  InitializeWizard2;
end;


如果您使用的是Inno Setup Script #Includes(ISSI),请参见在使用ISSI时实现事件函数InitializeWizard(添加背景图像)在Inno设置中:重复的标识符'INITIALIZEWIZARD'.

这篇关于合并来自不同来源的事件函数(InitializeWizard)实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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