如何在控件中嵌入一个firemonkey表单? [英] How embed a firemonkey form inside a control?

查看:98
本文介绍了如何在控件中嵌入一个firemonkey表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 程序TfrmMain.FormCreate(发件人:TObject); 
var
控制:TControlView;
begin
控制:= TControlView.Create(Self);
Control.BorderIcons:= [];
Control.parent:= ListControls;
Control.width:= 800;
ListControls.AddObject(Control);
Control.Visible:= True;
结束

然而,该表单显示在tfrmMain后面以及窗体的bouns之外。



我的想法是在一个面板中放置一个表单,并且在滚动框内。每个表单代表一个具有多个控件和东西的复杂项目(不使用ListBox的原因?Firemonkey控件创建比简单地做一个表单更容易嵌入)

解决方案

这个秘密在于你如何设计孩子的表格。



你需要创建一个控件作为容器,说一个TLayout造型),TRectangle(基本款式)或TPanel。我会和TLayout一起去决定您的容器的名称,为了争论说容器。现在创建您的子窗体,并将容器的父项分配给您的父对象。



所以,从你的代码上面(我假设TControlView是你的小孩形式):

  procedure TfrmMain.FormCreate(Sender:TObject); 
var
控制:TControlView;
begin
控制:= TControlView.Create(Self);
Control.Container.parent:= ListControls;
Control.Container.width:= 800;
结束


I have tried to embed a form inside a Scrollbox:

procedure TfrmMain.FormCreate(Sender: TObject);
var
  Control:TControlView;
begin
  Control := TControlView.Create(Self);
  Control.BorderIcons := [];
  Control.parent := ListControls;
  Control.width := 800;
  ListControls.AddObject(Control);
  Control.Visible:= True;
end;

However the form is displayed behind tfrmMain and outside the bouns of the form.

My idea is put a form inside a panel, and both inside scrollbox. Each form represent a complex item with several controls and stuff (the reason to not use ListBox? Firemonkey control creation is far harder than simply do a form and embed it)

解决方案

The secret is in how you design your child form.

You need to create a control as a container, say a TLayout (no styling), TRectangle (Basic styling) or TPanel. I'd go with the TLayout. Decide on a name for your container, say 'Container' for the sake of argument. Now create you child form and simply assign the Parent of Container to your parent object.

So, from your code above (I'm assuming TControlView is your child form):

procedure TfrmMain.FormCreate(Sender: TObject);
var
  Control:TControlView;
begin
  Control := TControlView.Create(Self);
  Control.Container.parent := ListControls;
  Control.Container.width := 800;
end;

这篇关于如何在控件中嵌入一个firemonkey表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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