0

I do not know how to call an interactive panel of tools like TeamViewer has. My question is very objective: How can I create a interactive panel where the panel will hide/show at any moment?

Example: enter image description here


EDIT:

I found a possible solution (code below). Now I want to insert a "Button" glued on the right side and below Panel. How can I make this?

procedure TForm1.btn1Click(Sender: TObject);
begin
  AnimateWindow(Panel1.Handle, 800, AW_SLIDE or AW_VER_NEGATIVE or AW_HIDE);
end;

procedure TForm1.btn2Click(Sender: TObject);
begin
  AnimateWindow(Panel1.Handle, 800, AW_SLIDE or AW_VER_POSITIVE or AW_ACTIVATE);
end;
Greg Bishop
  • 517
  • 1
  • 5
  • 16
  • - *" .. how call .. "* - Probably a toolbar, or a panel. – Sertac Akyuz May 05 '18 at 00:32
  • @SertacAkyuz, yes a "toolbar" floating, not static with reserved place on Form, of way that if hide will stay a empty space on Form. –  May 05 '18 at 00:35

2 Answers2

1
type
  TForm1 = class(TForm)
    pnl1: TPanel;
    btn1: TButton;
    procedure btn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
begin
    if btn1.Caption = 'H' then
    begin
      btn1.Top := 0;
      btn1.Caption := 'S';
      AnimateWindow(Pnl1.Handle, 400, AW_SLIDE or AW_VER_NEGATIVE or AW_HIDE);
    end
    else
    begin
      btn1.Top:= pnl1.Height;
      btn1.Caption := 'H';
      AnimateWindow(Pnl1.Handle, 400, AW_SLIDE or AW_VER_POSITIVE or AW_ACTIVATE);
    end;
end;

end.

This was my solution:

I'm still using AnimateWindow api.

  • On Button properties, set right = 0
  • When Panel is visible, the Button have top := Panel.Height
  • By last, when Panel is no-visible (hidden), Button have top := 0
  • This has actually inspired me to start writing a custom control for this purpose. I'm calling it a `TFloatBar`. The trick is setting the non-client area, so controls can align properly, while leaving room for a button. – Jerry Dodge May 05 '18 at 20:38
-2

Try this:

unit NP;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TMainFrm = class(TForm)
    Timer1: TTimer;
    Timer2: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);            
  private

  public

  end;

var
  MainFrm: TMainFrm;

  Range: integer;

implementation

{$R *.dfm}

procedure TMainFrm.FormCreate(Sender: TObject);
begin
  Width := 255;
  Height := Screen.Height;
  Left := 0 - Width;
  Top := 0;
  Range := 0;
  Timer1.Enabled := True;
  Timer2.Enabled := True;
  MainFrm.Show;
end;

procedure TMainFrm.Timer1Timer(Sender: TObject);
var
  pos: TPoint;
begin
  GetCursorPos(pos);
  if (pos.X < 10) and (MainFrm.Left < 0) then
  begin
    Range := 20;
    MainFrm.Show;
  end;
  if (Range <> 0) then
    MainFrm.Left := MainFrm.Left + Range;
  if MainFrm.Left < 0 - MainFrm.Width then
  begin
    Range := 0;
    MainFrm.Left := 0 - MainFrm.Width;
    MainFrm.Hide;
  end;
  if (Range = 20) and (MainFrm.Left >= 0) then
  begin
    Range := 0;
    MainFrm.Left := 0;
  end;
end;

procedure TMainFrm.Timer2Timer(Sender: TObject);
var
  pos: TPoint;
begin
  GetCursorPos(pos);
  if pos.X > MainFrm.Width then
    Range := -20;
end;

end.

Axel

Axel L.
  • 1
  • 2
  • 4
    This dioes not even closely answer the question. And even if it did, it is a code-only answer, without any explanation or otherwise helpful text. This is an answer that must be downvoted, even if that means being "riude" to newcomers. – Rudy Velthuis May 05 '18 at 10:31
  • Hmmm... I meant "rude". Should have put on my glasses first. – Rudy Velthuis May 05 '18 at 11:03
  • @RudyVelthuis, i already have half of answer, see my edition :-) –  May 05 '18 at 11:09
  • @KKK: Indeed. You already posted how to animate the toolbar (and that is probably a lot smoother and better looking than the "answer" above). You just want to know how to add the extra panel on the right. – Rudy Velthuis May 05 '18 at 11:13
  • @RudyVelthuis, i need know how make [**this part**](http://prntscr.com/je15uq), insert something to right and below panel that when panel is hidden this thing is visible, to after show panel again through this (exactly like is in Team View). –  May 05 '18 at 11:18
  • Sorry, I didn't have time for a long explanation. The example shows how to simulate the display or hiding with the mouse position. Now it's up to you to build what you need from this code. – Axel L. May 05 '18 at 17:37
  • @Axel: on my two-display setup, that only moved the form **to the right onto the other screen**. Certainly not what was asked, especially since for the toolbar, he already gave a much better solution himself. – Rudy Velthuis May 07 '18 at 06:19