1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
unit uAlhFloatingWindows;
interface
uses
System.SysUtils, System.Classes, FMX.Types, FMX.Controls,System.Types,System.UITypes,
FMX.Platform ;
type
TAlhFloatingWindows = class(TPanel)
private
{ Déclarations privées }
OkDeplace: Boolean;
HoldPosition: TPointF;
HoldMousePosition: TPointF;
protected
{ Déclarations protégées }
public
{ Déclarations publiques }
aTitleBar : TToolBar;
bClose : TButton;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure obOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
procedure obOnMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Single);
Procedure obOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
published
{ Déclarations publiées }
end;
procedure Register;
implementation
constructor TAlhFloatingWindows.Create(AOwner: TComponent);
begin
Inherited Create(AOwner);
aTitleBar:=TToolBar.Create(self);
bClose:=TButton.Create(self);
with bClose do
begin
Parent:=aTitleBar;
Height:=25;
Width:=25;
Align:=TAlignLayout.alRight;
Text:='X';
end;
with aTitleBar do
begin
Parent:=Self;
Height:= 25;
OnMouseDown:=obOnmouseDown;
OnMouseMove:=obOnMouseMove;
OnMouseUp:=obOnMouseUp;
end;
end;
destructor TAlhFloatingWindows.Destroy;
begin
Inherited;
end;
procedure TAlhFloatingWindows.obOnMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
begin
OkDeplace:=false;
end;
procedure TAlhFloatingWindows.obOnMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
OkDeplace:=true;
HoldPosition.X:=Position.X ;
HoldPosition.Y:=Position.Y;
HoldMousePosition:=Platform.GetMousePos;
end;
procedure TAlhFloatingWindows.obOnMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Single);
begin
if OkDeplace then
begin
Position.X:=HoldPosition.X+(Platform.GetMousePos.X-HoldMousePosition.X);
Position.Y:=HoldPosition.Y+(Platform.GetMousePos.Y-HoldMousePosition.Y);
end;
end;
procedure Register;
begin
RegisterComponents('AlhFiremonkey', [TAlhFloatingWindows]);
end;
end. |
Partager