2016-11-08 63 views
0

如何添加文本旁边Play/Mute button旁边的按钮添加文本Inno Setup的

enter image description here

这里是我的脚本:

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; 

回答

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; 
+0

我应该把在'什么码......“对不起! – DDoS

+0

您的问题代码。 –

+1

唷!这是我第一次正确。我的头疼:)非常感谢你@马丁! – DDoS