Einzelnen Beitrag anzeigen

Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.542 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: delphi TadvGlowbutton Click

  Alt 12. Nov 2014, 19:50
This is one of several ways (still quite dirty):
Delphi-Quellcode:
type
  TMAIN = class(TForm)
  private
    FOtherFormVisible: Boolean;
    FVolFrm: TVolFrm;
    procedure SetOtherFormVisible(Value: Boolean);
    function GetVolFrm: TVolFrm;
    property OtherFormVisible: Boolean read FOtherFormVisible write SetOtherFormVisible;
    property VolFrm: TVolFrm read GetVolFrm;
    ...
  end;
  
...

procedure TMAIN.SetOtherFormVisible(Value: Boolean);
begin
  FOtherFormVisible := Value;
  if FOtherFormVisible then
    (* Using the property, not the private field due to lazy initialization *)
    VolFrm.ProceedShowCode
  else
    VolFrm.ProceedHideCode;
end;

function TMAIN.GetVolFrm: TVolFrm;
begin
  if not Assigned(FVolFrm) then
    FVolFrm := TVolFrm.Create(nil);
  Result := FVolFrm;
end;

(* Click-Code left *)
procedure TMAIN.btnVolClick(Sender: TObject);
begin
  (* Accessing the property to call its Setter *)
  OtherFormVisible := not OtherFormVisible;
end;
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat