inno-setup – 合并来自不同来源的事件函数(InitializeWizard)实
发布时间:2020-12-15 10:06:16 所属栏目:大数据 来源:网络整理
导读:我现在正在组合我想要的脚本,但它有一个错误. 当我放一段时间时,它会运行但缺少其他功能. 这是我的代码: procedure InitializeWizard;begin MessageBoxTimeout(WizardForm.Handle,'MsgBox ' + Timeout 'Setup',MB_OK or MB_ICONINFORMATION,2000);end;var T
|
我现在正在组合我想要的脚本,但它有一个错误.
当我放一段时间时,它会运行但缺少其他功能. 这是我的代码: 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;
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
