Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi Firemonkey-如何在TComponent下定位新表单_Delphi_Firemonkey - Fatal编程技术网

Delphi Firemonkey-如何在TComponent下定位新表单

Delphi Firemonkey-如何在TComponent下定位新表单,delphi,firemonkey,Delphi,Firemonkey,我正在用Delphi 10和Firemonkey为Windows/Apple开发一个应用程序。 我的主窗体有一个按钮。 当我按下TButton时,我想在TButton的正下方创建并定位Form1。 这是我的代码: //Transposes the coordinates in the context of the form. myTPointF := TButton.LocalToAbsolute(TButton.Position.Point); //Transposes the coord

我正在用Delphi 10和Firemonkey为Windows/Apple开发一个应用程序。 我的主窗体有一个按钮。 当我按下TButton时,我想在TButton的正下方创建并定位Form1。 这是我的代码:

//Transposes the coordinates in the context of the form. 
myTPointF := TButton.LocalToAbsolute(TButton.Position.Point);

//Transposes the coordinates in the context of the screen. 
myTPointF := ClientToScreen(myTPointF);

Form1.Top := FloatToStr(myTPointF.X) + Round(TButton.Height);
Form1.Left := FloatToStr(myTPointF.Y);
如果TButton靠近表单的点(0,0)(而不是屏幕),它会工作,但越远离该点,打开表单时Form1的错误就越多

图像的链接:


提前感谢您的帮助。

您不应该只使用
localtoabsolution()
客户端到屏幕(Button1.Position.Point)。您还可以在显示的代码中交换
X
Y

您最好先将第二个表单设置为可见,因为在
Fmx
框架中第一次显示除主表单之外的其他表单之前,不一定要创建它们

这项工作:

procedure TForm14.Button1Click(Sender: TObject);
var
  newpos: TPointF;
begin
  Form15.Visible := True;

  newpos := ClientToScreen(Button1.Position.Point);
  Form15.Left := Round(newpos.X);
  Form15.Top  := Round(newpos.Y+Button1.Height);
end;

你是说所有的苹果产品吗?或者只是一个特定的操作系统,比如MacOS?“你肯定不想在iOS中看到这样的东西,对吧?”戴维斯欢迎来到斯塔克沃夫流。此社区的成员通过SO引擎在其帖子中存储图像。避免使用外部链接,因为它们可能无法访问,Q将变得无用。