DelphiXE8FMX工程实现无边框托动(FMX内部方法)
注意:
可以实现效果,但不知道我的用法对不对(或着说是不是最优化的用法),望高手们指教。
实例代码:
1 unit Unit1; 2 3 interface 4 5 uses 6 System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects; 8 9 type 10 TForm1 = class(TForm) 11 Image1: TImage; 12 procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, 13 Y: Single); 14 procedure FormCreate(Sender: TObject); 15 procedure Image1MouseDown(Sender: TObject; Button: TMouseButton; 16 Shift: TShiftState; X, Y: Single); 17 procedure Image1MouseUp(Sender: TObject; Button: TMouseButton; 18 Shift: TShiftState; X, Y: Single); 19 procedure FormShow(Sender: TObject); 20 private 21 { Private declarations } 22 public 23 { Public declarations } 24 end; 25 26 var 27 Form1: TForm1; 28 29 implementation 30 31 {$R *.fmx} 32 var IsDrag: Boolean; 33 34 procedure TForm1.FormShow(Sender: TObject); 35 begin 36 Self.BorderStyle := TFmxFormBorderStyle.None; //窗体样式 37 Image1.WrapMode := TImageWrapMode.Stretch; //图片加载方式 38 end; 39 40 procedure TForm1.FormCreate(Sender: TObject); 41 begin 42 IsDrag := False; 43 end; 44 45 procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; 46 Shift: TShiftState; X, Y: Single); 47 begin 48 if ssLeft in Shift then 49 begin 50 IsDrag := True; 51 end; 52 end; 53 54 procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, 55 Y: Single); 56 begin 57 if IsDrag = True then 58 Self.StartWindowDrag 59 else 60 begin 61 // 62 end; 63 end; 64 65 procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton; 66 Shift: TShiftState; X, Y: Single); 67 begin 68 IsDrag := False; 69 end; 70 71 end.
作者:疯狂Delphi
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
欢迎关注我,一起进步!扫描下方二维码即可加我