Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#12

AW: Komponente umstellen

  Alt 23. Jan 2016, 16:50
Delphi-Quellcode:
procedure TAudioVolume.SetAppVolume(Value: boolean);
begin
  if Value = FAppVolume then
    exit;

  FAppVolume := Value;
  if not FAppVolume then
     SetComponents;
end;
oder so ähnlich. AfterConstruction wäre auch noch eine Möglichkeit, aber das wird IIRC nicht immer ausgeführt (es sei denn, ich werfe da gerade etwas durcheinander).
Das Problem ist nicht das erstellen der Components sondern das auswerten des Flag FAppVolume.
Ich komme zu spät in den Setter das ist ja mein Problem.

Delphi-Quellcode:
procedure TAudioVolume.SetAppVolume(Value: boolean);
begin

  if Value = FAppVolume then
    exit;

  FAppVolume := Value;

  if FAppVolume then
  begin
    FGroupBox.Caption := 'Application';
    pbAppMeter := TProgressBar.Create(self);
    pbAppMeter.Parent := FGroupBox.Parent;
    pbAppMeter.Orientation := pbVertical;
    pbAppMeter.Max := 100;
    pbAppMeter.Min := 0;
    pbAppMeter.Smooth := true;

    lblAppPeak := TLabel.Create(self);
    lblAppPeak.Parent := FGroupBox.Parent;
    lblAppPeak.Caption := 'M';

    pbAppMeterL := TProgressBar.Create(self);
    pbAppMeterL.Parent := FGroupBox.Parent;
    pbAppMeterL.Orientation := pbVertical;
    pbAppMeterL.Max := 100;
    pbAppMeterL.Min := 0;
    pbAppMeterL.Smooth := true;

    lblAppPeakL := TLabel.Create(self);
    lblAppPeakL.Parent := FGroupBox.Parent;
    lblAppPeakL.Caption := 'L';

    tbAppVolume := TTrackBar.Create(self);
    tbAppVolume.Parent := FGroupBox.Parent;
    tbAppVolume.Orientation := trVertical;
    tbAppVolume.Max := 32;
    tbAppVolume.Min := 0;
    tbAppVolume.TickStyle := tsAuto;
    tbAppVolume.Frequency := 3;
    tbAppVolume.Position := 0;

    cbAppMute := TCheckbox.Create(self);
    cbAppMute.Parent := FGroupBox.Parent;
    cbAppMute.Caption := 'Mute';

    pbAppMeterR := TProgressBar.Create(self);
    pbAppMeterR.Parent := FGroupBox.Parent;
    pbAppMeterR.Orientation := pbVertical;
    pbAppMeterR.Max := 100;
    pbAppMeterR.Min := 0;
    pbAppMeterR.Smooth := true;

    lblAppPeakR := TLabel.Create(self);
    lblAppPeakR.Parent := FGroupBox.Parent;
    lblAppPeakR.Caption := 'R';

    tbAppVolume.Position := round((1.0 - GetVolume) * tbAppVolume.Max);
    tbAppVolume.OnChange := tbAppVolumeChange;
    cbAppMute.Checked := IsMuted;
    cbAppMute.OnClick := cbAppMuteClick;
    PostMessage(Handle, WM_SIZE, 0, 0);
  end;

end;
Ich bekomme erst ein True nachdem ich Create hinter mir gelassen habe.
Das ist aber zu spät.

Angenommen das Teil liegt schon auf der Form und ich ändere dann den Status über die Property AppVolume
dann müsste sich die Componente anhand der im Setter eingestellten werte ändern.
Tut es aber nicht so wie es soll.


gruss

Geändert von EWeiss (23. Jan 2016 um 16:55 Uhr)
  Mit Zitat antworten Zitat