inno-setup – 合并来自不同来源的事件函数(InitializeWizard)实现

前端之家收集整理的这篇文章主要介绍了inno-setup – 合并来自不同来源的事件函数(InitializeWizard)实现前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我现在正在组合我想要的脚本,但它有一个错误.

当我放一段时间时,它会运行但缺少其他功能.

这是我的代码

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

var
  TuneLabel: TLabel;

begin
  ExtractTemporaryFile('tune.xm');
  if BASS_Init(-1,44100,0) then
  begin
    SoundCtrlButton := TNewButton.Create(WizardForm);
    Music := BASS_MusicLoad(False,ExpandConstant('{tmp}\tune.xm'),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;

错误是指最后一个结束后的一行;

请帮帮我.

解决方法

当您重用不同来源的各种功能实现时,通常会实现相同的 Inno Setup event functions(如InitializeWizard).

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

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

主要实现必须低于其他实现.

例如,如果一个源具有InitializeWizard事件函数,则实现为:

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 Setup – Merging implementations of event functions that return boolean (like InitializeSetup).

因此,在您的具体情况下,代码应该是:

procedure InitializeWizard1;
begin
  MessageBoxTimeout(WizardForm.Handle,2000);
end;

procedure InitializeWizard2;
var
  TuneLabel: TLabel;
begin
  ExtractTemporaryFile('tune.xm');
  if BASS_Init(-1,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;
原文链接:/delphi/102980.html

猜你在找的Delphi相关文章