Reputation: 381
How to add text next to Play / Mute button
Here's my script:
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;
Upvotes: 0
Views: 630
Reputation: 202128
The same way you are adding the button. Create a new control (TLabel
) and add it to the form by assigning the WizardForm
to the control's Parent
property.
A basic code to add a label is:
var
MyLabel: TLabel;
begin
MyLabel := TLabel.Create(WizardForm);
MyLabel.Parent := WizardForm;
MyLabel.Left := ...;
MyLabel.Top := ...;
MyLabel.Caption := '...';
end;
Putting it together without your code and positioning the label relatively to the button:
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;
Upvotes: 2