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.

 

posted on 2017-01-11 12:04  疯狂delphi  阅读(451)  评论(0编辑  收藏  举报

导航