在Firemonkey中移动无边界的形式 [英] Move borderless form in Firemonkey

查看:149
本文介绍了在Firemonkey中移动无边界的形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VCL表单中,我使用 WM_SYSCOMMAND ,但在firemonkey中它是未声明的。

In VCL forms I use WM_SYSCOMMAND, but in firemonkey it is undeclared.

我测试这个代码:

procedure TForm4.dragPanelMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  isDraging := true;
  X0 := X;
  Y0 := Y;
end;

procedure TForm4.dragPanelMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Single);
begin
  if isDraging then
  begin
    Form4.Left := Trunc(Form4.Left + X - X0);
    Form4.Top := Trunc(Form4.Top + Y - Y0);
  end;
end;

procedure TForm4.dragPanelMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  isDraging := False;
end;

这个工作,但只是为了缓慢的动作!!!

this works, but just for slow moves!!!

如何在Firemonkey中移动表单?

How can I move form in Firemonkey?

推荐答案

如果要复制的VCL代码是: / p>

If the VCL code that you want to replicate is:

SendMessage(MyForm.Handle, WM_SYSCOMMAND, SC_DRAGMOVE, 0);

那么FMX的等价物将是:

then the equivalent for FMX would be:

SendMessage(FmxHandleToHWND(MyForm.Handle), WM_SYSCOMMAND, SC_DRAGMOVE, 0);

原因是 MyForm.Handle 一个FMX手柄。这与窗口把手不一样。您转换为一个窗口句柄,具有 FmxHandleToHWND()

The reason is that MyForm.Handle is an FMX handle. That's not the same as a window handle. You convert to a window handle with FmxHandleToHWND().

您可能需要声明几个常量: / p>

You may need to declare a couple of constants:

const
  WM_SYSCOMMAND = $0112;
  SC_DRAGMOVE = $F012;

这篇关于在Firemonkey中移动无边界的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆