答案 0 :(得分:2)
与添加按钮的方式相同。创建一个新控件(TLabel
),并将WizardForm
分配给控件的Parent
属性,将其添加到表单中。
添加标签的基本代码是:
var
MyLabel: TLabel;
begin
MyLabel := TLabel.Create(WizardForm);
MyLabel.Parent := WizardForm;
MyLabel.Left := ...;
MyLabel.Top := ...;
MyLabel.Caption := '...';
end;
在没有您的代码的情况下将它放在一起并将标签相对于按钮放置:
procedure InitializeWizard();
var
TuneLabel: TLabel;
begin
...
if ... then
begin
...
SoundCtrlButton := TNewButton.Create(WizardForm);
...
{ Creating a new TLabel control }
TuneLabel := TLabel.Create(WizardForm);
{ Adding it to the wizard form }
TuneLabel.Parent := WizardForm;
{ Setting caption }
TuneLabel.Caption := 'tune';
{ Aligning it to the right of the button }
TuneLabel.Left := SoundCtrlButton.Left + SoundCtrlButton.Width + ScaleX(8);
{ Vertically aligning it with the button }
{ Doing this only after the caption is set and the label is auto-sized. }
TuneLabel.Top :=
SoundCtrlButton.Top + ((SoundCtrlButton.Height - TuneLabel.Height) div 2);
end;
end;