Как создать интерактивную панель параметров, аналогичную TeamViewer (скрыть / показать)? - PullRequest
0 голосов
/ 05 мая 2018

Я не знаю, как вызвать интерактивную панель инструментов, как в TeamViewer. Мой вопрос очень объективен: как я могу создать интерактивную панель, где панель будет скрываться / показываться в любой момент?

Пример: enter image description here


EDIT:

Я нашел возможное решение (код ниже). Теперь я хочу вставить «Button», приклеенный справа и ниже Panel. Как я могу это сделать?

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;

Ответы [ 2 ]

0 голосов
/ 05 мая 2018
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.

Это было мое решение:

Я все еще использую AnimateWindow API.

  • Вкл. Button свойства, установите right = 0
  • Когда Panel виден, Button имеет top := Panel.Height
  • В последний раз, когда Panel невидим (скрыт), Button имеет top := 0
0 голосов
/ 05 мая 2018

Попробуйте это:

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

...