Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   delphi TadvGlowbutton Click (https://www.delphipraxis.net/182346-delphi-tadvglowbutton-click.html)

drama22 18. Okt 2014 03:37

delphi TadvGlowbutton Click
 
i am about to understand how to show a form on click and hide it on click on the same button again

here is how i show the form

Delphi-Quellcode:
procedure TMAIN.btnVolClick(Sender: TObject);
var
  Rect: TRect;
  volfrm : Tvolfrm;
begin
volfrm := Tvolfrm.Create(nil);
try
  GetWindowRect(btnVol.Handle, Rect);
  if not Assigned(volfrm) then
  begin
    volfrm:= Tvolfrm.CreateParented(0);
    volfrm.FormStyle := fsStayOnTop;
  end;

  volfrm.Left := Rect.Left;
  volfrm.top := Rect.Top - volfrm.Height;
finally
volfrm.Show;
end;
end;
how to hide the for again on click the same button

Real_Thunder 12. Nov 2014 18:18

AW: delphi TadvGlowbutton Click
 
There are a few ways to do so.

it depends on ..... do you just wanna Show and hide ? or do you want to create and destroy on button click =

DeddyH 12. Nov 2014 19:50

AW: delphi TadvGlowbutton Click
 
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;

drama22 13. Nov 2014 00:28

AW: delphi TadvGlowbutton Click
 
Thanks thats helps alot


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:10 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz