Inno Setup:如何在运行时更改消息?

时间:2011-06-14 19:13:37

标签: installer inno-setup pascal

我需要在运行时更改Messages。我有一个AfterInstall过程,检查bat文件是否成功。如果不是,我想在调用WizardForm.Close之前更改ExitSetupMessage的值。我本来希望做这样的事情.ExitSetupMessage:='这是不工作的部分';代码示例将不胜感激。谢谢。

[Languages]
Name: english; MessagesFile: compiler:Default.isl

[Files]
Source: {src}\test.bat; DestDir: {tmp}; AfterInstall: ValidateInstall

[Code]
procedure ValidateInstall();
var
  ResultCode : Integer;
begin
  if not Exec(ExpandConstant('{tmp}\test.bat'), '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
  begin
      english.ExitSetupMessage := 'THIS IS THE PART THAT DOES NOT WORK';
      WizardForm.Close;
  end;
end;

2 个答案:

答案 0 :(得分:1)

我不知道在运行时更改消息的方法。

然而,在您发布的情况下,我知道一种解决方法。您可以在调用WizardForm.Close

之前设置CustomState
var
  CustomState : Boolean;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
var
 Msg : String;
 Res : Integer;
begin
 Confirm := False; // Don't show the default dialog.

 // Chose which message the custom or default message.
 if CustomState then
    Msg := 'My Custom Close Message'
 else
    Msg := SetupMessage(msgExitSetupMessage);

 //as the Question
 Res := MsgBox(Msg, mbConfirmation,MB_OKCANCEL);

 // If they press OK then Cancel the install
 Cancel := (Res = IDOK);

end;

副作用是你丢失了对话框的Exit Setup?标题。

如果您不想更改消息,可以使用function ExitSetupMsgBox: Boolean; 保持标题。

答案 1 :(得分:0)

根据http://www.jrsoftware.org/ishelp/index.php?topic=scriptclasses

应该是

WizardForm.FinishedLabel.Caption := 'Desired text goes here';
相关问题