InnoSetup: How to add line break into component de

2019-06-15 16:23发布

问题:

I am trying to add a line break in the middle of my description for my components. But I can't seem to find the proper syntax for it.

[Components]
Name: Component A; Description: "This is component A:" + NewLine + "My component A has this stuff";

回答1:

Line breaks are not supported for [Components] section entries, but you can modify your component item descriptions from code (unfortunately, access to the property, which stores a description is indexed and there is no way to find an index by the component name).

This example shows how to modify the first component item's description (indexing is 0 based), and how to add a line break to it:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Components]
Name: "app"; Description: "Description is changed in [Code] section"
Name: "readme"; Description: "Readme File"

[Code]
procedure InitializeWizard;
begin
  WizardForm.ComponentsList.ItemCaption[0] :=
    'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id venenatis' + #13#10 +
    'erat, ac vehicula sapien. Etiam convallis ligula eros, in ullamcorper turpis' + #13#10 +
    'pulvinar sit amet.';
end;


回答2:

For the component description you can define a custom message where you can specify line breaks by the %n tags, e.g.:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[CustomMessages]
ComponentDescription=Lorem ipsum dolor sit amet,%nconsectetur adipiscing elit.

[Components]
Name: "app"; Description: "{cm:ComponentDescription}"
Name: "readme"; Description: "Readme File"


标签: inno-setup