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

发布于 2024-11-15 05:02:59 字数 633 浏览 3 评论 0原文

我需要在运行时更改消息。我有一个 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;

I need to change Messages at runtime. I have a AfterInstall procedure that checks to see if a bat file was successful. If it is not, I want to change the value of ExitSetupMessage just before calling WizardForm.Close. I was hoping to do something like this english.ExitSetupMessage := 'THIS IS THE PART THAT DOES NOT WORK';. Code examples would be appreciated. Thank you.

[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;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吃素的狼 2024-11-22 05:02:59

我不知道如何在运行时更改消息。

但是,在您发布的情况下,我知道一个解决方法。您可以在调用 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;
以保留标题。

I don't know of a way to change the messages at runtime.

However in the case you posted I know of a workaround. You would set your CustomState before calling WizardForm.Close

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;

The side effect is you lose the Exit Setup? title of the dialog box.

You can use function ExitSetupMsgBox: Boolean; when you don't want to change the message
to keep the title around.

沧笙踏歌 2024-11-22 05:02:59

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

应该是

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

According to http://www.jrsoftware.org/ishelp/index.php?topic=scriptclasses

it should be

WizardForm.FinishedLabel.Caption := 'Desired text goes here';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文