Recent

Author Topic: [SOLVED] Bottom sliding panel  (Read 509 times)

Pe3s

  • Hero Member
  • *****
  • Posts: 533
[SOLVED] Bottom sliding panel
« on: August 13, 2022, 08:27:15 pm »
Hello forum members, I wonder how to program the sliding panel from the bottom of the form. we hover the mouse, the panel leaves, we take the mouse, the panel is hiding. how to go about it?
« Last Edit: August 13, 2022, 09:29:13 pm by Pe3s »

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Bottom sliding panel
« Reply #1 on: August 13, 2022, 09:03:41 pm »
Done.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, ExtCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Panel1: TPanel;
  16.     Timer1: TTimer;
  17.     procedure FormCreate(Sender: TObject);
  18.     procedure Timer1Timer(Sender: TObject);
  19.   end;
  20.  
  21. var
  22.   Form1: TForm1;
  23.  
  24. implementation
  25.  
  26. {$R *.lfm}
  27.  
  28. { TForm1 }
  29.  
  30. procedure TForm1.FormCreate(Sender: TObject);
  31. begin
  32.   Constraints.MinHeight := Height;
  33.   Constraints.MaxHeight := Height;
  34.   Constraints.MinWidth  := Width;
  35.   Constraints.MaxWidth  := Width;
  36.   Panel1.Top            := Form1.Top + Form1.Height;
  37.   Panel1.Left           := 0;
  38.   Panel1.Width          := Form1.Width - 1;
  39.   Panel1.BevelInner     := bvLowered;
  40.   Timer1.Interval       := 20;
  41. end;
  42.  
  43. procedure TForm1.Timer1Timer(Sender: TObject);
  44. begin
  45.   case ScreenToClient(Mouse.CursorPos).Y > Height -20 of
  46.     True:
  47.       begin
  48.         if Panel1.Top > Form1.Height - Panel1.Height - 1 then
  49.           Panel1.Top := Panel1.Top - 5;
  50.         if Panel1.Top < Form1.Height - Panel1.Height then
  51.           Panel1.Top := Form1.Height - Panel1.Height - 1;
  52.       end;
  53.     False:
  54.       begin
  55.         if Panel1.Top < Form1.Height then
  56.           Panel1.Top := Panel1.Top + 5;
  57.       end;
  58.   end;
  59. end;
  60.  
  61. end.

Tested on Linux only.

Pe3s

  • Hero Member
  • *****
  • Posts: 533
Re: Bottom sliding panel
« Reply #2 on: August 13, 2022, 09:28:12 pm »
@Handoko Great, thanks a lot  :) :) :) :) :)

 

TinyPortal © 2005-2018