本文介绍了由CreateInputQueryPage创建的页面上的Inno Setup中的多行编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,当在Inno Setup中将TEdit添加到页面时,高度为一行.

By default, when you add a TEdit to a page in Inno Setup, the height is one line.

如何增加编辑的高度?

这是ISS文件的相关部分

Here is the relevant part of the ISS file

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 }

我现在可以进行更大的编辑,但不能有多行

I am now able to have a bigger edit but I can not have multiple lines

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变量.


Now you cannot use ContractConfigPage.Edits to access the TNewMemo and its value (it references the original [hidden] TPasswordEdit). You have to use the global JsonMemo variable.

您当然可以完全自己创建页面,使用CreateCustomPage从干净的页面开始.这可能是一个更干净的解决方案,但更麻烦.

You can of course create the page completely yourself, starting from a clean page using CreateCustomPage. It might be a cleaner solution, but more laborious.

这篇关于由CreateInputQueryPage创建的页面上的Inno Setup中的多行编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 05:38