Move borderless form in Firemonkey

╄→尐↘猪︶ㄣ 提交于 2019-12-02 11:02:18

If the VCL code that you want to replicate is:

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

then the equivalent for FMX would be:

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

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().

You may need to declare a couple of constants:

const
  WM_SYSCOMMAND = $0112;
  SC_DRAGMOVE = $F012;

What easier is just to use the StartWindowDrag method of the Form. This way it will work in both Windows and MacOS and its only 1 line of code. Like so:

procedure TForm4.dragPanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
    Self.StartWindowDrag;
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!