【问题标题】:Inno Setup: How to change Messages at runtime?Inno Setup:如何在运行时更改消息?
【发布时间】:2011-06-14 19:13:36
【问题描述】:

我需要在运行时更改消息。我有一个 AfterInstall 程序,用于检查 bat 文件是否成功。如果不是,我想在调用 WizardForm.Close 之前更改 ExitSetupMessage 的值。我希望做这样的事情 english.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;

【问题讨论】:

    标签: installation inno-setup pascal


    【解决方案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; 保留标题。

    【讨论】:

    • 这正是我想要的。谢谢。
    【解决方案2】:

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

    应该是

    WizardForm.FinishedLabel.Caption := 'Desired text goes here';
    

    【讨论】:

      猜你喜欢
      • 2012-03-05
      • 2016-06-23
      • 1970-01-01
      • 2011-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多