默认情况下,当您在 Inno Setup 中向页面添加 TEdit
时,高度为一行。
如何增加编辑的高度?
这是 ISS 文件的相关部分
ContractConfigPage := CreateInputQueryPage(ServerConfigPage.ID,
'Map contract as JSON', 'Please enter the map contract to use in JSON format', '');
ContractConfigPage.Add('JSON', False);
ContractConfigPage.Edits[0].Height := 100; { does not have any effect }
编辑:我现在可以进行更大的编辑,但不能有多行
ContractConfigPage := CreateInputQueryPage(ServerConfigPage.ID,
'Map contract as JSON', 'Please enter the map contract to use in JSON format', '');
ContractConfigPage.Add('JSON', False);
ContractConfigPage.Edits[0].AutoSize := False;
ContractConfigPage.Edits[0].Height := 100;
ContractConfigPage.Edits[0].Width := 100;
{ now the edit is bigger but I still can not have multiple lines }
最佳答案
您必须将 TPasswordEdit
替换为 TNewMemo
:
var
JsonMemo: TNewMemo;
procedure InitializeWizard();
var
ContractConfigPage: TInputQueryWizardPage;
JsonIndex: Integer;
JsonEdit: TCustomEdit;
begin
{ Create new page }
ContractConfigPage := CreateInputQueryPage(wpWelcome,
'Map contract as JSON', 'Please enter the map contract to use in JSON format', '');
{ Add TPasswordEdit. We use it only to have Inno Setup create the prompt label and }
{ to calculate the proper location of the edit control }
JsonIndex := ContractConfigPage.Add('JSON', False);
JsonEdit := ContractConfigPage.Edits[JsonIndex];
{ Create TNewMemo (multi line edit) on the same parent control and }
{ the same location (except for height) as the original single-line TPasswordEdit }
JsonMemo := TNewMemo.Create(WizardForm);
JsonMemo.Parent := JsonEdit.Parent;
JsonMemo.SetBounds(JsonEdit.Left, JsonEdit.Top, JsonEdit.Width, ScaleY(100));
{ Hide the original single-line edit }
JsonEdit.Visible := False;
{ Link the label to the new edit }
{ (has a practical effect only if there were a keyboard accelerator on the label) }
ContractConfigPage.PromptLabels[JsonIndex].FocusControl := JsonMemo;
end;
<小时/>
现在您无法使用 ContractConfigPage.Edits
访问 TNewMemo
及其值(它引用原始的[隐藏] TPasswordEdit
)。您必须使用全局 JsonMemo
变量。
您当然可以完全自己创建页面,使用 CreateCustomPage
从干净的页面开始。这可能是一个更干净的解决方案,但更费力。
关于installation - 在 Inno Setup 中由 CreateInputQueryPage 创建的页面上的多行编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32400937/