如何在面板中显示Delphi表单? [英] How can I display a Delphi form in a panel?
问题描述
我尝试遵循 http://docwiki的示例. embarcadero.com/CodeExamples/XE7/en/FMXEmbeddedForm_(Delphi),但我遇到了TCustomForm子级的第一个问题,这些子级显然是只读的,因此我将其注释掉并放入ArgForm.Parent:= ArgParent;
中,但是我仍然只是一个空白屏幕,看不到第二种形式的按钮.
I've tried to follow the example of http://docwiki.embarcadero.com/CodeExamples/XE7/en/FMXEmbeddedForm_(Delphi) but I hit my first problem with the children of TCustomForm, which are apparently read only, so I commented that out and put in ArgForm.Parent:= ArgParent;
instead, but I still just get an empty screen and can't see the buttons that are in my second form.
我主要表单的代码是:
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, Unit2;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure EmbedForm(ArgParent : TControl; ArgForm : TCustomForm);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Form2: TForm2;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
begin
Form2:= TForm2.Create(Self);
EmbedForm(Panel1, Form2);
end;
procedure TForm1.EmbedForm(ArgParent: TControl; ArgForm: TCustomForm);
begin
//while ArgForm.ChildrenCount>0 do
//begin
//ArgForm.Children[0]:= ArgParent);
//end;
ArgForm.Parent:= ArgParent;
end;
end.
要放入主窗体面板中的窗体的代码是:
The code for the form to put in the panel of my main form is:
unit Unit2;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.fmx}
end.
推荐答案
您只需要完全使用示例中编写的代码即可.您写道:
You just need to use the code exactly as it is written in the example. You wrote:
while ArgForm.ChildrenCount>0 do
ArgForm.Children[0]:= ArgParent;
但是您链接到的示例中的代码为:
But the code in the example you linked to reads:
while ArgForm.ChildrenCount>0 do
ArgForm.Children[0].Parent := ArgParent;
从正面看,您至少已更正了embed的拼写.
On the plus side, you have at least corrected the spelling of embed.
这篇关于如何在面板中显示Delphi表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!