【问题标题】:Add text next to button in Inno Setup在 Inno Setup 中的按钮旁边添加文本
【发布时间】:2020-04-06 15:04:58
【问题描述】:

如何在Play / Mute button旁边添加文字

这是我的脚本:

procedure InitializeWizard;
begin
  ExtractTemporaryFile('tune.xm');
  if BASS_Init(-1, 44100, 0, 0, 0) then
  begin
    SoundStream := BASS_StreamCreateFile(False, 
      ExpandConstant('{tmp}\tune.xm'), 0, 0, 0, 0, 
      EncodingFlag or BASS_SAMPLE_LOOP);
    BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);
    BASS_ChannelPlay(SoundStream, False);

    SoundCtrlButton := TNewButton.Create(WizardForm);
    SoundCtrlButton.Parent := WizardForm;
    SoundCtrlButton.Left := 8;
    SoundCtrlButton.Top := WizardForm.ClientHeight - 
      SoundCtrlButton.Height - 8;
    SoundCtrlButton.Width := 40;
    SoundCtrlButton.Caption :=
      ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
    SoundCtrlButton.OnClick := @SoundCtrlButtonClick;
  end;
end;

【问题讨论】:

    标签: inno-setup


    【解决方案1】:

    添加按钮的方式相同。创建一个新控件 (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;
    

    【讨论】:

    • 呸!我第一次做对了。我头疼:) 非常感谢@martin!
    猜你喜欢
    • 2016-08-01
    • 2013-10-01
    • 2023-03-27
    • 2021-08-14
    • 1970-01-01
    • 2013-09-16
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多