Add text to 'Ready Page' in Inno Setup

五迷三道 提交于 2020-07-31 09:50:28

问题


I added few custom pages to my Installer. These pages gather some data from user and disk, and I'd like to show this data to user before final installation step starts. Inno Setup has 'Ready to Install' page exactly for this purpose.

How can I add text to this page? By default it shows to me:

Destination location:
  C:\Program Files\MyProgram

I'd like to append some text here. Is it possible?


回答1:


Found it ... http://www.innosetup.org/ishelp/topic_scriptevents.htm:

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;

If Setup finds the UpdateReadyMemo event function in the Pascal script, it is called automatically when the Ready to Install wizard page becomes the active page. It should return the text to be displayed in the settings memo on the Ready to Install wizard page as a single string with lines separated by the NewLine parameter. Parameter Space contains a string with spaces. Setup uses this string to indent settings. The other parameters contain the (possibly empty) strings that Setup would have used as the setting sections. The MemoDirInfo parameter for example contains the string for the Selected Directory section.




回答2:


Alter the following code:

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpReady then
  begin
    Wizardform.ReadyMemo.Lines.Add(''); { Empty string }
    Wizardform.ReadyMemo.Lines.Add('Setup HP-UX test created by Armand');
  end;
end;



回答3:


You can hook into the setup process of the ReadyMemo WizardPage using this function:

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;

If Setup finds the UpdateReadyMemo event function in the Pascal script, it is called automatically when the Ready to Install wizard page becomes the active page. It should return the text to be displayed in the settings memo on the Ready to Install wizard page as a single string with lines separated by the NewLine parameter. Parameter Space contains a string with spaces. Setup uses this string to indent settings. The other parameters contain the (possibly empty) strings that Setup would have used as the setting sections. The MemoDirInfo parameter for example contains the string for the Selected Directory section.

Official docs at: http://www.innosetup.org/ishelp/topic_scriptevents.htm

Here is a simple example implementation that adds a single line to the default content of the ReadyMemo:

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
begin
    Result := ''

    if MemoUserInfoInfo <> '' then begin
        Result := MemoUserInfoInfo + Newline + NewLine;
    end;
    if MemoDirInfo <> '' then begin
        Result := Result + MemoDirInfo + Newline + NewLine;
    end;
    if MemoTypeInfo <> '' then begin
        Result := Result + MemoTypeInfo + Newline + NewLine;
    end;
    if MemoComponentsInfo <> '' then begin
        Result := Result + MemoComponentsInfo + Newline + NewLine;
    end;
    if MemoGroupInfo <> '' then begin
        Result := Result + MemoGroupInfo + Newline + NewLine;
    end;
    if MemoTasksInfo <> '' then begin
        Result := Result + MemoTasksInfo + Newline + NewLine;
    end;

    Result := Result + 'My custom string';
end;

For your information: I tried adding this code to the accepted answer, but it got declined and I was told to write a comment or a new answer.




回答4:


Also, if you just want to change the pre-existing messages to something less generic, you can change them in your [Messages] section:

i.e.

[Messages]
ReadyMemoDir=Server location:

The default messages are:

  • WizardReady
  • ReadyLabel1
  • ReadyLabel2a
  • ReadyLabel2b
  • ReadyMemoUserInfo
  • ReadyMemoDir
  • ReadyMemoType
  • ReadyMemoComponents
  • ReadyMemoGroup
  • ReadyMemoTasks



回答5:


As the existing answers show already, implement UpdateReadyMemo event function.

Implementing the function requires reimplementing an assembly of the default memo contents. Below is a less repetitive way to implement that.

procedure AddToReadyMemo(var Memo: string; Info, NewLine: string);
begin
  if Info <> '' then Memo := Memo + Info + Newline + NewLine;
end;

function UpdateReadyMemo(
  Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo,
  MemoGroupInfo, MemoTasksInfo: String): String;
begin
  AddToReadyMemo(Result, MemoUserInfoInfo, NewLine);
  AddToReadyMemo(Result, MemoDirInfo, NewLine);
  AddToReadyMemo(Result, MemoTypeInfo, NewLine);
  AddToReadyMemo(Result, MemoComponentsInfo, NewLine);
  AddToReadyMemo(Result, MemoGroupInfo, NewLine);
  AddToReadyMemo(Result, MemoTasksInfo, NewLine);

  Result := Result + 'Additional custom information';
end;



来源:https://stackoverflow.com/questions/1218411/add-text-to-ready-page-in-inno-setup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!