【问题标题】:How to align the typing to the center in the UserInfoPage?如何将输入对齐到 UserInfoPage 的中心?
【发布时间】:2017-08-27 01:46:16
【问题描述】:

正如问题所说,我想从中心开始打字,而不是从左边开始。

短代码值:

with WizardForm.UserInfoNameEdit do
  begin
    Left := ScaleX(104);
    Top := ScaleY(182);
    Width := ScaleX(233);
    Height := ScaleY(31);
    Font.Height := -19;
    MaxLength := 30;
    ParentFont := False;
  end;

这里有一些图片:

【问题讨论】:

  • 不,这是不可能的。对我来说,这似乎是个糟糕的主意。
  • 这就是我所说的糟糕想法的意思。遵循 Windows GUI 风格。不要自己发明。

标签: inno-setup pascalscript


【解决方案1】:

根据您的第三张图片,您可以使用自定义表单并将控件放置在表单的中心。

function CreateMyCustomUserDialog(): Boolean; 
var
   Form: TSetupForm;
   OKButton, CancelButton: TNewButton;
   Label1: TLabel;
   Edit1: TEdit;
begin
  Form := CreateCustomForm();
  try
    Form.ClientWidth := ScaleX(256);
    Form.ClientHeight := ScaleY(256);
    Form.Caption := 'User Information';
    Form.CenterInsideControl(WizardForm, true);

    OKButton := TNewButton.Create(Form);
    OKButton.Parent := Form;
    OKButton.Width := ScaleX(75);
    OKButton.Height := ScaleY(23);
    OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
    OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
    OKButton.Caption := 'OK';
    OKButton.ModalResult := mrOk;

    Label1 := TLabel.Create(Form);
    Label1.Parent := Form;
    Label1.Alignment := taCenter;
    Label1.Caption := 'Username:';
    Label1.Width := Form.ClientWidth;
    Label1.Height := ScaleY(23);    
    Label1.Top := 30;    

    Edit1 := TEdit.Create(Form);
    Edit1.Parent := Form;
    Edit1.Top := 50;
    Edit1.Width := 100;
    Edit1.Left := (Form.ClientWidth -  Edit1.Width) / 2;
    Edit1.Text := 'Admin';           

    CancelButton := TNewButton.Create(Form);
    CancelButton.Parent := Form;
    CancelButton.Width := ScaleX(75);
    CancelButton.Height := ScaleY(23);
    CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
    CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
    CancelButton.Caption := 'Cancel';
    CancelButton.ModalResult := mrCancel;
    CancelButton.Cancel := True;

    Form.ActiveControl := OKButton;

    if Form.ShowModal() = mrOk then
      MsgBox('You clicked OK.', mbInformation, MB_OK);
  finally
    Form.Free();
  end;
end;

【讨论】:

  • 您的代码不完整。但是我看到你正在使用 WizardForm.UserInfoPage;作为父窗体。所以你为什么不在你想要居中的控件上尝试类似的东西。 Left := (WizardForm.UserInfoPage.ClientWidth - Width) / 2;
猜你喜欢
  • 2022-01-26
  • 2019-05-25
  • 1970-01-01
  • 2013-12-08
  • 1970-01-01
  • 2015-12-01
  • 2010-12-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多