2015-09-04 125 views
2

默認情況下,當您將TEdit添加到Inno Setup中的頁面時,高度爲一行。Inno Setup中的多行編輯由CreateInputQueryPage創建的頁面

如何增加編輯的高度?

這裏是國際空間站的相關部分文件

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 } 
+1

該控件缺少ES_MULTILINE風格,這使得編輯控件mutiline。不幸的是,這種風格不能添加到控制沒有其再創造灰。你甚至不能用'TNewMemo'替代控件,因爲在處理輸入頁面項時,Inno Setup內部類型轉換爲'TPasswordEdit'類。所以剩下的就是丟掉這個東西,並且自己創建和處理一個'TNewMemo'控件。 – TLama

+0

「所以剩下的就是丟失這些東西,並自己創建和處理TNewMemo控件。」 =>你能解釋一下你的意思嗎,我不明白 –

+0

請看下面馬丁的回答。 – TLama

回答

1

你必須用TNewMemo代替TPasswordEdit

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一頁空白開始。這可能是一個更清潔的解決方案,但更加費力。

+0

我已經標記了您的答案,因爲它幫助了我很多,但我將提供一個乾淨的頁面的解決方案 –

1

下面是代碼,我終於用我的需求:

var 
ContractConfigPage: TWizardPage; 
ContractMemo: TNewMemo; 

然後在InitializeWizard:

ContractConfigPage := CreateCustomPage(ServerConfigPage.ID, 
    'Map contract as JSON', 'Please enter the map contract to use in JSON format WITHOUT DOUBLE QUOTES');  
ContractMemo := TNewMemo.Create(WizardForm); 
ContractMemo.Parent := ContractConfigPage.Surface; 
ContractMemo.SetBounds(0, 0, 410, 210); 
ContractMemo.ScrollBars := ssBoth; 
ContractMemo.WordWrap := False; 
ContractMemo.Text := '{'+#13#10+ 
' name:''map'''+#13#10+ 
'}'; 

請不就是我使用「」,而不是「,因爲該值的JSON內將進入xml所以這是更容易閱讀:)

+1

您應該更好地將備忘錄寬度與'ContractConfigPage.ClientWidth'關聯,並使用'ScaleY'爲高度。這是爲了使佈局在高DPI /大字體上正確縮放。 –