我有一个简单的 IntraWeb 测试项目,我的 Unit1 有一个包含 3 个区域的 IWform:页眉、正文和页脚,如下所示:
type
TIWForm1 = class(TIWAppForm)
Body_Region: TIWRegion;
Header_Region: TIWRegion;
Footer_Region: TIWRegion;
public
end;
implementation
{$R *.dfm}
initialization
TIWForm1.SetAsMainForm;
end.
我的 Unit2 和 Unit3 是一个 IWFrame,它们只有一个按钮,如下所示:
type
TIWFrame2 = class(TFrame)
IWFrameRegion: TIWRegion;
Button1: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
end.
(单元3与单元2相同)
现在,我可以在设计时轻松地将框架分配给主体区域,方法是将框架从工具板拖放到该区域。
问题是如何在运行时将其更改为 unit3 Frame?
如果我尝试将它添加到这样的类型部分
type
TIWForm1 = class(TIWAppForm)
Body_Region: TIWRegion;
Header_Region: TIWRegion;
Footer_Region: TIWRegion;
MyFram2: TIWFrame2; // added here
procedure IWAppFormShow(Sender: TObject);
public
end;
系统试图删除它!
如果我强制保留它以将其用作
Body_Region.Parent := MyFram2;
身体部位什么都没有!
如果我在设计时手动添加它,我会得到相同的声明,我让它工作但我无法更改它!
我在这里遗漏了什么还是不可能这样做?
顺便说一句,我在 Delphi Berlin 10.1 和 IW14.1.12 上。