DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: lixuan123
今日帖子: 17
在线用户: 3
导航: 论坛 -> 移动应用开发 斑竹:flyers,iamdream  
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2022/12/27 16:26:37
标题:
关于FireMonkey将窗体显示在Panel如何实现? 浏览:1149
加入我的收藏
楼主: 原来在VCL中很轻松实现的功能,在FMX中都不灵了,请教大家FMX窗体如何显示到另一个窗体的PANEL中啊

这网上资料实在太少了,找了半天也没看到有这方面的资料
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
作者:
男 bluefish3000 (bluefish) ▲▲△△△ -
普通会员
2022/12/27 17:03:57
1楼: 将窗体换成TFrame不行吗?
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/12/27 21:48:51
2楼: Embarcdero docwike: for Sydney.... or Alexandria, etc...

https://docwiki.embarcadero.com/CodeExamples/Sydney/en/FMXEmbeddedForm_(Delphi)


// Add the following code to the unit where the TParentForm class is defined.
// Add the following method to the TParentForm class.
// AParent can be any control, such as a panel or a tabsheet item of a TabControl.

type
  TForm1 = class(TForm)
    Button1: TButton;
    Panel1: TPanel;
    Layout1: TLayout;
    procedure Button1Click(Sender: TObject);
  private
    procedure EmbeddForm(AParent: TControl; AForm: TCustomForm);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

uses
  Unit2;


procedure TParentForm.EmbeddForm(AParent:TControl; AForm:TCustomForm);
begin
  while AForm.ChildrenCount>0 do
    AForm.Children[0].Parent:=AParent;
end;
Add the following code to the OnCreate event handler of the ParentForm.

procedure TParentForm.FormCreate(Sender: TObject);
begin
  EmbeddForm(Panel1, TFormXXXXXXXXXX.Create(Self));
end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2022/12/28 8:44:28
3楼: emailx45,您好!

我按您的方法试验没有成功,我的代码如下:


//公共函数
procedure TFrmMain.OpenForm(AParent: TControl; AForm: TCustomForm);
begin
  while AForm.ChildrenCount>0 do
    AForm.Children[0].Parent:=AParent;
end;


//主窗体
procedure TFrmMain.FormCreate(Sender: TObject);
begin
FrmMain.OpenForm(FrmMain.Panel2, TFrmWorkTask.Create(Self));
end;


打开子窗体
procedure TFrmMain.ListBoxItem1Click(Sender: TObject);
begin
   FrmWorkTask.Show;
end;
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2022/12/28 9:18:16
4楼: 我改成以下情况,好像可以了

procedure TFrmMain.ListBoxItem1Click(Sender: TObject);
begin
   OpenForm(Panel2,FrmWorkTask);
end;

procedure TFrmMain.OpenForm(AParent: TControl; AForm: TCustomForm);
begin
  while AForm.ChildrenCount>0 do
    AForm.Children[0].Parent:=AParent;
end;
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/12/28 11:21:48
5楼: @changfenglee

in fact, you cannot use ".SHOW", because your "form" will be showed into "Panel", not on the screen!

on Embarcadero sample, in fact, you are just "copy" all "children" object from "formXXX" to "Panel1".

in FMX, it will be better if you use a "Layout" technic.

1) Form1-main has a "TLayout"-Main (to receive all object from others forms)

2) Form2-clients has a "TLayout"-Client with all objects
   Form3-clients has a "TLayout"-Client with all objects
   etc...

3) then, you can copy all objects from Layout-clients to Layout-Main

Form1.LayoutAAA.DeleteChildren;  // delete old objects
Form1.LayoutAAA.AddObject( Form2.LayoutBBB ); // add new objects
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2022/12/28 13:36:51
6楼: To:emailx45

非常感谢,按您的方式问题解决了
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2022/12/28 15:08:38
7楼: To:emailx45

不好意思,还有个新问题出现

问题是:当一个窗体第一次打开没问题,再打开第二个窗体也可以,但再回过来再点第一个窗体打开时,没反应了

   Lay1.DeleteChildren;
   Lay1.AddObject(FrmIndex.Lay1);

主窗体和子窗体上的Layout名称都叫Lay1
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2022/12/28 15:25:29
8楼: 我尝修改了一下代码

将Lay1.DeleteChildren;改成了Lay1.RemoveObject(0) ;

问题倒是解决了,但我不知道这是否为正解!
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2022/12/28 18:44:13
9楼: 用上面的方法结果还是有问题,窗体中如果涉及定时器,会相互干扰,还得从窗体下手,复制的方案还是不可取
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2022/12/28 18:57:31
10楼: 问题又回到了原点,如何在FireMonkey中将窗体放入Panel或Layout里面又成了原始问题,请大家指点
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
作者:
男 sxqwhxq (步惊云) ★☆☆☆☆ -
普通会员
2022/12/28 19:08:06
11楼: 应该把Frame放入panel里,把Form放入panel会有些问题,而且重复放入里要先删除原来的frame,注意不能freeandnil,要用dispose。
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/12/28 21:16:12
12楼: here my sample using FMX and "TLayout" to simulate a "pages" to show my components in anothers forms!

1) form main has a "TLayout" (main)
2) each form (sub-forms) has your Tlayouts...
此帖子包含附件:emailx45_20221228211612.zip 大小:14.4K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/12/28 21:16:28
13楼: screenshot
此帖子包含附件:
PNG 图像
大小:58.7K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 changfenglee (葫芦老四) ★☆☆☆☆ -
普通会员
2023/1/3 8:34:38
14楼: 我知道我的问题出现在哪里了,因为各窗体之前控件名称重名的问题,导致出现了混乱
----------------------------------------------
【个人签名】:玩了多年DELPHI,终于从菜鸟升级成老菜鸟
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行85.9375毫秒 RSS