DelphiXE8FMX工程实现无边框托动(发送消息)

 

1.引用单元

uses Winapi.Windows, FMX.Platform.Win, Winapi.Messages;

 

2.发送消息

//发送系统消息
SendMessage(FmxHandleToHwnd(Handle), WM_SYSCOMMAND,SC_MOVE + HTCAPTION, 0);

网上说要用ReleaseCapture(),我没有用也可以,没细看为什么。

我看了一下ReleaseCapture()与StartWindowDrag,其实都是取坐标用的。

 

3.实例代码

 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 FormShow(Sender: TObject);
15   private
16     { Private declarations }
17   public
18     { Public declarations }
19   end;
20 
21 var
22   Form1: TForm1;
23 
24 implementation
25 uses Winapi.Windows, FMX.Platform.Win, Winapi.Messages;
26 {$R *.fmx}
27 
28 procedure TForm1.FormShow(Sender: TObject);
29 begin
30   Self.BorderStyle := TFmxFormBorderStyle.None; //窗体样式
31   Image1.WrapMode := TImageWrapMode.Stretch; //图片加载方式
32 end;
33 
34 procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
35   Y: Single);
36 begin
37   //发送系统消息
38   SendMessage(FmxHandleToHwnd(Handle), WM_SYSCOMMAND,SC_MOVE + HTCAPTION, 0);
39 end;
40 
41 end.

 

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

导航